Skip to content

Commit

Permalink
Reestablish caching of testdata_yaml[f]
Browse files Browse the repository at this point in the history
  • Loading branch information
thorehusfeldt committed Mar 8, 2024
1 parent dd6de68 commit 2b3d8af
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bin/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ def get_testdata_yaml(p, path, key, name=None) -> str | None:
f = dir / 'testdata.yaml'

if f.is_file():
flags = read_yaml(f, plain=True)
if f in p._testdata_yamls:
flags = p._testdata_yamls[f]
else:
p._testdata_yamls[f] = flags = read_yaml(f, plain=True)


# Validate the flags
for key in flags:
Expand All @@ -226,10 +230,6 @@ def get_testdata_yaml(p, path, key, name=None) -> str | None:
warn(f'Unknown testdata.yaml key: {key}')

# Store testdata.yaml files in a cache.
if f not in p._testdata_yamls:
p._testdata_yamls[f] = read_yaml(f, plain=True)

# flags = p._testdata_yamls[f]
if key in flags:
if isinstance(flags[key], str):
return flags[key]
Expand Down

0 comments on commit 2b3d8af

Please sign in to comment.