Home | Trees | Indices | Help |
|
---|
|
Interface to extended filesystem attributes.
This module gives access to the extended attributes present in some operating systems/filesystems. You can list attributes, get, set and remove them.
The module exposes two sets of functions:
Example:
>>> 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")
Note:
Most or all errors reported by the system while using the xattr
library will be reported by raising a EnvironmentError
; under Linux, the following
errno
values are used:
ENOATTR
and ENODATA
mean that the
attribute name is invalid
ENOTSUP
and EOPNOTSUPP
mean that the
filesystem does not support extended attributes, or that the
namespace is invalid
E2BIG
mean that the attribute value is too big
ERANGE
mean that the attribute name is too big (it
might also mean an error in the xattr module itself)
ENOSPC
and EDQUOT
are documented as
meaning out of disk space or out of disk space because of quota
limits
Version: 0.4.0
Author: Iustin Pop
Contact: iusty@k1024.org
License: GNU Lesser General Public License (LGPL)
|
|||
list |
|
||
string |
|
||
list |
|
||
None |
|
||
None |
|
||
Deprecated API | |||
---|---|---|---|
|
|||
|
|||
|
|||
|
|
|||
Namespace constants | |||
---|---|---|---|
NS_SECURITY =
|
|||
NS_SYSTEM =
|
|||
NS_TRUSTED =
|
|||
NS_USER =
|
|||
set function flags | |||
XATTR_CREATE = 1
|
|||
XATTR_REPLACE = 2
|
|
Return the list of attribute names for a file. Example: >>> xattr.list('/path/to/file') ['user.test', 'user.comment', 'system.posix_acl_access'] >>> xattr.list('/path/to/file', namespace=xattr.NS_USER) ['test', 'comment']
Since: 0.4 |
Get the value of a given extended attribute. Example: >>> xattr.get('/path/to/file', 'user.comment') 'test' >>> xattr.get('/path/to/file', 'comment', namespace=xattr.NS_USER) 'test'
Since: 0.4 |
Get all the extended attributes of an item. This function performs a bulk-get of all extended attribute names and the corresponding value. Example: >>> xattr.get_all('/path/to/file') [('user.mime-type', 'plain/text'), ('user.comment', 'test'), ('system.posix_acl_access', '\x02\x00...')] >>> xattr.get_all('/path/to/file', namespace=xattr.NS_USER) [('mime-type', 'plain/text'), ('comment', 'test')]
Note: Since reading the whole attribute list is not an atomic operation, it might be possible that attributes are added or removed between the initial query and the actual reading of the attributes; the returned list will contain only the attributes that were present at the initial listing of the attribute names and that were still present when the read attempt for the value is made. Since: 0.4 |
Set the value of a given extended attribute. Example: >>> xattr.set('/path/to/file', 'user.comment', 'test') >>> xattr.set('/path/to/file', 'comment', 'test', namespace=xattr.NS_USER)
Since: 0.4 |
Remove an attribute from a file. Example: >>> xattr.remove('/path/to/file', 'user.comment')
Since: 0.4 |
Return the list of attribute names for a file (deprecated). Parameters:
Deprecated: since version 0.4, this function has been deprecated by the list function |
Get the value of a given extended attribute (deprecated). Parameters:
Deprecated: since version 0.4, this function has been deprecated by the get function |
Set the value of a given extended attribute (deprecated). Be carefull in case you want to set attributes on symbolic links, you have to use all the 5 parameters; use 0 for the flags value if you want the default behavior (create or replace) Parameters:
Deprecated: since version 0.4, this function has been deprecated by the set function |
Remove an attribute from a file (deprecated). Parameters:
Deprecated: since version 0.4, this function has been deprecated by the remove function |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Feb 23 20:30:49 2009 | http://epydoc.sourceforge.net |