def RawParserUnparserFactory(parser_name, parse_callable, *unparse_callables):
def build_unparse(f):<EOL><INDENT>@wraps(f)<EOL>def unparse(self, source, *a, **kw):<EOL><INDENT>node = parse_callable(source)<EOL>return f(node, *a, **kw)<EOL><DEDENT>unparse.__doc__ = f.__doc__.replace(<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>)<EOL>return unparse<EOL><DEDENT>def build_parse(f):<EOL><INDENT>@wraps(f)<EOL>def parse(self, source):<EOL><INDENT>return f(source)<EOL><DEDENT>parse.__name__ = parser_name<EOL>parse.__qualname__ = parser_name<EOL>return parse<EOL><DEDENT>callables = {f.__name__: build_unparse(f) for f in unparse_callables}<EOL>callables['<STR_LIT>'] = build_parse(parse_callable)<EOL>callables['<STR_LIT>'] = PKGNAME<EOL>return type(parser_name, (object,), callables)()<EOL>
Produces a callable object that also has callable attributes that
passes its first argument to the parent callable.