From 02b099c821502ef3d43feb071c7c3db7d59a68bf Mon Sep 17 00:00:00 2001 From: David Stainton Date: Mon, 14 Sep 2015 06:29:56 +0200 Subject: [PATCH] Simply should_ignore_file helper function --- src/allmydata/magicpath.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/allmydata/magicpath.py b/src/allmydata/magicpath.py index e2728421..b072b463 100644 --- a/src/allmydata/magicpath.py +++ b/src/allmydata/magicpath.py @@ -9,22 +9,15 @@ def magic2path(path): return re.sub(ur'@[_@]', lambda m: {u'@_': u'/', u'@@': u'@'}[m.group(0)], path) -IGNORE_SUFFIXES = ['.backup', '.tmp', '.conflicted'] -IGNORE_PREFIXES = ['.'] +IGNORE_SUFFIXES = [u'.backup', u'.tmp', u'.conflicted'] +IGNORE_PREFIXES = [u'.'] def should_ignore_file(path_u): for suffix in IGNORE_SUFFIXES: if path_u.endswith(suffix): return True - while True: - head, tail = os.path.split(path_u) - if tail != "": - for prefix in IGNORE_PREFIXES: - if tail.startswith(prefix): - return True - else: - path_u = head - else: - if head == "": - return False + while path_u != u"": + path_u, tail_u = os.path.split(path_u) + if tail_u.startswith(u"."): + return True return False -- 2.45.2