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")
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")
def __addVarToRoutine__(self, Routine, CrossReference): globalVar = CrossReference.getGlobalByName(self._varName) if not globalVar: # this is to fix a problem with the name convention of a top level global # like ICD9 can be referred as eith ICD9 or ICD9( altName = getAlternateGlobalName(self._varName) globalVar = CrossReference.getGlobalByName(altName) if globalVar: self._varName = altName Routine.addGlobalVariables( GlobalVariable(self._varName, self._varPrefix, self._varValue))
def __addVarToRoutine__(self, Routine, CrossReference): globalVar = CrossReference.getGlobalByName(self._varName) if not globalVar: # this is to fix a problem with the name convention of a top level global # like ICD9 can be referred as eith ICD9 or ICD9( altName = getAlternateGlobalName(self._varName) globalVar = CrossReference.getGlobalByName(altName) if globalVar: logger.debug("Changing global name from %s to %s" % (self._varName, altName)) self._varName = altName Routine.addGlobalVariables(GlobalVariable(self._varName, self._varPrefix, self._varValue))