Diff of /trunk/cforge/cforge/Package/CFORGE/Scripts/build.py [r25] .. [r26]  Maximize  Restore

Switch to unified view

a/trunk/cforge/cforge/Package/CFORGE/Scripts/build.py b/trunk/cforge/cforge/Package/CFORGE/Scripts/build.py
1
import sys, os
1
import sys, os
2
import zipfile
2
import zipfile
3
3
import cds_script
4
4
5
5
6
# This is a cforge command (script file)
6
# This is a cforge command (script file)
7
# this will be run as ironpython script.
7
# this will be run as ironpython script.
8
# the filename of this script is automatically the corresponding cforge command 
8
# the filename of this script is automatically the corresponding cforge command 
...
...
21
21
22
if len(sys.argv) <= 1:
22
if len(sys.argv) <= 1:
23
    print("Oh, there are no arguments. Perhaps you forgot something?")
23
    print("Oh, there are no arguments. Perhaps you forgot something?")
24
    sys.exit()
24
    sys.exit()
25
25
26
folder = sys.argv[1]
26
folder = sys.argv[1]
27
scriptpath = os.path.abspath(os.path.dirname(sys.argv[0]))
27
28
28
def zipdir(path, ziph):
29
def zipdir(path, ziph):
29
    # ziph is zipfile handle
30
    # ziph is zipfile handle
30
    for root, dirs, files in os.walk(path):
31
    for root, dirs, files in os.walk(path):
31
        for file in files:
32
        for file in files:
...
...
33
            archname=filename[len(path)+1:]
34
            archname=filename[len(path)+1:]
34
            print("Adding file: %s -> %s" % (filename, archname))
35
            print("Adding file: %s -> %s" % (filename, archname))
35
            ziph.write(filename, arcname=archname)
36
            ziph.write(filename, arcname=archname)
36
37
37
38
39
# Build all packages
38
for root, dirs, files in os.walk(folder):
40
for root, dirs, files in os.walk(folder):
39
    for file in files:
41
    for file in files:
40
        if file == "package.manifest":
42
        if file == "package.manifest":
41
            packageDir = root
43
            packageDir = root
42
            packageName = root + ".package"
44
            packageName = root + ".package"
43
            print("Creating package: '%s' -> '%s'" % (packageDir, packageName))
45
            print("Creating package: '%s' -> '%s'" % (packageDir, packageName))
44
            zipf = zipfile.ZipFile(packageName, 'w', zipfile.ZIP_DEFLATED)
46
            zipf = zipfile.ZipFile(packageName, 'w', zipfile.ZIP_DEFLATED)
45
            zipdir(packageDir, zipf)
47
            zipdir(packageDir, zipf)
46
            zipf.close()
48
            zipf.close()
47
49
50
# Export documentation as markdown
51
52
scriptname = os.path.join(scriptpath, "action.markdown.py")
53
scriptargs = folder
54
55
cds_script.RunCodesysWithScript(scriptname, scriptargs, False)