# Path: sourceutils/codeTree/CodeTreeWalker.py
# class CodeTreeWalker:
#   
#     def __init__(self, projectRoot):
#         self.projectRoot = projectRoot
#     
#     def setFilenameFilterRegex(self, r):
#         self.filterRegex = re.compile(r)
#         
#     def __iter__(self):
#         for (dirpath, unused_dirnames, filenames) in os.walk(self.projectRoot):
#             for name in filenames:
#                 if not self.isOfInterest(name): continue
#                 absoluteName = dirpath + '/' + name
#                 yield absoluteName
#         
#     def getDirForFilename(self, filename):
#         return '/'.join(filename.split('/')[:-1])
# 
#     def isOfInterest(self, filename):
#         return self.filterRegex.match(filename)


from CSVToCFG import CSV2CFG
from sourceutils.codeTree.CodeTreeWalker import CodeTreeWalker
    import sys
#!/usr/bin/env python2

def extractCSVCFGs(projectRoot):

    codeTreeWalker = CodeTreeWalker(projectRoot)
    codeTreeWalker.setFilenameFilterRegex('(.*)\.(csv)$')
       
    for metaDataFile in codeTreeWalker:
        # print metaDataFile
        processor = CSV2CFG()
        processor.processCSVRows(metaDataFile)
        processor.terminateFunction()
    
def main(projectRoot):
    print("Creating PythonCFGs for " + projectRoot)
    extractCSVCFGs(projectRoot)


# Path: sourceutils/codeTree/CodeTreeWalker.py
# class CodeTreeWalker:
#   
#     def __init__(self, projectRoot):
#         self.projectRoot = projectRoot
#     
#     def setFilenameFilterRegex(self, r):
#         self.filterRegex = re.compile(r)
#         
#     def __iter__(self):
#         for (dirpath, unused_dirnames, filenames) in os.walk(self.projectRoot):
#             for name in filenames:
#                 if not self.isOfInterest(name): continue
#                 absoluteName = dirpath + '/' + name
#                 yield absoluteName
#         
#     def getDirForFilename(self, filename):
#         return '/'.join(filename.split('/')[:-1])
# 
#     def isOfInterest(self, filename):
#         return self.filterRegex.match(filename)


# Path: sourceutils/pythonCFGs/create.py
from CSVToCFG import CSV2CFG
from sourceutils.codeTree.CodeTreeWalker import CodeTreeWalker
    import sys

#!/usr/bin/env python2

def extractCSVCFGs(projectRoot):

    codeTreeWalker = CodeTreeWalker(projectRoot)
    codeTreeWalker.setFilenameFilterRegex('(.*)\.(csv)$')
       
    for metaDataFile in codeTreeWalker:
        # print metaDataFile
        processor = CSV2CFG()
        processor.processCSVRows(metaDataFile)
        processor.terminateFunction()
    
def main(projectRoot):
    print("Creating PythonCFGs for " + projectRoot)
    extractCSVCFGs(projectRoot)


if __name__ == '__main__':