Skip to content

Instantly share code, notes, and snippets.

@natural
Created September 1, 2013 22:14
Show Gist options
  • Save natural/6407668 to your computer and use it in GitHub Desktop.
Save natural/6407668 to your computer and use it in GitHub Desktop.
example j2py config file to throw away interfaces when generating python code
from java2python.config.default import astTransforms
from java2python.lang.selector import Type
from java2python.lang import tokens
interfaces = []
def throwAwayInterface(node, config):
interfaces.append(node.firstChildOfType(tokens.IDENT).text)
node.parent.children.remove(node)
def replaceInterfaces(node, config):
for token in node.findChildren():
if token.type == tokens.IDENT and token.text in interfaces:
token.parent.children.remove(token)
astTransforms.extend([
(Type('INTERFACE'), throwAwayInterface),
(Type('IMPLEMENTS_CLAUSE'), replaceInterfaces)
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment