--- a +++ b/trunk/cforge/cforge/Package/CFORGE/Scripts/build.py @@ -0,0 +1,46 @@ +import sys, os +import zipfile + + + +# This is a cforge command (script file) +# this will be run as ironpython script. +# the filename of this script is automatically the corresponding cforge command +# with some magic functions you can easily integrate it nicely into cforge tool + +# cforge_usage: +# here you can return an array of all possible arguments and options that can +# be passed to this command script +def cforge_usage(): + help = [ + ["<path to local repository>", "---"] + ] + + return help + + +if len(sys.argv) <= 1: + print("Oh, there are no arguments. Perhaps you forgot something?") + sys.exit() + +folder = sys.argv[1] + +def zipdir(path, ziph): + # ziph is zipfile handle + for root, dirs, files in os.walk(path): + for file in files: + filename=os.path.join(root, file) + archname=filename[len(path)+1:] + print("Adding file: %s -> %s" % (filename, archname)) + ziph.write(filename, arcname=archname) + + +for root, dirs, files in os.walk(folder): + for file in files: + if file == "package.manifest": + packageDir = root + packageName = root + ".package" + print("Creating package: '%s' -> '%s'" % (packageDir, packageName)) + zipf = zipfile.ZipFile(packageName, 'w', zipfile.ZIP_DEFLATED) + zipdir(packageDir, zipf) + zipf.close()