Skip to content

Commit

Permalink
mepo3: Local path saved to state file is relative to fixture directory
Browse files Browse the repository at this point in the history
  • Loading branch information
pchakraborty committed May 14, 2024
1 parent c8510db commit 430d36d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/mepo3/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ def read_state(cls):
allcomps_s = json.load(fin)
# List of dicts -> state (list of MepoComponent objects)
allcomps = []
for comp in allcomps_s:
allcomps.append(MepoComponent().deserialize(comp))
for comp_s in allcomps_s:
comp = MepoComponent().deserialize(comp_s)
# Relative path to absolute
comp.local = os.path.join(cls.get_root_dir(), comp.local)
allcomps.append(comp)
return allcomps
else:
raise StateDoesNotExistError("Error! mepo3 state does not exist")
Expand All @@ -89,6 +92,8 @@ def write_state(cls, allcomps):
new_state_file = cls.__get_new_state_file()
allcomps_s = []
for comp in allcomps:
# Save relative path (to fixture dir) to state
comp.local = os.path.relpath(comp.local, start=cls.get_root_dir())
allcomps_s.append(comp.serialize())
with open(new_state_file, "w") as fout:
json.dump(allcomps_s, fout)
Expand Down

0 comments on commit 430d36d

Please sign in to comment.