def output(fn):
p = Parser(expand_includes=False, include_comments=True)<EOL>m = MapfileToDict(include_position=True, include_comments=True)<EOL>v = Validator()<EOL>try:<EOL><INDENT>ast = p.parse_file(fn)<EOL>d = m.transform(ast)<EOL>logging.debug("<STR_LIT>".format(len(d["<STR_LIT>"])))<EOL>errors = v.validate(d, add_comments=True)<EOL>assert(len(errors) == <NUM_LIT:0>)<EOL><DEDENT>except Exception as ex:<EOL><INDENT>logging.exception(ex)<EOL>logging.warning("<STR_LIT>", fn)<EOL>d = None<EOL>raise<EOL><DEDENT>if d:<EOL><INDENT>try:<EOL><INDENT>s = mappyfile.utils.dumps(d)<EOL><DEDENT>except Exception:<EOL><INDENT>logging.warning(json.dumps(d, indent=<NUM_LIT:4>))<EOL>logging.warning("<STR_LIT>", fn)<EOL>raise<EOL><DEDENT>ast = p.parse(s)<EOL>d = m.transform(ast)<EOL>errors = v.validate(d)<EOL>assert(len(errors) == <NUM_LIT:0>)<EOL><DEDENT>
Parse, transform, and pretty print
the result