Skip to content

Commit

Permalink
Bump schema version to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
dhinakg committed Jan 3, 2023
1 parent 6ae3050 commit aba51bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions config_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ def save_config(data: dict):
plugin_dir = config_dir / Path("plugins")
plugin_dir.mkdir(exist_ok=True)

version = data["_version"]

for plugin in data:
if plugin == "_version":
continue
data[plugin]["versions"].sort(key=lambda x: (x["date_committed"], x["date_authored"]), reverse=True)
json.dump(data[plugin] | {"_version": data["_version"]}, (plugin_dir / Path(f"{plugin}.json")).open("w"), sort_keys=True)
json.dump(data[plugin] | {"_version": version}, (plugin_dir / Path(f"{plugin}.json")).open("w"), sort_keys=True)

latest = data.copy()
for plugin in latest:
Expand All @@ -21,4 +23,4 @@ def save_config(data: dict):

json.dump(data, (config_dir / Path("config.json")).open("w"), sort_keys=True)
json.dump(latest, (config_dir / Path("latest.json")).open("w"), sort_keys=True)
json.dump(list(data.keys()), (config_dir / Path("plugins.json")).open("w"), sort_keys=True)
json.dump({"plugins": list(data.keys()), "_version": version}, (config_dir / Path("plugins.json")).open("w"), sort_keys=True)
5 changes: 5 additions & 0 deletions update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def add_author_date(name, version):

config["_version"] = 3

# version 3 to 4
# nothing changed, but the other json files were added

if config["_version"] == 3:
config["_version"] = 4

save_config(config)

Expand Down

0 comments on commit aba51bb

Please sign in to comment.