# Path: pyxc/util.py
# def usingPython3():
#     return sys.version_info[0] == 3
# 
# Path: pyxc/util.py
# def rfilter(r, it, propFilter={}, invert=False):
#     '''
#     
#     >>> list(rfilter(r'^.o+$', ['foo', 'bar']))
#     ['foo']
#     
#     >>> list(rfilter(r'^.o+$', ['foo', 'bar'], invert=True))
#     ['bar']
#     
#     >>> list(rfilter(r'-(?P<x>[^-]+)-', ['fooo-baar-ooo', 'fooo-fooo-ooo'], propFilter={'x': r'o{3}'}))
#     ['fooo-fooo-ooo']
#     
#     >>> list(rfilter(r'-(?P<x>[^-]+)-', ['fooo-.*-ooo', 'fooo-fooo-ooo', 'fooo-.+-ooo'], propFilter={'x': ['.*', '.+']}))
#     ['fooo-.*-ooo', 'fooo-.+-ooo']
#     
#     '''
#     
#     # Supports Python 2 and 3
#     if isinstance(r, str):
#         r = re.compile(r)
#     try:
#         if isinstance(r, unicode):
#             r = re.compile
#     except NameError:
#         pass
#     
#     for x in it:
#         m = r.search(x)
#         ok = False
#         if m:
#             ok = True
#             if propFilter:
#                 d = m.groupdict()
#                 for k, v in propFilter.items():
#                     if k in d:
#                         if isinstance(v, basestring):
#                             if not re.search(v, d[k]):
#                                 ok = False
#                                 break
#                         else:
#                             if d[k] not in v:
#                                 ok = False
#                                 break
#         
#         if invert:
#             if not ok:
#                 yield x
#         else:
#             if ok:
#                 yield x
# 
# def parentOf(path):
#     return '/'.join(path.rstrip('/').split('/')[:-1])
# 
# def randomToken(n):
#     while True:
#         token = ''.join(random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') for i in range(n))
#         if not token.isdigit():
#             return token
# 
# Path: pyxc/pyxc_exceptions.py
# class NoTransformationForNode(PyxcError): pass


from pyxc.util import usingPython3
from pyxc.util import rfilter, parentOf, randomToken
from pyxc.pyxc_exceptions import NoTransformationForNode
import sys, os, ast, json, hashlib
                    return y
            raise NoTransformationForNode(repr(x))
        
        elif isinstance(x, TargetNode):
            self._finalizeTargetNode(x)
            return x
        
        else:
            # e.g. an integer
            return x
    
    def _finalizeTargetNode(self, y, pyNode=None):
        y.pyNode = pyNode
        y.transformedArgs = [self._transformNode(arg) for arg in y.args]
        y.transformer = self


#### Helpers

def getPythonAstNames():
    #LATER: do this properly
    return rfilter(r'[A-Z][a-zA-Z]+', dir(ast))


def loadTransformationsDict(parentModule):
    # transformationsDict = {
    #     'NodeName': [...transformation functions...]
    # }
    d = {}
    astNames = list(getPythonAstNames())

# Path: pyxc/util.py
# def usingPython3():
#     return sys.version_info[0] == 3
# 
# Path: pyxc/util.py
# def rfilter(r, it, propFilter={}, invert=False):
#     '''
#     
#     >>> list(rfilter(r'^.o+$', ['foo', 'bar']))
#     ['foo']
#     
#     >>> list(rfilter(r'^.o+$', ['foo', 'bar'], invert=True))
#     ['bar']
#     
#     >>> list(rfilter(r'-(?P<x>[^-]+)-', ['fooo-baar-ooo', 'fooo-fooo-ooo'], propFilter={'x': r'o{3}'}))
#     ['fooo-fooo-ooo']
#     
#     >>> list(rfilter(r'-(?P<x>[^-]+)-', ['fooo-.*-ooo', 'fooo-fooo-ooo', 'fooo-.+-ooo'], propFilter={'x': ['.*', '.+']}))
#     ['fooo-.*-ooo', 'fooo-.+-ooo']
#     
#     '''
#     
#     # Supports Python 2 and 3
#     if isinstance(r, str):
#         r = re.compile(r)
#     try:
#         if isinstance(r, unicode):
#             r = re.compile
#     except NameError:
#         pass
#     
#     for x in it:
#         m = r.search(x)
#         ok = False
#         if m:
#             ok = True
#             if propFilter:
#                 d = m.groupdict()
#                 for k, v in propFilter.items():
#                     if k in d:
#                         if isinstance(v, basestring):
#                             if not re.search(v, d[k]):
#                                 ok = False
#                                 break
#                         else:
#                             if d[k] not in v:
#                                 ok = False
#                                 break
#         
#         if invert:
#             if not ok:
#                 yield x
#         else:
#             if ok:
#                 yield x
# 
# def parentOf(path):
#     return '/'.join(path.rstrip('/').split('/')[:-1])
# 
# def randomToken(n):
#     while True:
#         token = ''.join(random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') for i in range(n))
#         if not token.isdigit():
#             return token
# 
# Path: pyxc/pyxc_exceptions.py
# class NoTransformationForNode(PyxcError): pass


# Path: pyxc/transforming.py
from pyxc.util import usingPython3
from pyxc.util import rfilter, parentOf, randomToken
from pyxc.pyxc_exceptions import NoTransformationForNode
import sys, os, ast, json, hashlib

                    return y
            raise NoTransformationForNode(repr(x))
        
        elif isinstance(x, TargetNode):
            self._finalizeTargetNode(x)
            return x
        
        else:
            # e.g. an integer
            return x
    
    def _finalizeTargetNode(self, y, pyNode=None):
        y.pyNode = pyNode
        y.transformedArgs = [self._transformNode(arg) for arg in y.args]
        y.transformer = self


#### Helpers

def getPythonAstNames():
    #LATER: do this properly
    return rfilter(r'[A-Z][a-zA-Z]+', dir(ast))


def loadTransformationsDict(parentModule):
    # transformationsDict = {
    #     'NodeName': [...transformation functions...]
    # }
    d = {}
    astNames = list(getPythonAstNames())

    filenames = rfilter(