2 <!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
3 <html><head><title>Python: module xattr</title>
4 </head><body bgcolor="#f0f0f8">
6 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
8 <td valign=bottom> <br>
9 <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>xattr</strong></big></big></font></td
10 ><td align=right valign=bottom
11 ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/iusty/work/pyxattr/build/lib.linux-i686-2.3/xattr.so">/home/iusty/work/pyxattr/build/lib.linux-i686-2.3/xattr.so</a></font></td></tr></table>
12 <p><tt>Access extended filesystem attributes<br>
14 This module gives access to the extended attributes present<br>
15 in some operating systems/filesystems. You can list attributes,<br>
16 get, set and remove them.<br>
17 The last and optional parameter for all functions is a boolean <br>
18 value which enables the 'l-' version of the functions - acting<br>
19 on symbolic links and not their destination.<br>
22 >>> import xattr<br>
23 >>> xattr.<a href="#-listxattr">listxattr</a>("file.txt")<br>
24 ('user.mime_type',)<br>
25 >>> xattr.<a href="#-getxattr">getxattr</a>("file.txt", "user.mime_type")<br>
27 >>> xattr.<a href="#-setxattr">setxattr</a>("file.txt", "user.comment", "Simple text file")<br>
28 >>> xattr.<a href="#-listxattr">listxattr</a>("file.txt")<br>
29 ('user.mime_type', 'user.comment')<br>
30 >>> xattr.removexattr ("file.txt", "user.comment")</tt></p>
32 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
33 <tr bgcolor="#eeaa77">
34 <td colspan=3 valign=bottom> <br>
35 <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
37 <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
38 <td width="100%"><dl><dt><a name="-getxattr"><strong>getxattr</strong></a>(...)</dt><dd><tt>Get the value of a given extended attribute.<br>
41 - a string representing filename, or a file-like object,<br>
42 or a file descriptor; this represents the file on <br>
43 which to act<br>
44 - a string, representing the attribute whose value to retrieve;<br>
45 usually in form of system.posix_acl or user.mime_type<br>
46 - (optional) a boolean value (defaults to false), which, if<br>
47 the file name given is a symbolic link, makes the<br>
48 function operate on the symbolic link itself instead<br>
49 of its target;</tt></dd></dl>
50 <dl><dt><a name="-listxattr"><strong>listxattr</strong></a>(...)</dt><dd><tt>Return the tuple of attribute names from a file<br>
53 - a string representing filename, or a file-like object,<br>
54 or a file descriptor; this represents the file to <br>
55 be queried<br>
56 - (optional) a boolean value (defaults to false), which, if<br>
57 the file name given is a symbolic link, makes the<br>
58 function operate on the symbolic link itself instead<br>
59 of its target;</tt></dd></dl>
60 <dl><dt><a name="-removexattr"><strong>removexattr</strong></a>(...)</dt><dd><tt>Remove an attribute from a file<br>
63 - a string representing filename, or a file-like object,<br>
64 or a file descriptor; this represents the file on <br>
65 which to act<br>
66 - a string, representing the attribute to be removed;<br>
67 usually in form of system.posix_acl or user.mime_type<br>
68 - (optional) a boolean value (defaults to false), which, if<br>
69 the file name given is a symbolic link, makes the<br>
70 function operate on the symbolic link itself instead<br>
71 of its target;</tt></dd></dl>
72 <dl><dt><a name="-setxattr"><strong>setxattr</strong></a>(...)</dt><dd><tt>Set the value of a given extended attribute.<br>
73 Be carefull in case you want to set attributes on symbolic<br>
74 links, you have to use all the 5 parameters; use 0 for the <br>
75 flags value if you want the default behavior (create or replace)<br>
78 - a string representing filename, or a file-like object,<br>
79 or a file descriptor; this represents the file on <br>
80 which to act<br>
81 - a string, representing the attribute whose value to set;<br>
82 usually in form of system.posix_acl or user.mime_type<br>
83 - a string, possibly with embedded NULLs; note that there<br>
84 are restrictions regarding the size of the value, for<br>
85 example, for ext2/ext3, maximum size is the block size<br>
86 - (optional) flags; if 0 or ommited the attribute will be <br>
87 created or replaced; if XATTR_CREATE, the attribute <br>
88 will be created, giving an error if it already exists;<br>
89 of XATTR_REPLACE, the attribute will be replaced,<br>
90 giving an error if it doesn't exists;<br>
91 - (optional) a boolean value (defaults to false), which, if<br>
92 the file name given is a symbolic link, makes the<br>
93 function operate on the symbolic link itself instead<br>
94 of its target;</tt></dd></dl>
96 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
97 <tr bgcolor="#55aa55">
98 <td colspan=3 valign=bottom> <br>
99 <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
101 <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
102 <td width="100%"><strong>XATTR_CREATE</strong> = 1<br>
103 <strong>XATTR_REPLACE</strong> = 2</td></tr></table>