[Pythonmac-SIG] MacOS 10.4: getxattr() etc. for Python?
Bob Ippolito
bob at redivi.com
Tue May 3 23:25:40 CEST 2005
On May 3, 2005, at 11:09 AM, Wolfgang Keller wrote:
> has anyone already wrapped the getxattr(), setxattr(),
> removexattr(), listxattr() functions on MacOS 10.4 for
> Python?
I took a stab at it today.
Get the xattr package from pythonmac packages <http://pythonmac.org/
packages/>
source: http://svn.red-bean.com/bob/xattr/trunk
I don't expose getxattr, etc. as public API, because the options they
take don't translate well to Python. Public API is simply an "xattr"
type that you can wrap over a path or fd, and then it's used in a
dict-like way. There should be enough doc strings to get along.
>>> import xattr
>>> x = xattr.xattr('Desktop/Untitled.txt')
>>> x.items()
[(u'com.apple.FinderInfo', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00')]
>>> x['org.pythonmac.encoding'] = 'utf-8'
>>> x.items()
[(u'com.apple.FinderInfo', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00'), (u'org.pythonmac.encoding', 'utf-8')]
>>> del x['org.pythonmac.encoding']
>>> x.items()
[(u'com.apple.FinderInfo', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
\x00\x00\x00\x00\x00')]
-bob
More information about the Pythonmac-SIG
mailing list