Browse Source

Adding an upgrade script for convenience

pull/9/head
Ryan Reed 1 year ago
parent
commit
e8b989541e
1 changed files with 28 additions and 0 deletions
  1. +28
    -0
      scripts/upgrade-2.0.py

+ 28
- 0
scripts/upgrade-2.0.py View File

@ -0,0 +1,28 @@
"""
Loops through STORE_PATH, looking for */.transpose files, create new transpose config file
Note: This does not remove the v1 */.transpose files, just in case. Must be done if desired.
"""
from pathlib import Path
import json
from transpose import TransposeConfig, DEFAULT_STORE_PATH
def main() -> None:
store_path = Path(DEFAULT_STORE_PATH)
config = TransposeConfig()
entries = store_path.glob("*/*.transpose.json")
for entry in entries:
with open(entry, "r") as f:
d = json.load(f)
config.add(Path(entry).parent.parts[-1], d["original_path"])
config.save(store_path.joinpath("transpose.json"))
if __name__ == "__main__":
main()

Loading…
Cancel
Save