Skip to content

Commit

Permalink
feat: deterministicly sortpath.glob
Browse files Browse the repository at this point in the history
  • Loading branch information
gosuto-inzasheru committed Nov 23, 2023
1 parent 914d4af commit d0d0360
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions transform-deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,25 @@
deployments = os.environ["DEPLOYMENTS_REPO_ROOT_URL"]
basepath = deployments


def main():
# Get deployments
active_deployments = []
old_deployments = []
ls = os.listdir(f"{basepath}/tasks")
for path in ls:
if bool(re.search(r'^\d{8}', path)):
if bool(re.search(r"^\d{8}", path)):
active_deployments.append(path)

ls = os.listdir(f"{basepath}/tasks/deprecated")
for path in ls:
if bool(re.search(r'^\d{8}', path)):
if bool(re.search(r"^\d{8}", path)):
old_deployments.append(path)

active = process_deployments(active_deployments, False)
old = process_deployments(old_deployments, True)

results = {
"active": active,
"old": old
}
results = {"active": active, "old": old}
with open("outputs/deployments.json", "w") as f:
json.dump(results, f, indent=3)
### Add extras
Expand Down Expand Up @@ -60,22 +58,19 @@ def main():
except:
data = {}
active[chain] = data | active[chain]
results = {
"active": active,
"old": old
}
results = {"active": active, "old": old}
with open("outputs/addressbook.json", "w") as f:
json.dump(results, f, indent=3)


def process_deployments(deployments, old=False):
result = {}
for task in deployments:
if old:
path = Path(f"{basepath}/tasks/deprecated/{task}/output")
else:
path = Path(f"{basepath}/tasks/{task}/output")

for file in list(path.glob("*.json")):
for file in list(sorted(path.glob("*.json"))):
chain = file.stem
if chain not in result.keys():
result[chain] = {}
Expand Down

0 comments on commit d0d0360

Please sign in to comment.