From 68b9db50c64d37b6e915e6a3ab0e5ea2224159cb Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Mon, 30 Jun 2008 23:02:57 +0200 Subject: [PATCH] Imported Upstream version 0.3.0 --- COPYING.LGPL-3 | 165 ++++++++++++++++++++++ ChangeLog | 92 ------------ MANIFEST | 2 - MANIFEST.in | 6 + NEWS | 12 ++ PKG-INFO | 6 +- README | 14 +- pyxattr.egg-info/PKG-INFO | 12 ++ pyxattr.egg-info/SOURCES.txt | 13 ++ pyxattr.egg-info/dependency_links.txt | 1 + pyxattr.egg-info/top_level.txt | 1 + setup.cfg | 7 +- setup.py | 28 ++-- test/test_xattr.py | 140 +++++++++++++++++++ xattr.c | 193 +++++++++++++------------- xattr.html | 104 -------------- xattr.txt | 98 ------------- 17 files changed, 483 insertions(+), 411 deletions(-) create mode 100644 COPYING.LGPL-3 delete mode 100644 ChangeLog create mode 100644 MANIFEST.in create mode 100644 pyxattr.egg-info/PKG-INFO create mode 100644 pyxattr.egg-info/SOURCES.txt create mode 100644 pyxattr.egg-info/dependency_links.txt create mode 100644 pyxattr.egg-info/top_level.txt create mode 100644 test/test_xattr.py delete mode 100644 xattr.html delete mode 100644 xattr.txt diff --git a/COPYING.LGPL-3 b/COPYING.LGPL-3 new file mode 100644 index 0000000..fc8a5de --- /dev/null +++ b/COPYING.LGPL-3 @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index d6eb215..0000000 --- a/ChangeLog +++ /dev/null @@ -1,92 +0,0 @@ -2007-07-01 Iustin Pop - - Fix a bug when listing xattrs of symlinks (report and fix by cscott@cscott.net) - -2006-02-11 Iustin Pop - - * Fixed bug in dealing with symlinks (didn't work at all) - * Fixed possible memory leak if reading of EA failed but buffer - calculation didn't fail - * Added and fixed Makefile after switched to subversion - -2006-02-11 Iustin Pop - - * Added MANIFEST file in MANIFEST.in (old change from 2003) - -2003-07-07 Iustin Pop - - Increase version number - -2003-07-07 Iustin Pop - - Added support for manipulating attributes of symbolic links (by request of - an actual user!) - -2002-12-24 Iustin Pop - - Removed build_requires - -2002-12-24 Iustin Pop - - Don't call python2, only python - -2002-12-24 Iustin Pop - - Prepare for first public release - -2002-12-24 Iustin Pop - - Added README - -2002-12-24 Iustin Pop - - Build changes - -2002-12-24 Iustin Pop - - Added new files, some example in the docstrings - -2002-12-24 Iustin Pop - - Improved documentation and added some constants (XATTR_*) - -2002-12-24 Iustin Pop - - Added url and license to setup.py - -2002-12-22 Iustin Pop - - Fixed names again, and switched parsing of int and files to PyObject_AsFileDescriptor - -2002-12-21 Iustin Pop - - Typos - -2002-12-21 Iustin Pop - - Renaming files - -2002-12-21 Iustin Pop - - Initial revision - -2002-12-21 Iustin Pop - - Documentation/comments - -2002-12-21 Iustin Pop - - Added support for variable type parameters, in order to wrap - both forms like get... and fget... in the same call. - -2002-12-21 Iustin Pop - - Initial revision - -2002-12-21 Iustin Pop - - New repository initialized by cvs2svn. - -;; Local Variables: -;; coding: utf-8 -;; End: diff --git a/MANIFEST b/MANIFEST index 77381a0..5922d65 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,5 +1,3 @@ -ChangeLog -MANIFEST NEWS README setup.cfg diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..93e54f1 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include setup.cfg +include README +include xattr.c +include MANIFEST +include NEWS +include COPYING.LGPL-3 diff --git a/NEWS b/NEWS index a04869c..800d791 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,15 @@ +v0.3.0 +------ + + * change licence from GPL to LGPL (3 or later) + * change listxattr return type from tuple to a list + * developer-related: add unittests + +v0.2.2 +------ + + * fix listing symlink xattrs + News in 0.2.1 ------------- diff --git a/PKG-INFO b/PKG-INFO index c0f5565..25c5a63 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,11 +1,11 @@ Metadata-Version: 1.0 Name: pyxattr -Version: 0.2.2 -Summary: Extended attributes for python +Version: 0.3.0 +Summary: Filesystem extended attributes for python Home-page: http://pyxattr.sourceforge.net Author: Iustin Pop Author-email: iusty@k1024.org -License: GPL +License: LGPL Description: This is a C extension module for Python which implements extended attributes manipulation. It is a wrapper on top of the attr C library - see attr(5). diff --git a/README b/README index 33f49a4..73e68de 100644 --- a/README +++ b/README @@ -1,7 +1,15 @@ -This is the pyxattr module, a Python extension module which gives -access to the extended attributes available in some operating systems. +This is the pyxattr module, a Python extension module which gives access +to the extended attributes for filesystem objects available in some +operating systems. -For usage details, see xattr.txt or xattr.html. +For usage details, see the documentation of the module using pydoc. The project web page is http://pyxattr.sourceforge.net +You need to have setuptools installed in order to build and install the +module. + Author: Iustin Pop, + +Starting with version 0.3, pyxattr is licensed under the GNU LGPL, +version 3 or any later version (see COPYING.LPGL-3). Previous versions +were licensed under GPL v2 or later. diff --git a/pyxattr.egg-info/PKG-INFO b/pyxattr.egg-info/PKG-INFO new file mode 100644 index 0000000..25c5a63 --- /dev/null +++ b/pyxattr.egg-info/PKG-INFO @@ -0,0 +1,12 @@ +Metadata-Version: 1.0 +Name: pyxattr +Version: 0.3.0 +Summary: Filesystem extended attributes for python +Home-page: http://pyxattr.sourceforge.net +Author: Iustin Pop +Author-email: iusty@k1024.org +License: LGPL +Description: This is a C extension module for Python which + implements extended attributes manipulation. It is a wrapper on top + of the attr C library - see attr(5). +Platform: UNKNOWN diff --git a/pyxattr.egg-info/SOURCES.txt b/pyxattr.egg-info/SOURCES.txt new file mode 100644 index 0000000..0f89b98 --- /dev/null +++ b/pyxattr.egg-info/SOURCES.txt @@ -0,0 +1,13 @@ +COPYING.LGPL-3 +MANIFEST +MANIFEST.in +NEWS +README +setup.cfg +setup.py +xattr.c +pyxattr.egg-info/PKG-INFO +pyxattr.egg-info/SOURCES.txt +pyxattr.egg-info/dependency_links.txt +pyxattr.egg-info/top_level.txt +test/test_xattr.py \ No newline at end of file diff --git a/pyxattr.egg-info/dependency_links.txt b/pyxattr.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/pyxattr.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/pyxattr.egg-info/top_level.txt b/pyxattr.egg-info/top_level.txt new file mode 100644 index 0000000..18c5e90 --- /dev/null +++ b/pyxattr.egg-info/top_level.txt @@ -0,0 +1 @@ +xattr diff --git a/setup.cfg b/setup.cfg index 256aa5f..a68b051 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,9 @@ [bdist_rpm] release = 1 requires = libattr -;build_requires = libattr libattr-devel + +[egg_info] +tag_build = +tag_date = 0 +tag_svn_revision = 0 + diff --git a/setup.py b/setup.py index 9e468b4..ddb4381 100755 --- a/setup.py +++ b/setup.py @@ -1,20 +1,22 @@ -#!/usr/bin/env python +#!/usr/bin/python -import distutils -from distutils.core import setup, Extension +#import distutils +#from distutils.core import setup, Extension +from setuptools import setup, Extension long_desc = """This is a C extension module for Python which implements extended attributes manipulation. It is a wrapper on top of the attr C library - see attr(5).""" -version = "0.2.2" +version = "0.3.0" -setup(name="pyxattr", - version=version, - description="Extended attributes for python", - long_description=long_desc, - author="Iustin Pop", - author_email="iusty@k1024.org", - url="http://pyxattr.sourceforge.net", - license="GPL", - ext_modules=[Extension("xattr", ["xattr.c"], libraries=["attr"])], +setup(name = "pyxattr", + version = version, + description = "Filesystem extended attributes for python", + long_description = long_desc, + author = "Iustin Pop", + author_email = "iusty@k1024.org", + url = "http://pyxattr.sourceforge.net", + license = "LGPL", + ext_modules = [Extension("xattr", ["xattr.c"], libraries=["attr"])], + test_suite = "test/test_xattr", ) diff --git a/test/test_xattr.py b/test/test_xattr.py new file mode 100644 index 0000000..58930ac --- /dev/null +++ b/test/test_xattr.py @@ -0,0 +1,140 @@ +# +# + +import unittest +import tempfile +import os +import errno + +import xattr + +class xattrTest(unittest.TestCase): + USER_ATTR = "user.test" + USER_VAL = "abc" + + def setUp(self): + """set up function""" + self.rmfiles = [] + self.rmdirs = [] + + def tearDown(self): + """tear down function""" + for fname in self.rmfiles: + os.unlink(fname) + for dname in self.rmdirs: + os.rmdir(dname) + + def _getfile(self): + """create a temp file""" + fh, fname = tempfile.mkstemp(".test", "xattr-", ".") + self.rmfiles.append(fname) + return fh, fname + + def _getdir(self): + """create a temp dir""" + dname = tempfile.mkdtemp(".test", "xattr-", ".") + self.rmdirs.append(dname) + return dname + + def _getsymlink(self): + """create a symlink""" + fh, fname = self._getfile() + os.close(fh) + os.unlink(fname) + os.symlink(fname + ".non-existent", fname) + return fname + + def _checkListSetGet(self, item, symlink=False): + """check list, set, get operations against an item""" + self.failUnlessEqual(xattr.listxattr(item, symlink), []) + self.failUnlessRaises(EnvironmentError, xattr.setxattr, item, + self.USER_ATTR, self.USER_VAL, + xattr.XATTR_REPLACE) + try: + xattr.setxattr(item, self.USER_ATTR, self.USER_VAL, 0, symlink) + except IOError, err: + if err.errno == errno.EPERM and symlink: + # symlinks may fail, in which case we abort the rest + # of the test for this case + return + raise + self.failUnlessRaises(EnvironmentError, xattr.setxattr, item, + self.USER_ATTR, self.USER_VAL, + xattr.XATTR_CREATE) + self.failUnlessEqual(xattr.listxattr(item, symlink), [self.USER_ATTR]) + self.failUnlessEqual(xattr.getxattr(item, self.USER_ATTR, symlink), + self.USER_VAL) + xattr.removexattr(item, self.USER_ATTR) + self.failUnlessEqual(xattr.listxattr(item, symlink), []) + self.failUnlessRaises(EnvironmentError, xattr.removexattr, + item, self.USER_ATTR) + + def testNoXattr(self): + """test no attributes""" + fh, fname = self._getfile() + self.failUnlessEqual(xattr.listxattr(fname), []) + dname = self._getdir() + self.failUnlessEqual(xattr.listxattr(dname), []) + sname = self._getsymlink() + self.failUnlessEqual(xattr.listxattr(sname, True), []) + + def testFileByName(self): + """test set and retrieve one attribute by file name""" + fh, fname = self._getfile() + self._checkListSetGet(fname) + os.close(fh) + + def testFileByDescriptor(self): + """test file descriptor operations""" + fh, fname = self._getfile() + self._checkListSetGet(fh) + os.close(fh) + + def testFileByObject(self): + """test file descriptor operations""" + fh, fname = self._getfile() + fo = os.fdopen(fh) + self._checkListSetGet(fo) + fo.close() + + def testMixedAccess(self): + """test mixed access to file""" + fh, fname = self._getfile() + fo = os.fdopen(fh) + self.failUnlessEqual(xattr.listxattr(fname), []) + xattr.setxattr(fname, self.USER_ATTR, self.USER_VAL) + self.failUnlessEqual(xattr.listxattr(fh), [self.USER_ATTR]) + self.failUnlessEqual(xattr.getxattr(fo, self.USER_ATTR), + self.USER_VAL) + + def testDirOps(self): + """test attribute setting on directories""" + dname = self._getdir() + self._checkListSetGet(dname) + + def testSymlinkOps(self): + """test symlink operations""" + sname = self._getsymlink() + self.failUnlessRaises(EnvironmentError, xattr.listxattr, sname) + self._checkListSetGet(sname, symlink=True) + + def testBinaryPayload(self): + """test binary values""" + fh, fname = self._getfile() + os.close(fh) + BINVAL = "abc" + '\0' + "def" + xattr.setxattr(fname, self.USER_ATTR, BINVAL) + self.failUnlessEqual(xattr.listxattr(fname), [self.USER_ATTR]) + self.failUnlessEqual(xattr.getxattr(fname, self.USER_ATTR), BINVAL) + xattr.removexattr(fname, self.USER_ATTR) + + def testManyOps(self): + """test many ops""" + fh, fname = self._getfile() + xattr.setxattr(fh, self.USER_ATTR, self.USER_VAL) + VL = [self.USER_ATTR] + for i in range(131072): + self.failUnlessEqual(xattr.listxattr(fh), VL) + for i in range(131072): + self.failUnlessEqual(xattr.getxattr(fh, self.USER_ATTR), + self.USER_VAL) diff --git a/xattr.c b/xattr.c index 8fd55a5..25bc169 100644 --- a/xattr.c +++ b/xattr.c @@ -2,7 +2,8 @@ #include /** Converts from a string, file or int argument to what we need. */ -static int convertObj(PyObject *myobj, int *ishandle, int *filehandle, char **filename) { +static int convertObj(PyObject *myobj, int *ishandle, int *filehandle, + char **filename) { if(PyString_Check(myobj)) { *ishandle = 0; *filename = PyString_AS_STRING(myobj); @@ -16,20 +17,20 @@ static int convertObj(PyObject *myobj, int *ishandle, int *filehandle, char **fi } /* Wrapper for getxattr */ -static char __pygetxattr_doc__[] = \ -"Get the value of a given extended attribute.\n" \ -"\n" \ -"Parameters:\n" \ -"\t- a string representing filename, or a file-like object,\n" \ -"\t or a file descriptor; this represents the file on \n" \ -"\t which to act\n" \ -"\t- a string, representing the attribute whose value to retrieve;\n" \ -"\t usually in form of system.posix_acl or user.mime_type\n" \ -"\t- (optional) a boolean value (defaults to false), which, if\n" \ -"\t the file name given is a symbolic link, makes the\n" \ -"\t function operate on the symbolic link itself instead\n" \ -"\t of its target;" \ -; +static char __pygetxattr_doc__[] = + "Get the value of a given extended attribute.\n" + "\n" + "Parameters:\n" + "\t- a string representing filename, or a file-like object,\n" + "\t or a file descriptor; this represents the file on \n" + "\t which to act\n" + "\t- a string, representing the attribute whose value to retrieve;\n" + "\t usually in form of system.posix_acl or user.mime_type\n" + "\t- (optional) a boolean value (defaults to false), which, if\n" + "\t the file name given is a symbolic link, makes the\n" + "\t function operate on the symbolic link itself instead\n" + "\t of its target;" + ; static PyObject * pygetxattr(PyObject *self, PyObject *args) @@ -85,32 +86,32 @@ pygetxattr(PyObject *self, PyObject *args) return res; } -static char __pysetxattr_doc__[] = \ -"Set the value of a given extended attribute.\n" \ -"Be carefull in case you want to set attributes on symbolic\n" \ -"links, you have to use all the 5 parameters; use 0 for the \n" \ -"flags value if you want the default behavior (create or " \ -"replace)\n" \ -"\n" \ -"Parameters:\n" \ -"\t- a string representing filename, or a file-like object,\n" \ -"\t or a file descriptor; this represents the file on \n" \ -"\t which to act\n" \ -"\t- a string, representing the attribute whose value to set;\n" \ -"\t usually in form of system.posix_acl or user.mime_type\n" \ -"\t- a string, possibly with embedded NULLs; note that there\n" \ -"\t are restrictions regarding the size of the value, for\n" \ -"\t example, for ext2/ext3, maximum size is the block size\n" \ -"\t- (optional) flags; if 0 or ommited the attribute will be \n" \ -"\t created or replaced; if XATTR_CREATE, the attribute \n" \ -"\t will be created, giving an error if it already exists;\n" \ -"\t of XATTR_REPLACE, the attribute will be replaced,\n" \ -"\t giving an error if it doesn't exists;\n" \ -"\t- (optional) a boolean value (defaults to false), which, if\n" \ -"\t the file name given is a symbolic link, makes the\n" \ -"\t function operate on the symbolic link itself instead\n" \ -"\t of its target;" \ -; +static char __pysetxattr_doc__[] = + "Set the value of a given extended attribute.\n" + "Be carefull in case you want to set attributes on symbolic\n" + "links, you have to use all the 5 parameters; use 0 for the \n" + "flags value if you want the default behavior (create or " + "replace)\n" + "\n" + "Parameters:\n" + "\t- a string representing filename, or a file-like object,\n" + "\t or a file descriptor; this represents the file on \n" + "\t which to act\n" + "\t- a string, representing the attribute whose value to set;\n" + "\t usually in form of system.posix_acl or user.mime_type\n" + "\t- a string, possibly with embedded NULLs; note that there\n" + "\t are restrictions regarding the size of the value, for\n" + "\t example, for ext2/ext3, maximum size is the block size\n" + "\t- (optional) flags; if 0 or ommited the attribute will be \n" + "\t created or replaced; if XATTR_CREATE, the attribute \n" + "\t will be created, giving an error if it already exists;\n" + "\t of XATTR_REPLACE, the attribute will be replaced,\n" + "\t giving an error if it doesn't exists;\n" + "\t- (optional) a boolean value (defaults to false), which, if\n" + "\t the file name given is a symbolic link, makes the\n" + "\t function operate on the symbolic link itself instead\n" + "\t of its target;" + ; /* Wrapper for setxattr */ static PyObject * @@ -125,7 +126,8 @@ pysetxattr(PyObject *self, PyObject *args) int flags = 0; /* Parse the arguments */ - if (!PyArg_ParseTuple(args, "Oss#|bi", &myarg, &attrname, &buf, &bufsize, &flags, &dolink)) + if (!PyArg_ParseTuple(args, "Oss#|bi", &myarg, &attrname, + &buf, &bufsize, &flags, &dolink)) return NULL; if(!convertObj(myarg, &ishandle, &filedes, &file)) return NULL; @@ -146,20 +148,20 @@ pysetxattr(PyObject *self, PyObject *args) return Py_None; } -static char __pyremovexattr_doc__[] = \ -"Remove an attribute from a file\n" \ -"\n" \ -"Parameters:\n" \ -"\t- a string representing filename, or a file-like object,\n" \ -"\t or a file descriptor; this represents the file on \n" \ -"\t which to act\n" \ -"\t- a string, representing the attribute to be removed;\n" \ -"\t usually in form of system.posix_acl or user.mime_type\n" \ -"\t- (optional) a boolean value (defaults to false), which, if\n" \ -"\t the file name given is a symbolic link, makes the\n" \ -"\t function operate on the symbolic link itself instead\n" \ -"\t of its target;" \ -; +static char __pyremovexattr_doc__[] = + "Remove an attribute from a file\n" + "\n" + "Parameters:\n" + "\t- a string representing filename, or a file-like object,\n" + "\t or a file descriptor; this represents the file on \n" + "\t which to act\n" + "\t- a string, representing the attribute to be removed;\n" + "\t usually in form of system.posix_acl or user.mime_type\n" + "\t- (optional) a boolean value (defaults to false), which, if\n" + "\t the file name given is a symbolic link, makes the\n" + "\t function operate on the symbolic link itself instead\n" + "\t of its target;" + ; /* Wrapper for removexattr */ static PyObject * @@ -193,18 +195,18 @@ pyremovexattr(PyObject *self, PyObject *args) return Py_None; } -static char __pylistxattr_doc__[] = \ -"Return the tuple of attribute names from a file\n" \ -"\n" \ -"Parameters:\n" \ -"\t- a string representing filename, or a file-like object,\n" \ -"\t or a file descriptor; this represents the file to \n" \ -"\t be queried\n" \ -"\t- (optional) a boolean value (defaults to false), which, if\n" \ -"\t the file name given is a symbolic link, makes the\n" \ -"\t function operate on the symbolic link itself instead\n" \ -"\t of its target;" \ -; +static char __pylistxattr_doc__[] = + "Return the list of attribute names for a file\n" + "\n" + "Parameters:\n" + "\t- a string representing filename, or a file-like object,\n" + "\t or a file descriptor; this represents the file to \n" + "\t be queried\n" + "\t- (optional) a boolean value (defaults to false), which, if\n" + "\t the file name given is a symbolic link, makes the\n" + "\t function operate on the symbolic link itself instead\n" + "\t of its target;" + ; /* Wrapper for listxattr */ static PyObject * @@ -216,7 +218,7 @@ pylistxattr(PyObject *self, PyObject *args) int ishandle, dolink=0; int nalloc, nret; PyObject *myarg; - PyObject *mytuple; + PyObject *mylist; int nattrs; char *s; @@ -259,12 +261,12 @@ pylistxattr(PyObject *self, PyObject *args) nattrs++; } - /* Create the tuple which will hold the result */ - mytuple = PyTuple_New(nattrs); + /* Create the list which will hold the result */ + mylist = PyList_New(nattrs); - /* Create and insert the attributes as strings in the tuple */ + /* Create and insert the attributes as strings in the list */ for(s = buf, nattrs = 0; s - buf < nret; s += strlen(s) + 1) { - PyTuple_SET_ITEM(mytuple, nattrs, PyString_FromString(s)); + PyList_SET_ITEM(mylist, nattrs, PyString_FromString(s)); nattrs++; } @@ -272,7 +274,7 @@ pylistxattr(PyObject *self, PyObject *args) PyMem_Free(buf); /* Return the result */ - return mytuple; + return mylist; } static PyMethodDef xattr_methods[] = { @@ -284,27 +286,28 @@ static PyMethodDef xattr_methods[] = { }; static char __xattr_doc__[] = \ -"Access extended filesystem attributes\n" \ -"\n" \ -"This module gives access to the extended attributes present\n" \ -"in some operating systems/filesystems. You can list attributes,\n"\ -"get, set and remove them.\n"\ -"The last and optional parameter for all functions is a boolean \n"\ -"value which enables the 'l-' version of the functions - acting\n"\ -"on symbolic links and not their destination.\n"\ -"\n" \ -"Example: \n" \ -">>> import xattr\n" \ -">>> xattr.listxattr(\"file.txt\")\n" \ -"('user.mime_type',)\n" \ -">>> xattr.getxattr(\"file.txt\", \"user.mime_type\")\n" \ -"'text/plain'\n" \ -">>> xattr.setxattr(\"file.txt\", \"user.comment\", \"Simple text file\")\n"\ -">>> xattr.listxattr(\"file.txt\")\n" \ -"('user.mime_type', 'user.comment')\n" \ -">>> xattr.removexattr (\"file.txt\", \"user.comment\")\n" \ -"" \ -; + "Access extended filesystem attributes\n" + "\n" + "This module gives access to the extended attributes present\n" + "in some operating systems/filesystems. You can list attributes,\n" + "get, set and remove them.\n" + "The last and optional parameter for all functions is a boolean \n" + "value which enables the 'l-' version of the functions - acting\n" + "on symbolic links and not their destination.\n" + "\n" + "Example: \n" + ">>> import xattr\n" + ">>> xattr.listxattr(\"file.txt\")\n" + "('user.mime_type',)\n" + ">>> xattr.getxattr(\"file.txt\", \"user.mime_type\")\n" + "'text/plain'\n" + ">>> xattr.setxattr(\"file.txt\", \"user.comment\", \"Simple text file\")" + "\n" + ">>> xattr.listxattr(\"file.txt\")\n" + "('user.mime_type', 'user.comment')\n" + ">>> xattr.removexattr (\"file.txt\", \"user.comment\")\n" + "" + ; void initxattr(void) diff --git a/xattr.html b/xattr.html deleted file mode 100644 index 94d9606..0000000 --- a/xattr.html +++ /dev/null @@ -1,104 +0,0 @@ - - -Python: module xattr - - - - -
 
- 
xattr
index
/home/iusty/work/pyxattr/build/lib.linux-i686-2.3/xattr.so
-

Access 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 last and optional parameter for all functions is a boolean 
-value which enables the 'l-' version of the functions - acting
-on symbolic links and not their destination.

-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")

-

- - - - - -
 
-Functions
       
getxattr(...)
Get the value of a given extended attribute.

-Parameters:
-        - a string representing filename, or a file-like object,
-              or a file descriptor; this represents the file on 
-              which to act
-        - a string, representing the attribute whose value to retrieve;
-              usually in form of system.posix_acl or user.mime_type
-        - (optional) a boolean value (defaults to false), which, if
-              the file name given is a symbolic link, makes the
-              function operate on the symbolic link itself instead
-              of its target;
-
listxattr(...)
Return the tuple of attribute names from a file

-Parameters:
-        - a string representing filename, or a file-like object,
-              or a file descriptor; this represents the file to 
-              be queried
-        - (optional) a boolean value (defaults to false), which, if
-              the file name given is a symbolic link, makes the
-              function operate on the symbolic link itself instead
-              of its target;
-
removexattr(...)
Remove an attribute from a file

-Parameters:
-        - a string representing filename, or a file-like object,
-              or a file descriptor; this represents the file on 
-              which to act
-        - a string, representing the attribute to be removed;
-              usually in form of system.posix_acl or user.mime_type
-        - (optional) a boolean value (defaults to false), which, if
-              the file name given is a symbolic link, makes the
-              function operate on the symbolic link itself instead
-              of its target;
-
setxattr(...)
Set the value of a given extended attribute.
-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:
-        - a string representing filename, or a file-like object,
-              or a file descriptor; this represents the file on 
-              which to act
-        - a string, representing the attribute whose value to set;
-              usually in form of system.posix_acl or user.mime_type
-        - a string, possibly with embedded NULLs; note that there
-              are restrictions regarding the size of the value, for
-              example, for ext2/ext3, maximum size is the block size
-        - (optional) flags; if 0 or ommited the attribute will be 
-              created or replaced; if XATTR_CREATE, the attribute 
-              will be created, giving an error if it already exists;
-              of XATTR_REPLACE, the attribute will be replaced,
-              giving an error if it doesn't exists;
-        - (optional) a boolean value (defaults to false), which, if
-              the file name given is a symbolic link, makes the
-              function operate on the symbolic link itself instead
-              of its target;
-

- - - - - -
 
-Data
       XATTR_CREATE = 1
-XATTR_REPLACE = 2
- \ No newline at end of file diff --git a/xattr.txt b/xattr.txt deleted file mode 100644 index cd4f8ea..0000000 --- a/xattr.txt +++ /dev/null @@ -1,98 +0,0 @@ -Help on module xattr: - -NAME - xattr - Access extended filesystem attributes - -FILE - /home/iusty/work/pyxattr/build/lib.linux-i686-2.3/xattr.so - -DESCRIPTION - This module gives access to the extended attributes present - in some operating systems/filesystems. You can list attributes, - get, set and remove them. - The last and optional parameter for all functions is a boolean - value which enables the 'l-' version of the functions - acting - on symbolic links and not their destination. - - 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") - -FUNCTIONS - getxattr(...) - Get the value of a given extended attribute. - - Parameters: - - a string representing filename, or a file-like object, - or a file descriptor; this represents the file on - which to act - - a string, representing the attribute whose value to retrieve; - usually in form of system.posix_acl or user.mime_type - - (optional) a boolean value (defaults to false), which, if - the file name given is a symbolic link, makes the - function operate on the symbolic link itself instead - of its target; - - listxattr(...) - Return the tuple of attribute names from a file - - Parameters: - - a string representing filename, or a file-like object, - or a file descriptor; this represents the file to - be queried - - (optional) a boolean value (defaults to false), which, if - the file name given is a symbolic link, makes the - function operate on the symbolic link itself instead - of its target; - - removexattr(...) - Remove an attribute from a file - - Parameters: - - a string representing filename, or a file-like object, - or a file descriptor; this represents the file on - which to act - - a string, representing the attribute to be removed; - usually in form of system.posix_acl or user.mime_type - - (optional) a boolean value (defaults to false), which, if - the file name given is a symbolic link, makes the - function operate on the symbolic link itself instead - of its target; - - setxattr(...) - Set the value of a given extended attribute. - 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: - - a string representing filename, or a file-like object, - or a file descriptor; this represents the file on - which to act - - a string, representing the attribute whose value to set; - usually in form of system.posix_acl or user.mime_type - - a string, possibly with embedded NULLs; note that there - are restrictions regarding the size of the value, for - example, for ext2/ext3, maximum size is the block size - - (optional) flags; if 0 or ommited the attribute will be - created or replaced; if XATTR_CREATE, the attribute - will be created, giving an error if it already exists; - of XATTR_REPLACE, the attribute will be replaced, - giving an error if it doesn't exists; - - (optional) a boolean value (defaults to false), which, if - the file name given is a symbolic link, makes the - function operate on the symbolic link itself instead - of its target; - -DATA - XATTR_CREATE = 1 - XATTR_REPLACE = 2 - - -- 2.39.5