Example #1
0
 def split_entries(split_lines, rid, mls, lineno_offset):
     '''This method splits up the given string in seperate entries which
     represent a entry record each.
     The lineno offset is the line number of the first line given in
     the sl array.
     '''
     doc = []
     lineno = lineno_offset
     success = True
     while split_lines:
         try:
             next_record \
                 = TxtParser.split_next_record(
                     split_lines, rid, lineno, mls)
             doc.append(next_record)
             lineno += len(next_record[1]) + len(next_record[2])
         except RMTException as rmte:
             # This is a hint that the tag line could not correctly
             # parsed.
             logger.error(LogFormatter.rmte(rmte))
             # Remove the errornous line
             del split_lines[0]
             lineno += 1
             success = False
     return success, doc
Example #2
0
 def split_entries(split_lines, rid, mls, lineno_offset):
     '''This method splits up the given string in seperate entries which
     represent a entry record each.
     The lineno offset is the line number of the first line given in
     the sl array.
     '''
     doc = []
     lineno = lineno_offset
     success = True
     while split_lines:
         try:
             next_record \
                 = TxtParser.split_next_record(
                     split_lines, rid, lineno, mls)
             doc.append(next_record)
             lineno += len(next_record[1]) + len(next_record[2])
         except RMTException as rmte:
             # This is a hint that the tag line could not correctly
             # parsed.
             logger.error(LogFormatter.rmte(rmte))
             # Remove the errornous line
             del split_lines[0]
             lineno += 1
             success = False
     return success, doc
Example #3
0
    def handle_modules_tag(self, reqs):
        if self.mods == None:
            return

        for modkey, module in self.mods.get_tagtype(self.tbhtags).items():
            try:
                tracer.debug("handle modules tag modkey [%s] tagtype [%s]" % (modkey, self.tbhtags))
                if self.tbhtags not in module.get_type_set():
                    logger.error(
                        LogFormatter.format(
                            90, "Wrong module type [%s] not in [%s]" % (self.tbhtags, module.get_type_set())
                        )
                    )
                    continue
                key, value = module.rewrite(self.id, reqs)
                # Check if there is already a key with the current key
                # in the map.
                if key in self.values:
                    logger.error(LogFormatter.format(54, "tag [%s] already defined" % (key), self.id))
                    self._set_not_usable()
                    # Also continue to get possible further error
                    # messages.
                self.values[key] = value
            except RMTException, rmte:
                # Some semantic error occurred: do not interpret key or
                # value.
                logger.error(LogFormatter.rmte(rmte))
                logger.error(LogFormatter.format(41, "semantic error occurred in " "module [%s]" % modkey, self.id))
                self._set_not_usable()
Example #4
0
    def handle_modules_tag(self, reqs):
        if self.mods == None:
            return

        for modkey, module in self.mods.get_tagtype(self.tbhtags).items():
            try:
                tracer.debug("handle modules tag modkey [%s] tagtype [%s]"
                      % (modkey, self.tbhtags))
                if self.tbhtags not in module.get_type_set():
                    logger.error(LogFormatter.format(
                                 90, "Wrong module type [%s] not in [%s]" %
                                 (self.tbhtags, module.get_type_set())))
                    continue
                key, value = module.rewrite(self.id, reqs)
                # Check if there is already a key with the current key
                # in the map.
                if key in self.values:
                    logger.error(LogFormatter.format(
                          54, "tag [%s] already defined" %
                          (key), self.id))
                    self._set_not_usable()
                    # Also continue to get possible further error
                    # messages.
                self.values[key] = value
            except RMTException, rmte:
                # Some semantic error occurred: do not interpret key or
                # value.
                logger.error(LogFormatter.rmte(rmte))
                logger.error(LogFormatter.format(
                               41, "semantic error occurred in "
                               "module [%s]" % modkey, self.id))
                self._set_not_usable()