# 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
                    # Store the string
                    self.strings.append(x)
                    
                    # Update self.linemaps
                    linemap = self.linemaps[-1]
                    for c in x:
                        linemap.append(mappingId)
                        if c == '\n':
                            linemap = []
                            self.linemaps.append(linemap)
            else:
                assert isinstance(x, TargetNode)
                self.handleNode(x, parentMappingId=mappingId)
    
    def mappingIdForNode(self, node):
        if node in self.node_mappingId_map:
            return self.node_mappingId_map[node]
        else:
            lineno = getattr(node.pyNode, 'lineno', None)
            col_offset = getattr(node.pyNode, 'col_offset', None)
            if (lineno is None) or (col_offset is None):
                return None
            else:
                mappingId = self.nextMappingId
                self.nextMappingId += 1
                self.node_mappingId_map[node] = mappingId
                self.mappings.append([self.fileString, lineno, col_offset])
                return mappingId



# 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

                    # Store the string
                    self.strings.append(x)
                    
                    # Update self.linemaps
                    linemap = self.linemaps[-1]
                    for c in x:
                        linemap.append(mappingId)
                        if c == '\n':
                            linemap = []
                            self.linemaps.append(linemap)
            else:
                assert isinstance(x, TargetNode)
                self.handleNode(x, parentMappingId=mappingId)
    
    def mappingIdForNode(self, node):
        if node in self.node_mappingId_map:
            return self.node_mappingId_map[node]
        else:
            lineno = getattr(node.pyNode, 'lineno', None)
            col_offset = getattr(node.pyNode, 'col_offset', None)
            if (lineno is None) or (col_offset is None):
                return None
            else:
                mappingId = self.nextMappingId
                self.nextMappingId += 1
                self.node_mappingId_map[node] = mappingId
                self.mappings.append([self.fileString, lineno, col_offset])
                return mappingId



def exportSourceMap(linemaps, mappings, sourceDict):