Пример #1
0
 def __handleNamespaces__(self, Package, PackageJson):
     if "namespace" in PackageJson and PackageJson['namespace']:
         for namespace in PackageJson['namespace']:
             Package.addNamespace(namespace)
     if "globalnamespace" in PackageJson and PackageJson['globalnamespace']:
         for globalNamespace in PackageJson['globalnamespace']:
             Package.addGlobalNamespace(globalNamespace)
Пример #2
0
 def __outputDependent__(self, Package):
     outputDict = dict() # aggregate all the information together
     routineDeps = Package.getPackageRoutineDependents()
     for (key, value) in routineDeps.iteritems():
         packageName = key.getName()
         if packageName not in outputDict:
             outputDict[packageName] = dict()
         outputDict[packageName]['routine_dependent'] = dict()
         outputDict[packageName]['routine_dependent']["caller_routines"]=[x.getName() for x in value[0]]
         outputDict[packageName]['routine_dependent']["called_routines"]=[x.getName() for x in value[1]]
     globalDeps = Package.getPackageGlobalDependents()
     for (key, value) in globalDeps.iteritems():
         packageName = key.getName()
         if packageName not in outputDict:
             outputDict[packageName] = dict()
         outputDict[packageName]['global_dependent']= dict()
         outputDict[packageName]['global_dependent']["access_routine"]=[x.getName() for x in value[0]]
         outputDict[packageName]['global_dependent']["accessed_globals"]=[x.getName() for x in value[1]]
     fileManDeps = Package.getPackageFileManFileDependents()
     for (key, value) in fileManDeps.iteritems():
         packageName = key.getName()
         if packageName not in outputDict:
             outputDict[packageName] = dict()
         outputDict[packageName]['filemanfile_dependent']= dict()
         outputDict[packageName]['filemanfile_dependent']["pointed_to_by"]=[x.getName() for x in value[0]]
         outputDict[packageName]['filemanfile_dependent']["filemanfiles"]=[x.getName() for x in value[1]]
     return [{"package":x,"dependency_details":y} for x,y in outputDict.iteritems()]
Пример #3
0
 def __handleNamespaces__(self, Package, PackageJson):
     if "namespace" in PackageJson and PackageJson['namespace']:
         for namespace in PackageJson['namespace']:
             Package.addNamespace(namespace)
     if "globalnamespace" in PackageJson and PackageJson['globalnamespace']:
         for globalNamespace in PackageJson['globalnamespace']:
             Package.addGlobalNamespace(globalNamespace)
Пример #4
0
def unitTestRoutineJSONEncoder(outputFile):
    testPA = Package("TestPA")
    testPB = Package("TestPB")
    testPC = Package("TestPC")
    calledRoutineA = Routine("TestRA", testPB)
    calledRoutineB = Routine("TestRB", testPC)
    testRoutine = Routine("TestRA", testPA)
    localVar = LocalVariable("TSTLA", ">>", "YU+4,XU+1*")
    testRoutine.addLocalVariables(localVar)
    localVar = LocalVariable("TSTLB", ">>", "YU+1*,XU+3*")
    testRoutine.addLocalVariables(localVar)
    globalVar = GlobalVariable("TSTGA", ">>", "YU+4,XU+1*")
    testRoutine.addGlobalVariables(globalVar)
    nakedVar = NakedGlobal("^(20.2", None, "YU+4,XU+1")
    testRoutine.addNakedGlobals(nakedVar)
    labelRef = LabelReference("DD", None, "YU+4,XU+1")
    testRoutine.addLabelReference(labelRef)
    globalVar = Global("^TMP(\"TEST\"", None, None, None)
    testRoutine.addReferredGlobal(globalVar)
    globalVar = Global("^TMP($J", None, None, None)
    testRoutine.addReferredGlobal(globalVar)
    testRoutine.addCalledRoutines(calledRoutineA, "$$DT", "N+1,Y+3")
    testRoutine.addCalledRoutines(calledRoutineB, "$$OUT", "Y+1,Z+3")
    output = RoutineJSONEncoder().outputRoutine(testRoutine)
    outputFile = open(outputFile, "wb")
    outputFile.write(output)
    outputFile.write("\n")
Пример #5
0
 def outputPackage(self, Package):
     self._outputDict.clear()
     outputDict = self._outputDict
     outputDict['name'] = Package.getName()
     outputDict['routines'] = [x for x in Package.getAllRoutines().iterkeys()]
     outputDict['non_fileman_globals'] = []
     outputDict['fileman_globals'] = []
     for globalVar in Package.getAllGlobals().itervalues():
         globalName = globalVar.getName()
         if globalVar.isFileManFile():
             fileNo = globalVar.getFileNo()
             fileName = globalVar.getFileManName()
             outputDict['fileman_globals'].append(dict({'name': globalName,
                                                        'file_no': fileNo,
                                                        'file_name': fileName}))
         else:
             outputDict['non_fileman_globals'].append(globalName)
     outputDict['original_name'] = Package.getOriginalName()
     outputDict['namespace'] = Package.getNamespaces()
     outputDict['globalspace'] = Package.getGlobalNamespace()
     outputDict['docLink'] = Package.getDocLink()
     outputDict['mirrorLink'] = Package.getDocMirrorLink()
     outputDict['dependency'] = self.__outputDependency__(Package)
     outputDict['dependent'] = self.__outputDependent__(Package)
     return json.dumps(outputDict)
Пример #6
0
 def outputPackage(self, Package):
     self._outputDict.clear()
     outputDict = self._outputDict
     outputDict['name'] = Package.getName()
     outputDict['routines'] = [
         x for x in Package.getAllRoutines().iterkeys()
     ]
     outputDict['non_fileman_globals'] = []
     outputDict['fileman_globals'] = []
     for globalVar in Package.getAllGlobals().itervalues():
         globalName = globalVar.getName()
         if globalVar.isFileManFile():
             fileNo = globalVar.getFileNo()
             fileName = globalVar.getFileManName()
             outputDict['fileman_globals'].append(
                 dict({
                     'name': globalName,
                     'file_no': fileNo,
                     'file_name': fileName
                 }))
         else:
             outputDict['non_fileman_globals'].append(globalName)
     outputDict['original_name'] = Package.getOriginalName()
     outputDict['namespace'] = Package.getNamespaces()
     outputDict['globalspace'] = Package.getGlobalNamespace()
     outputDict['docLink'] = Package.getDocLink()
     outputDict['mirrorLink'] = Package.getDocMirrorLink()
     outputDict['dependency'] = self.__outputDependency__(Package)
     outputDict['dependent'] = self.__outputDependent__(Package)
     return json.dumps(outputDict)
Пример #7
0
 def __outputIndividualPackage__(self, outDir, Package):
     logger.info("Writing Package %s" % Package)
     outputFile = open(
         os.path.join(
             outDir, "Package_%s.json" %
             (Package.getName().replace(' ', '_').replace('-', '_'))), 'wb')
     outputFile.write(self._packageEncoder.outputPackage(Package))
     outputFile.write("\n")
     outputFile.close()
Пример #8
0
 def __handleAllGlobals__(self, Package, PackageJson):
     crossRef = self._crossRef
     for globalName in PackageJson['non_fileman_globals']:
         crossRef.addGlobalToPackageByName(globalName, Package.getName())
     packageName = PackageJson["name"]
     package = crossRef.getPackageByName(packageName)
     for fileManGlobalDict in PackageJson['fileman_globals']:
         globalName = fileManGlobalDict['name']
         fileNo = fileManGlobalDict['file_no']
         fileName = fileManGlobalDict['file_name']
         GlobalVar = Global(globalName, fileNo, fileName, package)
         crossRef.addGlobalToPackage(GlobalVar, packageName)
Пример #9
0
 def __handleAllGlobals__(self, Package, PackageJson):
     crossRef = self._crossRef
     for globalName in PackageJson['non_fileman_globals']:
         crossRef.addGlobalToPackageByName(globalName, Package.getName())
     packageName = PackageJson["name"]
     package = crossRef.getPackageByName(packageName)
     for fileManGlobalDict in PackageJson['fileman_globals']:
         globalName = fileManGlobalDict['name']
         fileNo = fileManGlobalDict['file_no']
         fileName = fileManGlobalDict['file_name']
         GlobalVar = Global(globalName, fileNo, fileName, package)
         crossRef.addGlobalToPackage(GlobalVar, packageName)
Пример #10
0
 def __setPackageProperties__(self, Package, PackageJson):
     if "original_name" in PackageJson:
         Package.setOriginalName(PackageJson["original_name"])
     if "docLink" in PackageJson:
         Package.setDocLink(PackageJson["docLink"])
     if "mirrorLink" in PackageJson:
         Package.setMirrorLink(PackageJson["mirrorLink"])
Пример #11
0
 def __setPackageProperties__(self, Package, PackageJson):
     if "original_name" in PackageJson:
         Package.setOriginalName(PackageJson["original_name"])
     if "docLink" in PackageJson:
         Package.setDocLink(PackageJson["docLink"])
     if "mirrorLink" in PackageJson:
         Package.setMirrorLink(PackageJson["mirrorLink"])
Пример #12
0
 def __outputDependent__(self, Package):
     outputDict = dict()  # aggregate all the information together
     routineDeps = Package.getPackageRoutineDependents()
     for (key, value) in routineDeps.iteritems():
         packageName = key.getName()
         if packageName not in outputDict:
             outputDict[packageName] = dict()
         outputDict[packageName]['routine_dependent'] = dict()
         outputDict[packageName]['routine_dependent']["caller_routines"] = [
             x.getName() for x in value[0]
         ]
         outputDict[packageName]['routine_dependent']["called_routines"] = [
             x.getName() for x in value[1]
         ]
     globalDeps = Package.getPackageGlobalDependents()
     for (key, value) in globalDeps.iteritems():
         packageName = key.getName()
         if packageName not in outputDict:
             outputDict[packageName] = dict()
         outputDict[packageName]['global_dependent'] = dict()
         outputDict[packageName]['global_dependent']["access_routine"] = [
             x.getName() for x in value[0]
         ]
         outputDict[packageName]['global_dependent']["accessed_globals"] = [
             x.getName() for x in value[1]
         ]
     fileManDeps = Package.getPackageFileManFileDependents()
     for (key, value) in fileManDeps.iteritems():
         packageName = key.getName()
         if packageName not in outputDict:
             outputDict[packageName] = dict()
         outputDict[packageName]['filemanfile_dependent'] = dict()
         outputDict[packageName]['filemanfile_dependent'][
             "pointed_to_by"] = [x.getName() for x in value[0]]
         outputDict[packageName]['filemanfile_dependent'][
             "filemanfiles"] = [x.getName() for x in value[1]]
     return [{
         "package": x,
         "dependency_details": y
     } for x, y in outputDict.iteritems()]
Пример #13
0
 def __handleAllRoutines__(self, Package, PackageJson):
     assert "routines" in PackageJson
     crossRef = self._crossRef
     for routineName in PackageJson['routines']:
         crossRef.addRoutineToPackageByName(routineName, Package.getName())
Пример #14
0
 def __outputIndividualPackage__(self, outDir, Package):
     logger.info("Writing Package %s" % Package)
     outputFile = open(os.path.join(outDir,"Package_%s.json" % (Package.getName().replace(' ','_').replace('-','_'))),'wb')
     outputFile.write(self._packageEncoder.outputPackage(Package))
     outputFile.write("\n")
     outputFile.close()
Пример #15
0
    def getRoutinePackageNameSpace(self, routineName):
        return self._crossRef.categorizeRoutineByNamespace(routineName)

    def getGlobalPackageNameSpace(self, globalName):
        return self._crossRef.categorizeGlobalByNamespace(globalName)


# end of class CallerGraphLogFileParser

#===============================================================================
# Section for unit/regression testing routines
#===============================================================================
#Testing Constants
# Unit test of categorizing routine based on namespace
RoutineNamespaceMappingTestDict = {
    "%ZTLOAD": ("%Z", Package("Kernel")),
    "PRC0A": ("PRC", Package("IFCAP")),
    "PRCABIL1": ("PRCA", Package("Accounts Receivable")),
    "RGUTALR": ("RGUT", Package("Run Time Library")),
    "IBQL356": ("IBQ", Package("Utilization Management Rollup")),
    "A1B2OSR": (None, None)
}


def testingRoutineNamespaceMapping(loggerParser, testMapping):
    for (routineName, expectedValue) in testMapping.iteritems():
        result = loggerParser.getRoutinePackageNameSpace(routineName)
        assert result == expectedValue, "result: %s, expect: %s" % (
            result, expectedValue)

Пример #16
0
 def __handleAllRoutines__(self, Package, PackageJson):
     assert "routines" in PackageJson
     crossRef = self._crossRef
     for routineName in PackageJson['routines']:
         crossRef.addRoutineToPackageByName(routineName, Package.getName())