Example #1
0
 def ParseMultiple(self, unused_stats, file_objs, unused_knowledge_base):
   # TODO(user): review quoting and line continuation.
   result = rdf_config_file.LogConfig()
   for file_obj in file_objs:
     for entry in self.ParseEntries(file_obj.read()):
       directive = entry[0]
       log_rule = self.log_rule_re.match(directive)
       if log_rule and entry[1:]:
         target = self._ParseAction(entry[1])
         target.facility, target.priority = log_rule.groups()
         result.targets.append(target)
   return [result]
Example #2
0
    def ParseFiles(self, knowledge_base, pathspecs, filedescs):
        del knowledge_base  # Unused.
        del pathspecs  # Unused.

        # TODO(user): review quoting and line continuation.
        result = rdf_config_file.LogConfig()
        for file_obj in filedescs:
            for entry in self._field_parser.ParseEntries(
                    utils.ReadFileBytesAsUnicode(file_obj)):
                directive = entry[0]
                log_rule = self._field_parser.log_rule_re.match(directive)
                if log_rule and entry[1:]:
                    target = self._field_parser.ParseAction(entry[1])
                    target.facility, target.priority = log_rule.groups()
                    result.targets.append(target)
        return [result]
Example #3
0
    def ParseFiles(
        self,
        knowledge_base: rdf_client.KnowledgeBase,
        pathspecs: Iterable[rdf_paths.PathSpec],
        filedescs: Iterable[IO[bytes]],
    ) -> Iterator[rdf_protodict.AttributedDict]:
        del knowledge_base  # Unused.
        del pathspecs  # Unused.

        # TODO(user): review quoting and line continuation.
        result = rdf_config_file.LogConfig()
        for file_obj in filedescs:
            for entry in self._field_parser.ParseEntries(
                    utils.ReadFileBytesAsUnicode(file_obj)):
                directive = entry[0]
                log_rule = self._field_parser.log_rule_re.match(directive)
                if log_rule and entry[1:]:
                    target = self._field_parser.ParseAction(entry[1])
                    target.facility, target.priority = log_rule.groups()
                    result.targets.append(target)
        yield result