# Path: sourceutils/csvASTs/CSVProcessor.py
# class CSVProcessor:
#     def __init__(self):
#         self.handlers = dict()
#         self.defaultHandler = None
#         
#         self.reader = None
#         self.currentFile = None
#     
#     def processCSVRows(self, metaDataFile):
#         self.currentFile = metaDataFile
#         self.reader = csv.reader(open(metaDataFile), delimiter="\t",
#                             quotechar=None, escapechar=None)
#         
#         for row in self.reader:
#             self._processCSVRow(row)
#         
#     def _processCSVRow(self, row):
#         
#         if self.defaultHandler:
#             executeOtherHandlers = self.defaultHandler(row)
#             if not executeOtherHandlers: return
#         
#         lineType = getCSVRowType(row)
#         handler = self._getHandlerForType(lineType)
#         if not handler: return
#         handler(row)
# 
#     def registerChildHandler(self, level, childHandler):
#         self.parentLevel = level
#         self.defaultHandler = childHandler
#     
#     def unregisterChildHandler(self):
#         self.parentLevel = None
#         self.defaultHandler = None
# 
#     def _getHandlerForType(self, lineType):
#         try:
#             return self.handlers[lineType]
#         except:
#             return None
# 
# Path: sourceutils/csvASTs/CSVRowAccessors.py
# def getCSVRowLevel(row):
#     return row[LEVEL]
# 
# Path: sourceutils/pythonASTs/PythonASTTreeNode.py
# class PythonASTTreeNode():
#     def __init__(self, row):
#         self.row = row
#         self.children = []
# 
#     def appendChild(self, child):
#         self.children.append(child)
# 
#     def applyFunc(self, f):
#         self.row = f(self.row)
#         for child in self.children:
#             child.applyFunc(f)
#     
#     def __str__(self):
#         retStr = '@+'
#         retStr += str(self.row)
#         for child in self.children:
#             retStr += str(child)
#         retStr += '+@'
#         return retStr


import pickle
from sourceutils.csvASTs.CSVProcessor import CSVProcessor
from sourceutils.csvASTs.CSVRowAccessors import getCSVRowLevel
from sourceutils.pythonASTs.PythonASTTreeNode import PythonASTTreeNode



class CSVToPythonAST(CSVProcessor):
    def __init__(self):
        CSVProcessor.__init__(self)
        
        self.rootNode = PythonASTTreeNode(None)
        self.parentStack = []
        self.previousNode = self.rootNode
        
        self.defaultHandler = self.handleNode
    
    def handleNode(self, row):
        

# Path: sourceutils/csvASTs/CSVProcessor.py
# class CSVProcessor:
#     def __init__(self):
#         self.handlers = dict()
#         self.defaultHandler = None
#         
#         self.reader = None
#         self.currentFile = None
#     
#     def processCSVRows(self, metaDataFile):
#         self.currentFile = metaDataFile
#         self.reader = csv.reader(open(metaDataFile), delimiter="\t",
#                             quotechar=None, escapechar=None)
#         
#         for row in self.reader:
#             self._processCSVRow(row)
#         
#     def _processCSVRow(self, row):
#         
#         if self.defaultHandler:
#             executeOtherHandlers = self.defaultHandler(row)
#             if not executeOtherHandlers: return
#         
#         lineType = getCSVRowType(row)
#         handler = self._getHandlerForType(lineType)
#         if not handler: return
#         handler(row)
# 
#     def registerChildHandler(self, level, childHandler):
#         self.parentLevel = level
#         self.defaultHandler = childHandler
#     
#     def unregisterChildHandler(self):
#         self.parentLevel = None
#         self.defaultHandler = None
# 
#     def _getHandlerForType(self, lineType):
#         try:
#             return self.handlers[lineType]
#         except:
#             return None
# 
# Path: sourceutils/csvASTs/CSVRowAccessors.py
# def getCSVRowLevel(row):
#     return row[LEVEL]
# 
# Path: sourceutils/pythonASTs/PythonASTTreeNode.py
# class PythonASTTreeNode():
#     def __init__(self, row):
#         self.row = row
#         self.children = []
# 
#     def appendChild(self, child):
#         self.children.append(child)
# 
#     def applyFunc(self, f):
#         self.row = f(self.row)
#         for child in self.children:
#             child.applyFunc(f)
#     
#     def __str__(self):
#         retStr = '@+'
#         retStr += str(self.row)
#         for child in self.children:
#             retStr += str(child)
#         retStr += '+@'
#         return retStr


# Path: sourceutils/pythonASTs/CSVToPythonAST.py
import pickle
from sourceutils.csvASTs.CSVProcessor import CSVProcessor
from sourceutils.csvASTs.CSVRowAccessors import getCSVRowLevel
from sourceutils.pythonASTs.PythonASTTreeNode import PythonASTTreeNode




class CSVToPythonAST(CSVProcessor):
    def __init__(self):
        CSVProcessor.__init__(self)
        
        self.rootNode = PythonASTTreeNode(None)
        self.parentStack = []
        self.previousNode = self.rootNode
        
        self.defaultHandler = self.handleNode
    
    def handleNode(self, row):
        

        newNode = PythonASTTreeNode(row)