1
- # Developed for Python 3.x
1
+ """
2
+ Builds .sublime-package files from the contents of the "Source" folder.
3
+
4
+ Developed for Python 3.x
5
+ """
6
+
2
7
import os , zipfile , sys
3
8
4
9
ROOT = ""
13
18
def main ():
14
19
print ("Building .sublime-package files..." )
15
20
global ROOT
16
- licenseFile = os .path .join (ROOT , "LICENSE.md" )
17
- if not os .path .isfile (licenseFile ):
21
+ license_file = os .path .join (ROOT , "LICENSE.md" )
22
+ if not os .path .isfile (license_file ):
18
23
print ("Could not find 'LICENSE.md' in '%s'." % ROOT )
19
24
return
20
- licenseRelPath = os .path .relpath (licenseFile , os .path .split (licenseFile )[0 ])
21
- readmeFile = os .path .join (ROOT , "README.md" )
22
- if not os .path .isfile (readmeFile ):
25
+ license_relative_path = os .path .relpath (license_file , os .path .split (license_file )[0 ])
26
+ readme_file = os .path .join (ROOT , "README.md" )
27
+ if not os .path .isfile (readme_file ):
23
28
print ("Could not find 'README.md' in '%s'." % ROOT )
24
29
return
25
- readmeRelPath = os .path .relpath (readmeFile , os .path .split (readmeFile )[0 ])
30
+ readme_relative_path = os .path .relpath (readme_file , os .path .split (readme_file )[0 ])
26
31
pkg = os .path .join (ROOT , "Packages" )
27
32
if not os .path .isdir (pkg ):
28
33
os .makedirs (pkg )
@@ -32,31 +37,33 @@ def main():
32
37
return
33
38
core = os .path .join (src , "Core" )
34
39
if os .path .isdir (core ):
35
- coreFiles = []
40
+ core_files = []
36
41
for root , dirs , files in os .walk (core ):
37
42
for file in files :
38
- coreFiles .append (os .path .join (root , file ))
39
- with zipfile .ZipFile (os .path .join (pkg , PACKGE_PREFIX + PACKAGE_EXTENSION ), "w" ) as coreZip :
40
- coreZip .write (licenseFile , licenseRelPath )
41
- coreZip .write (readmeFile , readmeRelPath )
42
- for file in coreFiles :
43
- coreZip .write (file , os .path .relpath (file , os .path .split (file )[0 ]))
43
+ core_files .append (os .path .join (root , file ))
44
+ with zipfile .ZipFile (os .path .join (pkg , PACKGE_PREFIX + PACKAGE_EXTENSION ), "w" ) as core_zip :
45
+ core_zip .write (license_file , license_relative_path )
46
+ core_zip .write (readme_file , readme_relative_path )
47
+ for file in core_files :
48
+ core_zip .write (file , os .path .relpath (file , os .path .split (file )[0 ]))
44
49
else :
45
50
print ("There is no 'Core' folder in '%s'." % src )
46
51
return
47
52
modules = os .path .join (src , "Modules" )
53
+ print ("Building modules:\n \t Core" )
48
54
if os .path .isdir (modules ):
49
- for moduleName in os .listdir (modules ):
50
- modulePath = os .path .join (modules , moduleName )
51
- if os .path .isdir (modulePath ):
52
- moduleFiles = []
53
- for root , dirs , files in os .walk (modulePath ):
55
+ for module_name in os .listdir (modules ):
56
+ print ("\t " + module_name )
57
+ module_path = os .path .join (modules , module_name )
58
+ if os .path .isdir (module_path ):
59
+ module_files = []
60
+ for root , dirs , files in os .walk (module_path ):
54
61
for file in files :
55
- moduleFiles .append (os .path .join (root , file ))
56
- with zipfile .ZipFile (os .path .join (pkg , "%s - %s%s" % (PACKGE_PREFIX , moduleName , PACKAGE_EXTENSION )), "w" ) as moduleZip :
57
- moduleZip .write (licenseFile , licenseRelPath )
58
- moduleZip .write (readmeFile , readmeRelPath )
59
- for file in moduleFiles :
60
- moduleZip .write (file , os .path .relpath (file , os .path .split (file )[0 ]))
62
+ module_files .append (os .path .join (root , file ))
63
+ with zipfile .ZipFile (os .path .join (pkg , "%s - %s%s" % (PACKGE_PREFIX , module_name , PACKAGE_EXTENSION )), "w" ) as module_zip :
64
+ module_zip .write (license_file , license_relative_path )
65
+ module_zip .write (readme_file , readme_relative_path )
66
+ for file in module_files :
67
+ module_zip .write (file , os .path .relpath (file , os .path .split (file )[0 ]))
61
68
print ("Finished..." )
62
69
main ()
0 commit comments