Skip to content

Commit

Permalink
download and sort json from prefix.cc with python script in custom task
Browse files Browse the repository at this point in the history
  • Loading branch information
muddymudskipper committed Jul 17, 2024
1 parent 345dffc commit 7ce1c24
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions TaskfileCustom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 0 additions & 12 deletions sort_prefix_json.py

This file was deleted.

11 changes: 11 additions & 0 deletions update_prefixes.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7ce1c24

Please sign in to comment.