예제 #1
0
def to_stdout(data, fmt):
    if fmt.startswith('j'):
        import json
        print json.dumps(data, indent=4)
    elif fmt.startswith('y'):
        from ec2audit import yamlout
        print yamlout.dump(data)
    elif fmt.startswith('p'):
        from pprint import pprint
        pprint(data)
예제 #2
0
파일: output.py 프로젝트: xxxVxxx/ec2audit
def to_stdout(data, fmt):
    if fmt.startswith('j'):
        import json
        print json.dumps(data, indent=4)
    elif fmt.startswith('y'):
        from ec2audit import yamlout
        print yamlout.dump(data)
    elif fmt.startswith('p'):
        from pprint import pprint
        pprint(data)
    elif fmt.startswith('db'):
        from pprint import pprint
        pprint(data.values()[0])
예제 #3
0
파일: output.py 프로젝트: xxxVxxx/ec2audit
def to_dir(data, fmt, output):
    if fmt.startswith("j"):
        import json

        ext = "json"
        dump = lambda data, f: json.dump(data, f, indent=4)
    elif fmt.startswith("y"):
        from ec2audit import yamlout

        ext = "yaml"
        dump = lambda data, f: yamlout.dump(data, f)
    elif fmt.startswith("p"):
        from pprint import pprint

        ext = "py"
        dump = lambda data, f: pprint(data, f)
    elif fmt.startswith("db"):
        import json

        ext = "db"
        dump = lambda data, f: json.dump(data[data.keys()[0]], f, indent=4)
    mkdirp(output)
    for dtype, items in data.items():
        base = join(output, dtype)
        mkdirp(base)
        for name, item in items.items():
            with open(join(base, name.replace("/", ":") + "." + ext), "w") as f:
                dump({name: item}, f)
예제 #4
0
파일: output.py 프로젝트: xxxVxxx/ec2audit
def to_stdout(data, fmt):
    if fmt.startswith("j"):
        import json

        print json.dumps(data, indent=4)
    elif fmt.startswith("y"):
        from ec2audit import yamlout

        print yamlout.dump(data)
    elif fmt.startswith("p"):
        from pprint import pprint

        pprint(data)
    elif fmt.startswith("db"):
        from pprint import pprint

        pprint(data.values()[0])
예제 #5
0
def to_dir(data, fmt, output):
    if fmt.startswith('j'):
        import json
        ext = 'json'
        dump = lambda data, f: json.dump(data, f, indent=4)
    elif fmt.startswith('y'):
        from ec2audit import yamlout
        ext = 'yaml'
        dump = lambda data, f: yamlout.dump(data, f)
    elif fmt.startswith('p'):
        from pprint import pprint
        ext = 'py'
        dump = lambda data, f: pprint(data, f)

    mkdirp(output)
    for dtype, items in data.items():
        base = join(output, dtype)
        mkdirp(base)
        for name, item in items.items():
            with open(join(base, name.replace('/', ':') + '.' + ext), 'w') as f:
                dump({name:item}, f)
예제 #6
0
파일: output.py 프로젝트: xxxVxxx/ec2audit
def to_dir(data, fmt, output):
    if fmt.startswith('j'):
        import json
        ext = 'json'
        dump = lambda data, f: json.dump(data, f, indent=4)
    elif fmt.startswith('y'):
        from ec2audit import yamlout
        ext = 'yaml'
        dump = lambda data, f: yamlout.dump(data, f)
    elif fmt.startswith('p'):
        from pprint import pprint
        ext = 'py'
        dump = lambda data, f: pprint(data, f)
    elif fmt.startswith('db'):
        import json
        ext = 'db'
        dump = lambda data, f: json.dump(data[data.keys()[0]], f, indent=4)
    mkdirp(output)
    for dtype, items in data.items():
        base = join(output, dtype)
        mkdirp(base)
        for name, item in items.items():
            with open(join(base, name.replace('/', ':') + '.' + ext), 'w') as f:
                dump({name:item}, f)