def render(args, conf): conf.update(_parse_options(args.option)) conf.update({ "source": args.source, "template": args.template, "absolute_resolved_path": os.path.abspath(args.source) }) load = loaders.loader_for_source(args.source) if load is None: print('Could not find loader for {}'.format(args.source)) return 1 with io.open(args.template, 'r', encoding='utf-8-sig') as f: template_body = f.read() template = jinja2.Template(template_body) with load(**conf) as data: rendered = template.render( make_list_table=helpers.make_list_table, make_list_table_from_mappings=helpers. make_list_table_from_mappings, data=data, **conf ) print(rendered)
def dump(args, conf): conf.update(_parse_options(args.option)) conf.update({ "source": args.source, "absolute_resolved_path": os.path.abspath(args.source) }) load = loaders.loader_for_source(args.source) if load is None: print('Could not find loader for {}'.format(args.source)) return 1 with load(**conf) as data: pprint.pprint(data)
def test_lookup_yaml(): actual = loaders.loader_for_source('source.yaml') assert actual == loaders.load_yaml
def test_lookup_json(): actual = loaders.loader_for_source('source.json') assert actual == loaders.load_json
def test_lookup_dbm(): actual = loaders.loader_for_source('source.dbm') assert actual == loaders.load_dbm
def test_lookup_csv(): actual = loaders.loader_for_source('source.csv') assert actual == loaders.load_csv