INNER CODE UNIT · Python
_ensure_xattr_support
jd/pifpaf · pifpaf/drivers/__init__.py:72
def _ensure_xattr_support(self):
testfile = os.path.join(self.tempdir, "test")
self._touch(testfile)
xattr_supported = False
if xattr is not None:
try:
# PyPI: xattr
if hasattr(xattr, 'xattr'):
x = xattr.xattr(testfile)
x[b"user.test"] = b"test"
# PyPI: pyxattr
else:
xattr.setxattr(testfile, 'user.test', 'test')
except (OSError, IOError) as e:
if e.errno != 95:
raise
else:
xattr_supported = True