def __init__(self, root=None, loadpath=None, flags=NONE): """Initialize the library. Use 'root' as the filesystem root. If 'root' is None, use the value of the environment variable AUGEAS_ROOT. If that doesn't exist either, use "/". 'loadpath' is a colon-spearated list of directories that modules should be searched in. This is in addition to the standard load path and the directories in AUGEAS_LENS_LIB. 'flags' is a bitmask made up of values from AUG_FLAGS.""" # Sanity checks if not isinstance(root, string_types) and root != None: raise TypeError("root MUST be a string or None!") if not isinstance(loadpath, string_types) and loadpath != None: raise TypeError("loadpath MUST be a string or None!") if not isinstance(flags, int): raise TypeError("flag MUST be a flag!") root = enc(root) if root else ffi.NULL loadpath = enc(loadpath) if loadpath else ffi.NULL # Create the Augeas object self.__handle = ffi.gc(lib.aug_init(root, loadpath, flags), lambda x: self.close) if not self.__handle: raise RuntimeError("Unable to create Augeas object!")
def __init__(self, root=None, loadpath=None, flags=NONE): """ Initialize the library. :param root: the filesystem root. If `root` is :py:obj:`None`, use the value of the environment variable :envvar:`AUGEAS_ROOT`. If that doesn't exist either, use :samp:`/`. :type root: str or None :param loadpath: a colon-separated list of directories that modules should be searched in. This is in addition to the standard load path and the directories in :envvar:`AUGEAS_LENS_LIB`. :type loadpath: str or None :param flags: a combination of values of :attr:`SAVE_BACKUP`, :attr:`SAVE_NEWFILE`, :attr:`TYPE_CHECK`, :attr:`NO_STDINC`, :attr:`SAVE_NOOP`, :attr:`NO_LOAD`, :attr:`NO_MODL_AUTOLOAD`, and :attr:`ENABLE_SPAN`. :type flags: int or :attr:`NONE` """ # Sanity checks if not isinstance(root, string_types) and root is not None: raise TypeError("root MUST be a string or None!") if not isinstance(loadpath, string_types) and loadpath is not None: raise TypeError("loadpath MUST be a string or None!") if not isinstance(flags, int): raise TypeError("flag MUST be a flag!") root = enc(root) if root else ffi.NULL loadpath = enc(loadpath) if loadpath else ffi.NULL # Create the Augeas object self.__handle = ffi.gc(lib.aug_init(root, loadpath, flags), lambda x: self.close) if not self.__handle: raise RuntimeError("Unable to create Augeas object!")