Example #1
0
def checkCSVDeps(self, CrossReference, optionText, keyVal):
    if CrossReference._inputTemplateDeps:
        if (keyVal == "Input_Template") and (
                optionText in CrossReference._inputTemplateDeps.keys()):
            for entry in CrossReference._inputTemplateDeps[optionText]:
                foundGlobal = CrossReference.getGlobalByFileNo(entry[3])
                if foundGlobal:
                    self._curRoutine.addGlobalVariables(
                        GlobalVariable(foundGlobal.getName(), "", "RJ"))
    if CrossReference._sortTemplateDeps:
        if (keyVal == "Sort_Template") and (
                optionText in CrossReference._sortTemplateDeps.keys()):
            for entry in CrossReference._sortTemplateDeps[optionText]:
                foundGlobal = CrossReference.getGlobalByFileNo(entry[3])
                if foundGlobal:
                    self._curRoutine.addGlobalVariables(
                        GlobalVariable(foundGlobal.getName(), "", "RJ"))
    if CrossReference._printTemplateDeps:
        if (keyVal == "Print_Template") and (
                optionText in CrossReference._printTemplateDeps.keys()):
            for entry in CrossReference._printTemplateDeps[optionText]:
                foundGlobal = CrossReference.getGlobalByFileNo(entry[3])
                if foundGlobal:
                    self._curRoutine.addGlobalVariables(
                        GlobalVariable(foundGlobal.getName(), "", "RJ"))
Example #2
0
 def parseLine(self, line, Global, CrossReference):
     assert self._global
     strippedLine = line.rstrip(" ")
     if len(strippedLine) == 0:
         return
     value = strippedLine[self.POINTED_TO_BY_VALUE_INDEX:]
     logger.debug("Parsing line [%s]" % value)
     result = self.POINTED_TO_BY_VALUE.search(value)
     if result:
         fileManNo = result.group("FileNo")
         fieldNo = result.group('fieldNo')
         subFileNo = result.group('subFieldNo')
         logger.debug("File # %s, field # %s, sub-field # %s" %
                      (fileManNo, fieldNo, subFileNo))
         pointedByGlobal = CrossReference.getGlobalByFileNo(fileManNo)
         if pointedByGlobal:
             self._global.addPointedToByFile(pointedByGlobal, fieldNo,
                                             subFileNo)
             logger.debug("added global to pointed list: %s, %s, %s" %
                          (fileManNo, fieldNo, subFileNo))
         else:
             logger.warning("Could not find global based on %s, %s" %
                            (fileManNo, result.group("Name")))
     else:
         logger.error(
             "Could not parse pointer reference [%s] in file [%s]" %
             (line, self._global.getFileNo()))
Example #3
0
 def __parsingVariablePointer__(self, Global, CrossReference):
     index, fileList, found = 0, None, False
     indentValue = self.__getDefaultIndentLevel__(self._curFile,
                                                  self.DEFAULT_NAME_INDENT)
     for index in range(len(self._lines)):
         if not found:
             if re.search(
                     "^ {%d,%d}FILE  ORDER  PREFIX    LAYGO  MESSAGE$" %
                 (self.DEFAULT_NAME_INDENT, indentValue),
                     self._lines[index]):
                 found = True
             continue
         else:
             if re.search("^ {%d,}$" % indentValue, self._lines[index]):
                 break
             else:
                 result = re.search("^ +(?P<File>[0-9\.]+) +",
                                    self._lines[index])
                 if result:
                     filePointedTo = CrossReference.getGlobalByFileNo(
                         result.group('File'))
                     if not filePointedTo:
                         # log an error for now, will handle this case later
                         logger.error(
                             "INVALID File! File is %s, Global is %s" %
                             (result.group('File'), Global))
                         continue
                     if not fileList: fileList = []
                     fileList.append(filePointedTo)
     self._field.setPointedToFiles(fileList)
Example #4
0
 def __createFieldByType__(self, fieldNo, fType, fName, fLocation, line,
                           Global, CrossReference):
     logger.debug("Current Type is [%s]" % fType)
     result = self.UNDEFINED_POINTER.search(fType)
     if result:
         self._field = FileManFieldFactory.createField(
             fieldNo, fName, FileManField.FIELD_TYPE_FILE_POINTER,
             fLocation)
         return
     result = self.POINTER_TO_REGEX.search(fType)
     if result:
         fileNo = result.group('File')
         filePointedTo = CrossReference.getGlobalByFileNo(fileNo)
         self._field = FileManFieldFactory.createField(
             fieldNo, fName, FileManField.FIELD_TYPE_FILE_POINTER,
             fLocation)
         if not filePointedTo:
             logger.error(
                 "Could not find file pointed to [%s], [%s], line:[%s]" %
                 (fileNo, self._curFile, line))
         else:
             self._field.setPointedToFile(filePointedTo)
         return
     # deal with file pointer to subFiles
     result = self.SUBFILE_REGEX.search(fType)
     if result:
         # create a field for sub file type
         self._field = FileManFieldFactory.createField(
             fieldNo, fName, FileManField.FIELD_TYPE_SUBFILE_POINTER,
             fLocation)
         fileNo = result.group('File')
         logger.debug("Pointer to subFile %s" % fileNo)
         subFile = Global.getSubFileByFileNo(fileNo)
         if not subFile:
             subFile = FileManFile(fileNo, fName, self._curFile)
             self._curFile.addFileManSubFile(subFile)
             logger.debug("Added subFile %s to File %s" %
                          (fileNo, self._curFile.getFileNo()))
             if self._isSubFile:
                 Global.addFileManSubFile(subFile)
         self._field.setPointedToSubFile(subFile)
         return
     for (key, value) in self.StringTypeMappingDict.iteritems():
         if fType.startswith(key):
             self._field = FileManFieldFactory.createField(
                 fieldNo, fName, value, fLocation)
             break
     if not self._field:
         # double check the loc and type
         if line.find(fType) > self.MAXIMIUM_TYPE_START_INDEX:
             fType = line[self.MAXIMIUM_TYPE_START_INDEX:]
             if fLocation:
                 fLocation = line[line.find(fLocation):self.
                                  MAXIMIUM_TYPE_START_INDEX]
             logger.warn("new Type is [%s], loc is [%s]" %
                         (fType, fLocation))
             self.__createFieldByType__(fieldNo, fType, fName, fLocation,
                                        line, Global, CrossReference)
     assert self._field, "Could not find the right type for %s, %s, %s, %s, %s" % (
         fType, fLocation, fieldNo, line, self._curFile.getFileNo())
 def __createFieldByType__(self, fieldNo, fType, fName, fLocation, line, Global, CrossReference):
     logger.debug("Current Type is [%s]" % fType)
     result = self.UNDEFINED_POINTER.search(fType)
     if result:
         self._field = FileManFieldFactory.createField(fieldNo, fName,
                            FileManField.FIELD_TYPE_FILE_POINTER, fLocation)
         return
     result = self.POINTER_TO_REGEX.search(fType)
     if result:
         fileNo = result.group('File')
         filePointedTo = CrossReference.getGlobalByFileNo(fileNo)
         self._field = FileManFieldFactory.createField(fieldNo, fName,
                            FileManField.FIELD_TYPE_FILE_POINTER, fLocation)
         if not filePointedTo:
             logger.error("Could not find file pointed to [%s], [%s], line:[%s]" % (fileNo, self._curFile, line))
         else:
             self._field.setPointedToFile(filePointedTo)
         return
     # deal with file pointer to subFiles
     result = self.SUBFILE_REGEX.search(fType)
     if result:
         # create a field for sub file type
         self._field = FileManFieldFactory.createField(fieldNo, fName,
                             FileManField.FIELD_TYPE_SUBFILE_POINTER, fLocation)
         fileNo = result.group('File')
         logger.debug("Pointer to subFile %s" % fileNo)
         subFile = Global.getSubFileByFileNo(fileNo)
         if not subFile: # this is a new subfile
             subFile = FileManFile(fileNo, fName, self._curFile)
             self._curFile.addFileManSubFile(subFile)
             logger.debug("Added subFile %s to File %s" % (fileNo, self._curFile.getFileNo()))
             if self._isSubFile:
                 Global.addFileManSubFile(subFile)
         self._field.setPointedToSubFile(subFile)
         CrossReference.addFileManSubFile(subFile)
         return
     for (key, value) in self.StringTypeMappingDict.iteritems():
         if fType.startswith(key):
             self._field = FileManFieldFactory.createField(fieldNo, fName, value, fLocation)
             break
     if not self._field:
       # double check the loc and type
       if line.find(fType) > self.MAXIMIUM_TYPE_START_INDEX:
           fType = line[self.MAXIMIUM_TYPE_START_INDEX:]
           if fLocation:
               fLocation = line[line.find(fLocation):self.MAXIMIUM_TYPE_START_INDEX]
           logger.warn("new Type is [%s], loc is [%s]" % (fType, fLocation))
           self.__createFieldByType__(fieldNo, fType, fName, fLocation, line, Global, CrossReference)
     assert self._field, "Could not find the right type for %s, %s, %s, %s, %s" % (fType, fLocation, fieldNo, line, self._curFile.getFileNo())
 def parseLine(self, line, Global, CrossReference):
     assert self._global
     strippedLine = line.rstrip(" ")
     if not strippedLine:
         return
     value = strippedLine[self.POINTED_TO_BY_VALUE_INDEX:]
     result = POINTED_TO_BY_VALUE_REGEX.search(value)
     if result:
         fileManNo = result.group("FileNo")
         fieldNo = result.group('fieldNo')
         subFileNo = result.group('subFieldNo')
         pointedByGlobal = CrossReference.getGlobalByFileNo(fileManNo)
         if pointedByGlobal:
             self._global.addPointedToByFile(pointedByGlobal, fieldNo, subFileNo)
         else:
             logger.warning("Could not find global based on %s, %s" %
                            (fileManNo, result.group("Name")))
     else:
         logger.error("Could not parse pointer reference [%s] in file [%s]" % (line, self._global.getFileNo()))
 def parseLine(self, line, Global, CrossReference):
     assert self._global
     strippedLine = line.rstrip(" ")
     if len(strippedLine) == 0:
         return
     value = strippedLine[self.POINTED_TO_BY_VALUE_INDEX:]
     logger.debug("Parsing line [%s]" % value)
     result = self.POINTED_TO_BY_VALUE.search(value)
     if result:
         fileManNo = result.group("FileNo")
         fieldNo = result.group('fieldNo')
         subFileNo = result.group('subFieldNo')
         logger.debug("File # %s, field # %s, sub-field # %s" % (fileManNo, fieldNo, subFileNo))
         pointedByGlobal = CrossReference.getGlobalByFileNo(fileManNo)
         if pointedByGlobal:
             self._global.addPointedToByFile(pointedByGlobal, fieldNo, subFileNo)
             logger.debug("added global to pointed list: %s, %s, %s" %
                         (fileManNo, fieldNo, subFileNo))
         else:
             logger.warning("Could not find global based on %s, %s" %
                            (fileManNo, result.group("Name")))
     else:
         logger.error("Could not parse pointer reference [%s] in file [%s]" % (line, self._global.getFileNo()))
Example #8
0
 def __parsingVariablePointer__(self, Global, CrossReference):
     index, fileList, found = 0, None, False
     indentValue = self.__getDefaultIndentLevel__(self._curFile,
                                                  self.DEFAULT_NAME_INDENT)
     for index in range(len(self._lines)):
         if not found:
             if re.search("^ {%d,%d}FILE  ORDER  PREFIX    LAYGO  MESSAGE$" % (self.DEFAULT_NAME_INDENT, indentValue),
                          self._lines[index]):
                 found = True
             continue
         else:
             if re.search("^ {%d,}$" % indentValue, self._lines[index]):
                 break
             else:
                 result = FILE_REGEX.search(self._lines[index])
                 if result:
                     filePointedTo = CrossReference.getGlobalByFileNo(result.group('File'))
                     if not filePointedTo:
                         # log an error for now, will handle this case later
                         logger.error("INVALID File! File is %s, Global is %s" % (result.group('File'), Global))
                         continue
                     if not fileList: fileList = []
                     fileList.append(filePointedTo)
     self._field.setPointedToFiles(fileList)