Ejemplo n.º 1
0
def transform_to_serial(parsed, transformer):
    default_serializer = default_object_serializer(transformer)
    transformed = transformer.transform(parsed)
    return json.dumps(transformed,
                      separators=(',', ':'),
                      default=default_serializer)

def default_object_serializer(transformer):
    if hasattr(transformer, 'default_serializer'):
        return transformer.default_serializer()
    else:
        return lambda x: x.__dict__

def print_error(text, was, now):
    print "----------------"
    print text
    print "WAS: %s" % was
    print "IS:  %s" % now

def dump_results(specs, output_path):
    with open(output_path, 'w') as output_file:
        results = OrderedDict([
            ("env", ENV),
            ("specs", specs)
        ])
        json.dump(results, output_file, indent=4)

if __name__ == '__main__':
    configure_platform()
    main()
Ejemplo n.º 2
0
def _main():
    configure_platform()
    text = " ".join(sys.argv[1:])
    run(text)
Ejemplo n.º 3
0
    default_serializer = default_object_serializer(transformer)
    transformed = transformer.transform(parsed)
    return json.dumps(transformed,
                      separators=(',', ':'),
                      default=default_serializer)


def default_object_serializer(transformer):
    if hasattr(transformer, 'default_serializer'):
        return transformer.default_serializer()
    else:
        return lambda x: x.__dict__


def print_error(text, was, now):
    print("----------------")
    print(text)
    print("WAS: %s" % was)
    print("IS:  %s" % now)


def dump_results(specs, output_path):
    with open(output_path, 'w') as output_file:
        results = OrderedDict([("env", ENV), ("specs", specs)])
        json.dump(results, output_file, indent=4)


if __name__ == '__main__':
    configure_platform()
    main()
Ejemplo n.º 4
0
def _main():
    configure_platform()
    text = " ".join(sys.argv[1:])
    run(text)