示例#1
0
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)
示例#2
0
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)
示例#3
0
def test_lookup_yaml():
    actual = loaders.loader_for_source('source.yaml')
    assert actual == loaders.load_yaml
示例#4
0
def test_lookup_json():
    actual = loaders.loader_for_source('source.json')
    assert actual == loaders.load_json
示例#5
0
def test_lookup_dbm():
    actual = loaders.loader_for_source('source.dbm')
    assert actual == loaders.load_dbm
示例#6
0
def test_lookup_csv():
    actual = loaders.loader_for_source('source.csv')
    assert actual == loaders.load_csv