Commit dacefdfe by Kyle MacFarlane Committed by Timothée Peignier

remove exists() call from glob and versioning, trying tocatch exceptions instead when possible

Signed-off-by: Timothée Peignier <timothee.peignier@tryphon.org>
parent 93381ffe
...@@ -23,8 +23,7 @@ def iglob(pathname): ...@@ -23,8 +23,7 @@ def iglob(pathname):
""" """
if not has_magic(pathname): if not has_magic(pathname):
if storage.exists(pathname): yield pathname
yield pathname
return return
dirname, basename = os.path.split(pathname) dirname, basename = os.path.split(pathname)
if not dirname: if not dirname:
......
...@@ -39,8 +39,6 @@ class Versioning(object): ...@@ -39,8 +39,6 @@ class Versioning(object):
def need_update(self, output_file, paths): def need_update(self, output_file, paths):
version = self.version(paths) version = self.version(paths)
output_file = self.output_filename(output_file, version) output_file = self.output_filename(output_file, version)
if not storage.exists(output_file):
return True, version
return getattr(self.versioner, 'need_update')(output_file, paths, version) return getattr(self.versioner, 'need_update')(output_file, paths, version)
def cleanup(self, filename): def cleanup(self, filename):
......
...@@ -13,4 +13,8 @@ class MTimeVersioning(VersioningBase): ...@@ -13,4 +13,8 @@ class MTimeVersioning(VersioningBase):
def need_update(self, output_file, paths, version): def need_update(self, output_file, paths, version):
output_filename = self.output_filename(output_file, version) output_filename = self.output_filename(output_file, version)
return (int(time.mktime(storage.modified_time(output_filename).timetuple())) < int(version)), version try:
modified_time = storage.modified_time(output_filename)
except EnvironmentError:
return True, version
return (int(time.mktime(modified_time.timetuple())) < int(version)), version
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment