store: move __contains__() implementation from class fncache into fncachestore

This restores the previous semantics of fncache.__contains__().

(a followup to e76e2e89c766)
This commit is contained in:
Adrian Buehlmann 2012-10-12 10:40:09 +02:00
parent 5ba969faf1
commit f86ce05929

View File

@ -426,19 +426,10 @@ class fncache(object):
self._dirty = True
self.entries.add(fn)
def __contains__(self, path):
def __contains__(self, fn):
if self.entries is None:
self._load()
# Check for files (exact match)
if path + ".i" in self.entries:
return True
# Now check for directories (prefix match)
if not path.endswith('/'):
path += '/'
for e in self.entries:
if e.startswith(path):
return True
return False
return fn in self.entries
def __iter__(self):
if self.entries is None:
@ -524,7 +515,16 @@ class fncachestore(basicstore):
def __contains__(self, path):
'''Checks if the store contains path'''
path = "/".join(("data", path))
return path in self.fncache
# check for files (exact match)
if path + '.i' in self.fncache:
return True
# now check for directories (prefix match)
if not path.endswith('/'):
path += '/'
for e in self.fncache:
if e.startswith(path):
return True
return False
def store(requirements, path, vfstype):
if 'store' in requirements: