portage.util._xattr module

Portability shim for xattr support

Exported API is the xattr object with get/get_all/set/remove/list operations. We do not include the functions that Python 3.3+ provides in the os module as the signature there is different compared to xattr.

See the standard xattr module for more documentation:

https://pypi.python.org/pypi/pyxattr

class portage.util._xattr._XattrGetAll

Bases: object

Implement get_all() using list()/get() if there is no easy bulk method

classmethod get_all(item, nofollow=False, namespace=None)
class portage.util._xattr._XattrStub

Bases: portage.util._xattr._XattrGetAll

Fake object since system doesn’t support xattrs

static _raise()
classmethod get(item, name, nofollow=False, namespace=None)
classmethod get_all(item, nofollow=False, namespace=None)
classmethod list(item, nofollow=False, namespace=None)
classmethod remove(item, name, nofollow=False, namespace=None)
classmethod set(item, name, value, flags=0, namespace=None)
class portage.util._xattr._XattrSystemCommands

Bases: portage.util._xattr._XattrGetAll

Implement things with getfattr/setfattr

static _call(*args, **kwargs)
static _parse_output(output)
classmethod get(item, name, nofollow=False, namespace=None)
classmethod get_all(item, nofollow=False, namespace=None)
classmethod list(item, nofollow=False, namespace=None, _names_only=True)
classmethod remove(item, name, nofollow=False, namespace=None)
classmethod set(item, name, value, _flags=0, namespace=None)
portage.util._xattr.preserve_xattrs(path, nofollow=False, namespace=None)

Context manager to save/restore extended attributes on |path|

If you want to rewrite a file (possibly replacing it with a new one), but want to preserve the extended attributes, this will do the trick.

# First read all the extended attributes. with save_xattrs(‘/some/file’):

… rewrite the file …

# Now the extended attributes are restored as needed.

class portage.util._xattr.xattr

Bases: portage.util._xattr._XattrGetAll

Python >=3.3 and GNU/Linux

static get(item, name, nofollow=False, namespace=None)
classmethod get_all(item, nofollow=False, namespace=None)
static list(item, nofollow=False, namespace=None)
static remove(item, name, nofollow=False, namespace=None)
static set(item, name, value, flags=0, namespace=None)