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+
27import os , zipfile , sys
38
49ROOT = ""
1318def main ():
1419 print ("Building .sublime-package files..." )
1520 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 ):
1823 print ("Could not find 'LICENSE.md' in '%s'." % ROOT )
1924 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 ):
2328 print ("Could not find 'README.md' in '%s'." % ROOT )
2429 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 ])
2631 pkg = os .path .join (ROOT , "Packages" )
2732 if not os .path .isdir (pkg ):
2833 os .makedirs (pkg )
@@ -32,31 +37,33 @@ def main():
3237 return
3338 core = os .path .join (src , "Core" )
3439 if os .path .isdir (core ):
35- coreFiles = []
40+ core_files = []
3641 for root , dirs , files in os .walk (core ):
3742 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 ]))
4449 else :
4550 print ("There is no 'Core' folder in '%s'." % src )
4651 return
4752 modules = os .path .join (src , "Modules" )
53+ print ("Building modules:\n \t Core" )
4854 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 ):
5461 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 ]))
6168 print ("Finished..." )
6269main ()
0 commit comments