Пример #1
0
    def get(self, path):
        """Lookup the value associated with 'path'.
        Returns the value at the path specified.
        It is an error if more than one node matches 'path'."""

        # Sanity checks
        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!")

        # Create the char * value
        value = ffi.new("char*[]", 1)

        # Call the function and pass value by reference (char **)
        ret = lib.aug_get(self.__handle, enc(path), value)
        if ret > 1:
            raise ValueError("path specified had too many matches!")

        return dec(ffi.string(value[0])) if value[0] != ffi.NULL else None
Пример #2
0
    def get(self, path):
        """
        Lookup the value associated with `path`.
        It is an error if more than one node matches `path`.

        :returns: the value at the path specified
        :rtype: str
        """

        # Sanity checks
        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!")

        # Create the char * value
        value = ffi.new("char*[]", 1)

        # Call the function and pass value by reference (char **)
        ret = lib.aug_get(self.__handle, enc(path), value)
        if ret < 0:
            self._raise_error(AugeasValueError, "Augeas.get() failed")

        return self._optffistring(value[0])