def getdir(*args): """Create dir if not exists Full path should be passed as individual arguments, as they are forwarded to os.path.join()""" if not isdir(makepath(*args)): mkdir(makepath(*args)) return makepath(*args)
from os.path import relpath as makepath from glob import glob root = makepath("../Release") # To add directories to the list of sources to generate file lists from, # simply edit this dictionary. The key is the directory path (relative to # the build output directory), and the value is either a glob pattern to include, # or an explicit list of files to include. # All paths should be in UNIX format, since makepath() will be used to convert them. # There should be no trailing slashes. files = { 'data/dialogs': '*.xml', 'data/strings': '*.txt', 'data/fonts': '*.ttf', 'data/shaders': ['mask.frag', 'mask.vert'], 'Scenario Editor/graphics.exd/mac': '*.png', 'Scenario Editor/graphics.exd/mac/cursors': '*.gif', 'Scenario Editor/sounds.exa': '*.WAV', } for path, pattern in files.items(): print 'SetOutPath', '"' + makepath("$INSTDIR/" + path + '/') + '"' if type(pattern) == list: check_files = [root + '/' + path + '/' + x for x in pattern] else: check_files = glob(root + '/' + path + '/' + pattern) for fname in check_files:
from os.path import normpath as makepath from glob import glob import sys root = makepath(sys.argv[1]) # To add directories to the list of sources to generate file lists from, # simply edit this dictionary. The key is the directory path (relative to # the build output directory), and the value is either a glob pattern to include, # or an explicit list of files to include. # All paths should be in UNIX format, since makepath() will be used to convert them. # There should be no trailing slashes. files = { 'data/dialogs': '*.xml', 'data/strings': '*.txt', 'data/fonts': '*.ttf', 'data/shaders': ['mask.frag', 'mask.vert'], 'data/graphics': '*.png', 'data/cursors': '*.gif', 'data/sounds': '*.WAV', } for path, pattern in files.items(): print 'SetOutPath', '"' + makepath("$INSTDIR/" + path + '/') + '"' if type(pattern) == list: check_files = [root + '/' + path + '/' + x for x in pattern] else: check_files = glob(makepath(root + '/' + path + '/' + pattern)) for fname in check_files:
from os.path import normpath as makepath from glob import glob import sys root = makepath(sys.argv[1]) # To add directories to the list of sources to generate file lists from, # simply edit this dictionary. The key is the directory path (relative to # the build output directory), and the value is either a glob pattern to include, # or an explicit list of files to include. # All paths should be in UNIX format, since makepath() will be used to convert them. # There should be no trailing slashes. files = { 'data/dialogs': '*.xml', 'data/strings': '*.txt', 'data/fonts': '*.ttf', 'data/shaders': ['mask.frag', 'mask.vert'], 'data/graphics': '*.png', 'data/cursors': '*.gif', 'data/sounds': '*.WAV', } for path, pattern in files.items(): print 'SetOutPath', '"' + makepath("$INSTDIR/" + path + '/') + '"' if type(pattern) == list: check_files = [root + '/' + path + '/' + x for x in pattern] else: check_files = glob(makepath(root + '/' + path + '/' + pattern))
if name: cd.remove_system(name[0]) cd.create_system(system) # Get command line options parser = argparse.ArgumentParser() parser.add_argument('-d', '--debug', help = 'Print debug information', action = 'store_true', default = False) parser.add_argument('-b', '--basedir', help = 'Base directory', required = True) parser.add_argument('-r', '--resource', help = 'Resource, defaults to hosts', default = 'hosts') parser.add_argument('-f', '--file', help = 'Validate resource file') parser.add_argument('-a', '--all', help = 'Validate all resource files', action = 'store_true', default = False) parser.add_argument('-c', '--cobbler', help = 'Create Cobbler system, can\'t be used with -a', action = 'store_true', default = False) args = parser.parse_args() # Load resource schema fname = makepath(args.basedir, args.resource, 'schema') schema = dict() if isfile(fname + '.yaml'): schema = yaml.load(open(fname + '.yaml').read()) elif isfile(fname + '.json'): schema = json.loads(open(fname + '.json').read()) else: print 'Schema doesn\'t exist: %s.(json|yaml)' % fname # Validate resource files if args.all: files = glob(makepath(args.basedir, args.resource, 'inputs', '*')) for fname in files: validate_resource(fname, schema) else: