Skip to content

Commit

Permalink
Cleanup handling for collecting files, fix issues with non-relative p…
Browse files Browse the repository at this point in the history
…aths and using only non-globs. Ref #53.
  • Loading branch information
ionelmc committed May 27, 2016
1 parent b6f6063 commit 41b3174
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/pytest_benchmark/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,18 @@ def query(self, *globs_or_files):
filename_glob = filename_glob.rstrip("*") + "*.json"
globs.append((platform_glob, filename_glob))

return sorted(chain(
files,
(
file
for platform_glob, filename_glob in globs
for path in self.path.glob(platform_glob)
for file in path.glob(filename_glob)
), (
file for file in self.path.glob(filename_glob)
)
), key=lambda file: (file.name, file.parent))
files.extend((
file
for platform_glob, filename_glob in globs
for path in self.path.glob(platform_glob)
for file in path.glob(filename_glob)
))
files.extend((
file
for _, filename_glob in globs
for file in self.path.glob(filename_glob)
))
return sorted(files, key=lambda file: (file.name, file.parent))

def load(self, *globs_or_files):
for file in self.query(*globs_or_files):
Expand All @@ -85,8 +86,11 @@ def load(self, *globs_or_files):
"Failed to load {0}: {1}".format(file, exc), fslocation=self.location)
continue
self._cache[file] = data

yield file.relative_to(self.path), data
try:
relpath = file.relative_to(self.path)
except ValueError:
relpath = file
yield relpath, data

def load_benchmarks(self, *globs_or_files):
sources = [
Expand Down

0 comments on commit 41b3174

Please sign in to comment.