Skip to content

Commit 374ebd6

Browse files
authored
Style changes
Suggested by pylint.
1 parent ad2b937 commit 374ebd6

File tree

4 files changed

+51
-39
lines changed

4 files changed

+51
-39
lines changed

BuildPackages.py

+32-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
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+
27
import os, zipfile, sys
38

49
ROOT = ""
@@ -13,16 +18,16 @@
1318
def 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\tCore")
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...")
6269
main()

BuildRelease.bat

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@python BuildRelease.py
2+
@pause
+17-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
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+
27
import os, zipfile, sys, time
38

49
ROOT = ""
@@ -13,19 +18,19 @@
1318

1419
def main():
1520
print("Input version number: ")
16-
releaseVersion = input()
21+
release_version = input()
1722
print("Building a release archive...")
1823
global ROOT
19-
licenseFile = os.path.join(ROOT, "LICENSE.md")
20-
if not os.path.isfile(licenseFile):
24+
license_file = os.path.join(ROOT, "LICENSE.md")
25+
if not os.path.isfile(license_file):
2126
print("Could not find 'LICENSE.md' in '%s'." % ROOT)
2227
return
23-
licenseRelPath = os.path.relpath(licenseFile, os.path.split(licenseFile)[0])
24-
readmeFile = os.path.join(ROOT, "README.md")
25-
if not os.path.isfile(readmeFile):
28+
license_relative_path = os.path.relpath(license_file, os.path.split(license_file)[0])
29+
readme_file = os.path.join(ROOT, "README.md")
30+
if not os.path.isfile(readme_file):
2631
print("Could not find 'README.md' in '%s'." % ROOT)
2732
return
28-
readmeRelPath = os.path.relpath(readmeFile, os.path.split(readmeFile)[0])
33+
readme_relative_path = os.path.relpath(readme_file, os.path.split(readme_file)[0])
2934
rls = os.path.join(ROOT, "Releases")
3035
if not os.path.isdir(rls):
3136
os.makedirs(rls)
@@ -34,10 +39,10 @@ def main():
3439
print("Could not find 'Packages' folder in '%s'." % ROOT)
3540
return
3641
packages = [os.path.join(pkg, p) for p in os.listdir(pkg) if PACKAGE_EXTENSION in p]
37-
with zipfile.ZipFile(os.path.join(rls, "%s - %s%s" % (RELEASE_PREFIX, releaseVersion, RELEASE_EXTENSION)), "w") as releaseZip:
38-
releaseZip.write(licenseFile, licenseRelPath)
39-
releaseZip.write(readmeFile, readmeRelPath)
42+
with zipfile.ZipFile(os.path.join(rls, "%s - %s%s" % (RELEASE_PREFIX, release_version, RELEASE_EXTENSION)), "w") as release_zip:
43+
release_zip.write(license_file, license_relative_path)
44+
release_zip.write(readme_file, readme_relative_path)
4045
for package in packages:
41-
releaseZip.write(package, os.path.relpath(package, os.path.split(package)[0]))
46+
release_zip.write(package, os.path.relpath(package, os.path.split(package)[0]))
4247
print("Finished...")
4348
main()

BuildReleases.bat

-2
This file was deleted.

0 commit comments

Comments
 (0)