From e7c54769106f2105c3713d8a294d4c50217d7822 Mon Sep 17 00:00:00 2001 From: Jamie Hardt Date: Sat, 26 Oct 2024 11:18:27 -0700 Subject: [PATCH] Added ucsdirs.py --- README.md | 3 +++ tools/ucsdirs.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tools/ucsdirs.py diff --git a/README.md b/README.md index 74aaf06..d1c233b 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ Some items of interest are: - [JSON-formatted UCS Schedules](json/) for all the available languages. - The [tool](tools/ucsxls2json.py) used to make these JSON files from the original XLS file. + - A [directory-creation tool](tools/ucsdirs.py) that can create a directory + tree of UCS categories and sub-categories in any of the supported + languages, using the JSON schedule of your choice. ## Who maintains this? diff --git a/tools/ucsdirs.py b/tools/ucsdirs.py new file mode 100644 index 0000000..01d90b8 --- /dev/null +++ b/tools/ucsdirs.py @@ -0,0 +1,31 @@ +# ucsdirs.py +# (c) 2024 Jamie Hardt +# +# This tool creates a directory tree of UCS category and sub-categories +# according to the selected language schedule. +# +# This script is a part of the `ucs-community` project, a LICENSE file outling +# your rights should be included in its distribution. For more information see +# the project website on github: https://github.com/iluvcapra/ucs-community + +import os +import sys +import json + +# The path to the UCS schedule json +SCHEDULE_JSON=sys.argv[1] + +# The path to create the directory tree in +OUTPUT_PATH='dirs' + +schedule = [] + +with open(SCHEDULE_JSON, "r") as fp: + entries = json.load(fp=fp) + schedule.extend(entries) + +for cat in schedule: + path = os.path.join(OUTPUT_PATH, cat['Category'], + f"{cat['Category']} - {cat['SubCategory']}") + os.makedirs(path) +