summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--anidb.py2
-rw-r--r--pyanidb/hash.py6
2 files changed, 6 insertions, 2 deletions
diff --git a/anidb.py b/anidb.py
index 0075a96..b88d8e8 100644
--- a/anidb.py
+++ b/anidb.py
@@ -90,7 +90,7 @@ for name in args:
for root, subdirs, subfiles in os.walk(name):
subdirs.sort()
subfiles.sort()
- files += [os.path.join(root, file) for file in subfiles if sum([file.endswith('.' + suffix) for suffix in options.suffix])]
+ files += [os.path.join(root, file) for file in subfiles if True in [file.endswith('.' + suffix) for suffix in options.suffix]]
if not files:
print blue('Nothing to do.')
diff --git a/pyanidb/hash.py b/pyanidb/hash.py
index a748f9e..4aab45f 100644
--- a/pyanidb/hash.py
+++ b/pyanidb/hash.py
@@ -12,7 +12,7 @@ class File:
self.cached = False
if cache:
self.read_cache()
- if sum([not hasattr(self, a) for a in algorithms]):
+ if False in [hasattr(self, a) for a in algorithms]:
self.cached = False
h = multihash.hash_file(name, algorithms)
for a in algorithms:
@@ -20,6 +20,8 @@ class File:
self.write_cache()
def read_cache(self):
+ if not xattr:
+ return
cache = dict([(n[13:], xattr.getxattr(self.name, n)) for n in xattr.listxattr(self.name) if n.startswith('user.pyanidb.')])
if 'mtime' not in cache or str(int(self.mtime)) != cache.pop('mtime'):
return
@@ -28,6 +30,8 @@ class File:
self.cached = True
def write_cache(self):
+ if not xattr:
+ return
try:
self.clear_cache()
xattr.setxattr(self.name, 'user.pyanidb.mtime', str(int(self.mtime)))