def read_from_rp(self, rp):
"""Set the extended attributes from an rpath"""
try:
attr_list = rp.conn.xattr.listxattr(encode(rp.path),
rp.issym())
except IOError, exc:
if exc[0] in (errno.EOPNOTSUPP, errno.EPERM, errno.ETXTBSY):
return # if not supported, consider empty
if exc[0] in (errno.EACCES, errno.ENOENT, errno.ELOOP):
log.Log("Warning: listattr(%s): %s" % (repr(rp.path), exc), 4)
return
raise
for attr in attr_list:
if attr.startswith('system.'):
# Do not preserve system extended attributes
continue
if not rp.isdir() and attr == 'com.apple.ResourceFork':
# Resource Fork handled elsewhere, except for directories
continue
try:
self.attr_dict[attr] = \
rp.conn.xattr.getxattr(encode(rp.path),
attr, rp.issym())
except IOError, exc:
# File probably modified while reading, just continue
if exc[0] == errno.ENODATA: continue
elif exc[0] == errno.ENOENT: break
# Handle bug in pyxattr < 0.2.2
elif exc[0] == errno.ERANGE: continue
else: raise
评论列表
文章目录