def main(): defaultTarget = '.' defaultUmask = 0o022 if settingsAvailable: defaultTarget = settings.TARGET defaultUmask = settings.UMASK parser = argparse.ArgumentParser(description='Work with recipe markdown files') parser.add_argument('-s', metavar='source', help='source of data', default='.') parser.add_argument('-t', metavar='target', help='target for processed outputs', default=defaultTarget) parser.add_argument('-i', help='do not reprocess, build index', default=None, action='store_true') parser.add_argument('-j', help='do not reprocess, build metadata json', default=None, action='store_true') args = parser.parse_args() if args.t is None: print('no target specified via command line or config file') return 1 if args.i is None and args.j is None: reprocess(args.t, args.s, defaultUmask) target = args.t + '/' if args.i or args.i is None: print('building html index') index.update_index(target) if args.j or args.j is None: print('building json index') index.update_json(target) return 0
def main(): os.umask(settings.UMASK) (ref, old, new) = sys.argv[1:4] print('starting processing of commit') cf = git.changed_files(old, new) # do a dry run to catch errors for f in cf: action = f[4] file = f[5] obj_id = f[3] if file.split('.')[-1] != settings.EXTENSION: continue if action == 'M' or action == 'A' or action == 'C': r = common.process(obj_id, '/dev/null', settings.XSLT) # do a real run for c in cf: action = c[4] file = c[5] obj_id = c[3] if file.split('.')[-1] != settings.EXTENSION: continue filename = common.xml_filename(file, settings.TARGET) if action == 'D': print('D {}'.format(file)) try: os.remove(filename) except FileNotFoundError: print( 'file to be removed, but could not be found'.format(file)) elif action == 'M' or action == 'A' or action == 'C': print('C {}'.format(file)) common.process(obj_id, filename, settings.XSLT) else: print('unknown git status {} of <{}>'.format(action, file), file=sys.stderr) index.update_index(settings.TARGET) index.update_json(settings.TARGET) print('finished processing of commits')
def main(): os.umask(settings.UMASK) (ref,old,new) = sys.argv[1:4] print('starting processing of commit') cf = git.changed_files(old,new) # do a dry run to catch errors for f in cf: action = f[4] file = f[5] obj_id = f[3] if file.split('.')[-1] != settings.EXTENSION: continue if action == 'M' or action == 'A' or action == 'C': r = common.process(obj_id, '/dev/null', settings.XSLT) # do a real run for c in cf: action = c[4] file = c[5] obj_id = c[3] if file.split('.')[-1] != settings.EXTENSION: continue filename = common.xml_filename(file, settings.TARGET) if action == 'D': print('D {}'.format(file)) try: os.remove(filename) except FileNotFoundError: print('file to be removed, but could not be found'.format(file)) elif action == 'M' or action == 'A' or action == 'C': print('C {}'.format(file)) common.process(obj_id, filename, settings.XSLT) else: print('unknown git status {} of <{}>'.format(action, file), file=sys.stderr) index.update_index(settings.TARGET) index.update_json(settings.TARGET) print('finished processing of commits')
def main(): defaultTarget = '.' defaultUmask = 0o022 if settingsAvailable: defaultTarget = settings.TARGET defaultUmask = settings.UMASK parser = argparse.ArgumentParser( description='Work with recipe markdown files') parser.add_argument('-s', metavar='source', help='source of data', default='.') parser.add_argument('-t', metavar='target', help='target for processed outputs', default=defaultTarget) parser.add_argument('-i', help='do not reprocess, build index', default=None, action='store_true') parser.add_argument('-j', help='do not reprocess, build metadata json', default=None, action='store_true') args = parser.parse_args() if args.t is None: print('no target specified via command line or config file') return 1 if args.i is None and args.j is None: reprocess(args.t, args.s, defaultUmask) target = args.t + '/' if args.i or args.i is None: print('building html index') index.update_index(target) if args.j or args.j is None: print('building json index') index.update_json(target) return 0