[diffoscope] 01/01: Support the case where the python3-xattr package is installed but python3-pyxattr is not. Based on an patch by Doug Freed. (Closes: #892240)
Chris Lamb
chris at chris-lamb.co.uk
Fri Mar 9 06:01:38 CET 2018
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository diffoscope.
commit ec51d78da0bbc32fac09cf5b0f56039b8f79c696
Author: Chris Lamb <lamby at debian.org>
Date: Thu Mar 8 21:01:24 2018 -0800
Support the case where the python3-xattr package is installed but python3-pyxattr is not. Based on an patch by Doug Freed. (Closes: #892240)
---
diffoscope/comparators/directory.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py
index b939664..ae2a1f7 100644
--- a/diffoscope/comparators/directory.py
+++ b/diffoscope/comparators/directory.py
@@ -110,20 +110,29 @@ class Getfacl(Command):
def xattr(path1, path2):
try:
- import xattr
+ import xattr as xattr_
except ImportError:
return None
+ # Support the case where the python3-xattr package is installed but
+ # python3-pyxattr is not; python3-xattr has an xattr class that can be used
+ # like a dict.
+ try:
+ get_all = xattr_.get_all
+ except AttributeError:
+ get_all = lambda x: xattr_.xattr(x).items()
+
def fn(x):
return '\n'.join('{}: {}'.format(
k.decode('utf-8', 'ignore'),
v.decode('utf-8', 'ignore'),
- ) for k, v in sorted(xattr.get_all(x)))
+ ) for k, v in get_all(x))
return Difference.from_text(
fn(path1), fn(path2), path1, path2, source='extended file attributes',
)
+
def compare_meta(path1, path2):
if Config().exclude_directory_metadata:
logger.debug("Excluding directory metadata for paths (%s, %s)", path1, path2)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list