Example #1
0
 def __init__(self, **kwargs):
     ancestor, dirty, filepath, metadata = util.parsernode_kwargs(kwargs)  # pylint: disable=unused-variable
     super(ApacheParserNode, self).__init__(**kwargs)
     self.ancestor = ancestor
     self.filepath = filepath
     self.dirty = dirty
     self.metadata = metadata
     self._raw = self.metadata["ac_ast"]
    def test_parsernode_from_metadata(self):
        params = self._setup_parsernode()
        params.pop("filepath")
        md = {"some": "value"}
        params["metadata"] = md

        # Just testing that error from missing required parameters is not raised
        _, _, _, metadata = util.parsernode_kwargs(params)
        self.assertEqual(metadata, md)
    def test_parsernode(self):
        params = self._setup_parsernode()
        ctrl = self._setup_parsernode()

        ancestor, dirty, filepath, metadata = util.parsernode_kwargs(params)
        self.assertEqual(ancestor, ctrl["ancestor"])
        self.assertEqual(dirty, ctrl["dirty"])
        self.assertEqual(filepath, ctrl["filepath"])
        self.assertEqual(metadata, {})
Example #4
0
 def __init__(self, **kwargs: Any) -> None:
     # pylint: disable=unused-variable
     ancestor, dirty, filepath, metadata = util.parsernode_kwargs(kwargs)
     super().__init__(**kwargs)
     self.ancestor = ancestor
     self.filepath = filepath
     self.dirty = dirty
     self.metadata = metadata
     self._raw: Any = self.metadata["ac_ast"]
Example #5
0
 def __init__(self, **kwargs):
     """
     Initializes the ParserNode instance.
     """
     ancestor, dirty, filepath, metadata = util.parsernode_kwargs(kwargs)
     self.ancestor = ancestor
     self.dirty = dirty
     self.filepath = filepath
     self.metadata = metadata
     super().__init__(**kwargs)
Example #6
0
 def __init__(self, **kwargs):
     ancestor, dirty, filepath, metadata = util.parsernode_kwargs(kwargs)  # pylint: disable=unused-variable
     super(AugeasParserNode, self).__init__(**kwargs)
     self.ancestor = ancestor
     self.filepath = filepath
     self.dirty = dirty
     self.metadata = metadata
     self.parser = self.metadata.get("augeasparser")
     try:
         if self.metadata["augeaspath"].endswith("/"):
             raise errors.PluginError(
                 "Augeas path: {} has a trailing slash".format(
                     self.metadata["augeaspath"]))
     except KeyError:
         raise errors.PluginError("Augeas path is required")
Example #7
0
 def __init__(self, **kwargs: Any):
     # pylint: disable=unused-variable
     ancestor, dirty, filepath, metadata = util.parsernode_kwargs(kwargs)
     super().__init__(**kwargs)
     self.ancestor: str = ancestor
     self.filepath: str = filepath
     self.dirty: bool = dirty
     self.metadata: Dict[str, Any] = metadata
     self.parser: parser.ApacheParser = cast(
         parser.ApacheParser, self.metadata.get("augeasparser"))
     try:
         if self.metadata["augeaspath"].endswith("/"):
             raise errors.PluginError(
                 "Augeas path: {} has a trailing slash".format(
                     self.metadata["augeaspath"]))
     except KeyError:
         raise errors.PluginError("Augeas path is required")