This is the pyxattr module, a Python extension module which gives access to the extended attributes for filesystem objects available in some operating systems.
Downloads: go to https://pyxattr.k1024.org/downloads/. The source repository is either at https://git.k1024.org/pyxattr.git or at https://github.com/iustin/pyxattr.
See the CONTRIBUTING.md
file for details on how to contribute, or
support me on ko-fi.
The current supported Python versions are 3.7+ (tested up to 3.12), or PyPy versions 3.7+ (tested up to 3.10). The code should currently be compatible down to Python 3.4, but such versions are no longer tested.
The library has been written and tested on Linux, kernel v2.4 or later, with XFS and ext2/ext3/ext4 file systems, and MacOS recent versions. If any other platform implements the same behaviour, pyxattr could be used.
To build the module from source, you will need both a Python
development environment/libraries and the C compiler, plus the
setuptools tool installed, and for building the documentation you need
to have Sphinx installed. The exact list of dependencies depends on
the operating system/distribution, but should be something along the
lines of python3-devel
(RedHat), python3-all-dev
(Debian), etc.
Alternatively, you can install directly from pip after installing the above depedencies (C compiler, Python development libraries):
pip install pyxattr
Or you can install already compiled versions from your distribution, e.g. in Debian:
sudo apt install python3-pyxattr
For reporting security vulnerabilities, please see SECURITY.md
.
>>> import xattr
>>> xattr.listxattr("file.txt")
['user.mime_type']
>>> xattr.getxattr("file.txt", "user.mime_type")
'text/plain'
>>> xattr.setxattr("file.txt", "user.comment", "Simple text file")
>>> xattr.listxattr("file.txt")
['user.mime_type', 'user.comment']
>>> xattr.removexattr ("file.txt", "user.comment")
pyxattr is Copyright 2002-2008, 2012-2015 Iustin Pop.
pyxattr is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See the COPYING file for the full license terms.
Note that previous versions had different licenses: version 0.3 was licensed under LGPL version 3 (which, I realized later, is not compatible with GPLv2, hence the change to LGPL 2.1), and even older versions were licensed under GPL v2 or later.