def main(): parser = argparse.ArgumentParser( description='Work with recipe markdown files') parser.add_argument( '-i', metavar='mdfile', type=argparse.FileType('r'), help='name of the markdown file to process, default: use stdin', default=sys.stdin) parser.add_argument('-o', metavar='output', type=argparse.FileType('wb'), help='name of the output file, default: use stdout', default=sys.stdout.buffer) parser.add_argument( '-t', metavar='outtype', choices=['xml', 'json'], help='output type to generate (xml, json), default: xml', default='xml') parser.add_argument( '--xslt', metavar='xslt', help= 'xslt to reference in PI of generated XMLs, ignored if outtype is not "xml"', default=None) args = parser.parse_args() recipes = parseFile(args.i) if args.t == 'xml': xs.dump(args.o, recipes, args.xslt) else: js.dump(args.o, recipes)
def process(obj_id, target, xslt = None): """ get file from git, process, write to target folder Arguments: obj_id -- git object id of the file (as string) target -- target folder path (as string, with trailing slash) xslt -- xslt file path if xml-stylesheet PI should be included, no PI will be included if null (which is default) """ stream = io.TextIOWrapper(git.blob_file_handle(obj_id), encoding='utf8') r = parseFile(stream) dump(target, r, xslt)
def main(): parser = argparse.ArgumentParser(description='Work with recipe markdown files') parser.add_argument('-i', metavar='mdfile', type=argparse.FileType('r'), help='name of the markdown file to process, default: use stdin', default=sys.stdin) parser.add_argument('-o', metavar='output', type=argparse.FileType('wb'), help='name of the output file, default: use stdout', default=sys.stdout.buffer) parser.add_argument('-t', metavar='outtype', choices=['xml', 'json'], help='output type to generate (xml, json), default: xml', default='xml') parser.add_argument('--xslt', metavar='xslt', help='xslt to reference in PI of generated XMLs, ignored if outtype is not "xml"', default=None) args = parser.parse_args() recipes = parseFile(args.i) if args.t == 'xml': xs.dump(args.o, recipes, args.xslt) else: js.dump(args.o, recipes)