diff --git a/TaskfileCustom.yaml b/TaskfileCustom.yaml index e589abb..e0240bc 100644 --- a/TaskfileCustom.yaml +++ b/TaskfileCustom.yaml @@ -6,5 +6,4 @@ tasks: update_prefixes: desc: Update the prefix list from prefix.cc. cmds: - - curl -L -o cmem_plugin_shapes/prefix.cc.json http://prefix.cc/popular/all.file.json - - python sort_prefix_json.py + - python update_prefixes.py diff --git a/sort_prefix_json.py b/sort_prefix_json.py deleted file mode 100644 index a6860e8..0000000 --- a/sort_prefix_json.py +++ /dev/null @@ -1,12 +0,0 @@ -"""Helper script to sort prefixes in task custom:update_prefixes""" - -from json import dump, load -from pathlib import Path - -file_path = Path("cmem_plugin_shapes") / "prefix.cc.json" - -with file_path.open("r") as json_file: - json_data = load(json_file) - -with file_path.open("w") as json_file: - dump(json_data, json_file, sort_keys=True, indent=2) diff --git a/update_prefixes.py b/update_prefixes.py new file mode 100644 index 0000000..f6cced7 --- /dev/null +++ b/update_prefixes.py @@ -0,0 +1,11 @@ +"""Helper script to sort prefixes in task custom:update_prefixes""" + +from json import dump, loads +from pathlib import Path +from urllib.request import urlopen + +with urlopen('http://prefix.cc/popular/all.file.json') as f: + json_data = loads(f.read().decode('utf-8')) + +with (Path("cmem_plugin_shapes") / "prefix.cc.json").open("w") as json_file: + dump(json_data, json_file, sort_keys=True, indent=2)