Esempio n. 1
0
    def text_store(self, lens, node, path):
        """Use the value of node 'node' as a string and transform it into a tree
        using the lens 'lens' and store it in the tree at 'path', which will be
        overwritten. 'path' and 'node' are path expressions."""

        # Sanity checks
        if not isinstance(lens, string_types):
            raise TypeError("lens MUST be a string!")
        if not isinstance(node, string_types):
            raise TypeError("node MUST be a string!")
        if not isinstance(path, string_types):
            raise TypeError("path MUST be a string!")
        if not self.__handle:
            raise RuntimeError("The Augeas object has already been closed!")

        # Call the function
        ret = lib.aug_text_store(self.__handle, enc(lens), enc(node),
                                 enc(path))
        if ret != 0:
            raise ValueError("Unable to store text at node!")
        return ret
Esempio n. 2
0
    def text_store(self, lens, node, path):
        """
        Use the value of node `node` as a string and transform it into a tree
        using the lens `lens` and store it in the tree at `path`, which will be
        overwritten. `path` and `node` are path expressions.
        """

        # Sanity checks
        if not isinstance(lens, string_types):
            raise TypeError("lens MUST be a string!")
        if not isinstance(node, string_types):
            raise TypeError("node MUST be a string!")
        if not isinstance(path, string_types):
            raise TypeError("path MUST be a string!")
        if not self.__handle:
            raise RuntimeError("The Augeas object has already been closed!")

        # Call the function
        ret = lib.aug_text_store(
            self.__handle, enc(lens), enc(node), enc(path))
        if ret != 0:
            self._raise_error(AugeasValueError, "Augeas.text_store() failed")
        return ret