Skip to content

Commit 1750fd5

Browse files
committed
Merge pull request #14 from Kapiainen/rewrite
Rewrite
2 parents 293a45f + 6fb1182 commit 1750fd5

File tree

3,113 files changed

+6729
-21573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,113 files changed

+6729
-21573
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
*.stackdump
22
Packages/
3-
Release/
3+
Releases/

BuildPackages.py

+54-48
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,55 @@
1-
# Developed on Python 3.2.5
2-
# This program goes through the repository looking for files in specific places, adds the files to lists, and then generates .sublime-package files.
3-
import os, io, zipfile, time
1+
# Developed for Python 3.x
2+
import os, zipfile
43

5-
packagename = "SublimePapyrus"
6-
packageextension = ".sublime-package"
7-
packagedirectory = "Packages"
8-
corefiles = [] # Contains all the files in SublimePapyrus.sublime-package.
9-
corelibraries = ["skyrim"] # The libraries to include in the core package.
10-
libraries = {} # Contains lists of files for each library. Produces SublimePapyrus - Key.sublime-package files.
11-
currentdirectory = os.getcwd()
12-
for entry in os.listdir(currentdirectory):
13-
if entry.lower().startswith("."):
14-
continue
15-
if not os.path.isfile(entry):
16-
if entry.lower() == "core":
17-
coredirectory = os.path.join(currentdirectory, entry)
18-
for corefile in os.listdir(coredirectory):
19-
corefiles.append(os.path.join(coredirectory, corefile))
20-
elif entry.lower() == "libraries":
21-
librariesdirectory = os.path.join(currentdirectory, entry)
22-
for library in os.listdir(librariesdirectory):
23-
librarydirectory = os.path.join(librariesdirectory, library)
24-
if library.lower() in corelibraries:
25-
for libraryfile in os.listdir(librarydirectory):
26-
corefiles.append(os.path.join(librarydirectory, libraryfile))
27-
else:
28-
libraryfiles = []
29-
for libraryfile in os.listdir(librarydirectory):
30-
libraryfiles.append(os.path.join(librarydirectory, libraryfile))
31-
libraries[library] = libraryfiles
32-
outputdirectory = os.path.join(currentdirectory, packagedirectory)
33-
if not os.path.exists(outputdirectory):
34-
os.mkdir(outputdirectory)
35-
print("Core files:")
36-
corepackage = packagename + packageextension
37-
with zipfile.ZipFile(os.path.join(outputdirectory, corepackage), "w") as corezip:
38-
for corefile in corefiles:
39-
print(corefile)
40-
corezip.write(corefile, os.path.relpath(corefile, os.path.split(corefile)[0]))
41-
for library in libraries.keys():
42-
print("\n" + library + " files:")
43-
librarypackage = packagename + " - " + library + packageextension
44-
with zipfile.ZipFile(os.path.join(outputdirectory, librarypackage), "w") as libraryzip:
45-
for libraryfile in libraries[library]:
46-
print(libraryfile)
47-
libraryzip.write(libraryfile, os.path.relpath(libraryfile, os.path.split(libraryfile)[0]))
48-
print("\nDone!")
49-
#time.sleep(2.0)
4+
PACKGE_PREFIX = "SublimePapyrus"
5+
PACKAGE_EXTENSION = ".sublime-package"
6+
7+
def main():
8+
cwd = os.getcwd()
9+
licenseFile = os.path.join(cwd, "LICENSE.md")
10+
if not os.path.isfile(licenseFile):
11+
print("Could not find 'LICENSE.md' in '%s'." % cwd)
12+
return
13+
licenseRelPath = os.path.relpath(licenseFile, os.path.split(licenseFile)[0])
14+
readmeFile = os.path.join(cwd, "README.md")
15+
if not os.path.isfile(readmeFile):
16+
print("Could not find 'README.md' in '%s'." % cwd)
17+
return
18+
readmeRelPath = os.path.relpath(readmeFile, os.path.split(readmeFile)[0])
19+
pkg = os.path.join(cwd, "Packages")
20+
if not os.path.isdir(pkg):
21+
os.makedirs(pkg)
22+
src = os.path.join(cwd, "Source")
23+
if not os.path.isdir(src):
24+
print("There is no 'Source' folder in '%s'." % cwd)
25+
return
26+
core = os.path.join(src, "Core")
27+
if os.path.isdir(core):
28+
coreFiles = []
29+
for root, dirs, files in os.walk(core):
30+
for file in files:
31+
coreFiles.append(os.path.join(root, file))
32+
with zipfile.ZipFile(os.path.join(pkg, PACKGE_PREFIX+PACKAGE_EXTENSION), "w") as coreZip:
33+
coreZip.write(licenseFile, licenseRelPath)
34+
coreZip.write(readmeFile, readmeRelPath)
35+
for file in coreFiles:
36+
coreZip.write(file, os.path.relpath(file, os.path.split(file)[0]))
37+
else:
38+
print("There is no 'Core' folder in '%s'." % src)
39+
return
40+
modules = os.path.join(src, "Modules")
41+
if os.path.isdir(modules):
42+
for moduleName in os.listdir(modules):
43+
modulePath = os.path.join(modules, moduleName)
44+
if os.path.isdir(modulePath):
45+
moduleFiles = []
46+
for root, dirs, files in os.walk(modulePath):
47+
for file in files:
48+
moduleFiles.append(os.path.join(root, file))
49+
with zipfile.ZipFile(os.path.join(pkg, "%s - %s%s" % (PACKGE_PREFIX, moduleName, PACKAGE_EXTENSION)), "w") as moduleZip:
50+
moduleZip.write(licenseFile, licenseRelPath)
51+
moduleZip.write(readmeFile, readmeRelPath)
52+
for file in moduleFiles:
53+
moduleZip.write(file, os.path.relpath(file, os.path.split(file)[0]))
54+
print("Finished...")
55+
main()

BuildRelease.py

-37
This file was deleted.

BuildReleases.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Developed for Python 3.x
2+
import os, zipfile, time
3+
4+
RELEASE_PREFIX = "SublimePapyrus"
5+
RELEASE_EXTENSION = ".zip"
6+
PACKAGE_EXTENSION = ".sublime-package"
7+
8+
def main():
9+
cwd = os.getcwd()
10+
licenseFile = os.path.join(cwd, "LICENSE.md")
11+
if not os.path.isfile(licenseFile):
12+
print("Could not find 'LICENSE.md' in '%s'." % cwd)
13+
return
14+
licenseRelPath = os.path.relpath(licenseFile, os.path.split(licenseFile)[0])
15+
readmeFile = os.path.join(cwd, "README.md")
16+
if not os.path.isfile(readmeFile):
17+
print("Could not find 'README.md' in '%s'." % cwd)
18+
return
19+
readmeRelPath = os.path.relpath(readmeFile, os.path.split(readmeFile)[0])
20+
rls = os.path.join(cwd, "Releases")
21+
if not os.path.isdir(rls):
22+
os.makedirs(rls)
23+
pkg = os.path.join(cwd, "Packages")
24+
if not os.path.isdir(pkg):
25+
print("Could not find 'Packages' folder in '%s'." % cwd)
26+
return
27+
packages = [os.path.join(pkg, p) for p in os.listdir(pkg) if PACKAGE_EXTENSION in p]
28+
with zipfile.ZipFile(os.path.join(rls, "%s - %s%s" % (RELEASE_PREFIX, time.strftime("%Y-%m-%d %H-%M-%S", time.gmtime()), RELEASE_EXTENSION)), "w") as releaseZip:
29+
releaseZip.write(licenseFile, licenseRelPath)
30+
releaseZip.write(readmeFile, readmeRelPath)
31+
for package in packages:
32+
releaseZip.write(package, os.path.relpath(package, os.path.split(package)[0]))
33+
print("Finished...")
34+
main()

Core/Auto-State.sublime-snippet

-8
This file was deleted.

Core/Compiled Papyrus.tmLanguage

-19
This file was deleted.

Core/Default.sublime-commands

-22
This file was deleted.

Core/Disassemble Papyrus.sublime-build

-5
This file was deleted.

Core/ElseIf.sublime-snippet

-7
This file was deleted.

Core/Event.sublime-snippet

-8
This file was deleted.

Core/For.sublime-snippet

-10
This file was deleted.

Core/Function.sublime-snippet

-8
This file was deleted.

Core/GetState.sublime-snippet

-6
This file was deleted.

Core/GoToState.sublime-snippet

-6
This file was deleted.

Core/If.sublime-snippet

-8
This file was deleted.

Core/Miscellaneous.tmPreferences

-46
This file was deleted.

Core/OnBeginState.sublime-snippet

-8
This file was deleted.

Core/OnEndState.sublime-snippet

-8
This file was deleted.

Core/OnInit.sublime-snippet

-8
This file was deleted.

Core/Papyrus - batch.sublime-build

-6
This file was deleted.

Core/Papyrus Assembly.sublime-build

-5
This file was deleted.

0 commit comments

Comments
 (0)