Added ucsdirs.py
This commit is contained in:
@@ -14,6 +14,9 @@ Some items of interest are:
|
|||||||
- [JSON-formatted UCS Schedules](json/) for all the available languages.
|
- [JSON-formatted UCS Schedules](json/) for all the available languages.
|
||||||
- The [tool](tools/ucsxls2json.py) used to make these JSON files from the
|
- The [tool](tools/ucsxls2json.py) used to make these JSON files from the
|
||||||
original XLS file.
|
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?
|
## Who maintains this?
|
||||||
|
|
||||||
|
31
tools/ucsdirs.py
Normal file
31
tools/ucsdirs.py
Normal file
@@ -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)
|
||||||
|
|
Reference in New Issue
Block a user