Skip to content

Commit ccc0dc2

Browse files
committed
Added cli
1 parent f0e59a9 commit ccc0dc2

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

remove-json-keys/remove-json-keys.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'''
22
Name: remove-json-keys.py
3-
Version: 2026.2.10.10
3+
Version: 2026.2.10.11
44
Author: Adam Lui
55
Description: Remove key/value pairs from json_dir/**.json
66
Homepage: https://github.com/adamlui/python-utils
@@ -11,6 +11,12 @@
1111

1212
import argparse
1313
import os, re
14+
from types import SimpleNamespace
15+
16+
cli = SimpleNamespace(
17+
name='remove-json-keys',
18+
urls=SimpleNamespace(jsdelivr='https://cdn.jsdelivr.net/gh/adamlui/python-utils')
19+
)
1420

1521
# Parse CLI args
1622
parser = argparse.ArgumentParser(description='Remove key/value pairs from JSON files')

translate-messages/translate-en-messages.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'''
22
Name: translate-en-messages.py
3-
Version: 2026.2.10.16
3+
Version: 2026.2.10.17
44
Author: Adam Lui
55
Description: Translate en/messages.json to other locales
66
Homepage: https://github.com/adamlui/python-utils
@@ -13,8 +13,14 @@
1313
import os, json
1414
from sys import stdout
1515
from translate import Translator
16+
from types import SimpleNamespace
1617
from urllib.request import urlopen
1718

19+
cli = SimpleNamespace(
20+
name='translate-messages',
21+
urls=SimpleNamespace(jsdelivr='https://cdn.jsdelivr.net/gh/adamlui/python-utils')
22+
)
23+
1824
provider = ''
1925
default_target_locales = [
2026
'af', 'am', 'ar', 'az', 'be', 'bem', 'bg', 'bn', 'bo', 'bs', 'ca', 'ceb', 'cs', 'cy', 'da', 'de', 'dv', 'dz', 'el',
@@ -49,7 +55,7 @@
4955
print(f'Config already exists at {config_path}')
5056
else:
5157
try: # try to fetch template from jsDelivr
52-
jsd_url = f'https://cdn.jsdelivr.net/gh/adamlui/python-utils/translate-messages/{config_filename}'
58+
jsd_url = f'{cli.urls.jsdelivr}/{cli.name}/{config_filename}'
5359
with urlopen(jsd_url) as resp:
5460
if resp.status == 200 : config_data = json.loads(resp.read().decode('utf-8'))
5561
except Exception : pass

0 commit comments

Comments
 (0)