Skip to content

Commit b2fe924

Browse files
committed
Rid DEFAULT_CONFIG, condensed --help descriptions ↞ [auto-sync from https://github.com/adamlui/python-utils/tree/main/translate-messages]
1 parent a6a8759 commit b2fe924

File tree

24 files changed

+240
-264
lines changed

24 files changed

+240
-264
lines changed

amazongpt/greasemonkey/utils/translate-en-messages.py

Lines changed: 10 additions & 11 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.14
3+
Version: 2026.2.10.15
44
Author: Adam Lui
55
Description: Translate en/messages.json to other locales
66
Homepage: https://github.com/adamlui/python-utils
@@ -26,34 +26,33 @@
2626
]
2727

2828
# Init/load config file
29-
DEFAULT_CONFIG = { 'include_langs': '', 'exclude_langs': '', 'ignore_keys': '' }
3029
script_name = os.path.splitext(os.path.basename(__file__))[0]
3130
config_filename = f'{script_name}.config.json'
3231
config_path = os.path.join(os.path.dirname(__file__), config_filename)
33-
config_data = DEFAULT_CONFIG.copy()
32+
config_data = {}
3433
if os.path.exists(config_path):
3534
with open(config_path, 'r', encoding='utf-8') as file_config:
3635
config_data.update(json.load(file_config))
3736

3837
# Parse CLI args
3938
parser = argparse.ArgumentParser(description='Translate en/messages.json to other locales')
40-
parser.add_argument('--include-langs', type=str, help='Comma-separated list of languages to include (e.g. "en,es,fr")')
41-
parser.add_argument('--exclude-langs', type=str, help='Comma-separated list of languages to exclude (e.g. "en,es")')
42-
parser.add_argument('--ignore-keys', type=str, help='Comma-separated list of keys to ignore (e.g. "appName,author")')
43-
parser.add_argument('--init', action='store_true', help='Create a .config.json adjacent to this script')
39+
parser.add_argument('--include-langs', type=str, help='Languages to include (e.g. "en,es,fr")')
40+
parser.add_argument('--exclude-langs', type=str, help='Languages to exclude (e.g. "en,es")')
41+
parser.add_argument('--ignore-keys', type=str, help='Keys to ignore (e.g. "appName,author")')
42+
parser.add_argument('--init', action='store_true', help='Create .config.json file to store defaults')
4443
args = parser.parse_args()
4544

4645
if args.init: # create config file
4746
if os.path.exists(config_path):
4847
print(f'Config already exists at {config_path}')
4948
else:
50-
try: # to use jsDelivr copy
49+
try: # try to fetch template from jsDelivr
5150
jsd_url = f'https://cdn.jsdelivr.net/gh/adamlui/python-utils/translate-messages/{config_filename}'
5251
with urlopen(jsd_url) as resp:
5352
if resp.status == 200 : config_data = json.loads(resp.read().decode('utf-8'))
54-
except Exception:
55-
config_data = { 'include_langs': '', 'exclude_langs': '' }
56-
with open(config_path, 'w', encoding='utf-8') as f: json.dump(config_data, f, indent=2)
53+
except Exception : pass
54+
with open(config_path, 'w', encoding='utf-8') as configFile:
55+
json.dump(config_data, configFile, indent=2)
5756
print(f'Default config created at {config_path}')
5857
exit()
5958

autoclear-chatgpt-history/greasemonkey/utils/translate-en-messages.py

Lines changed: 10 additions & 11 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.14
3+
Version: 2026.2.10.15
44
Author: Adam Lui
55
Description: Translate en/messages.json to other locales
66
Homepage: https://github.com/adamlui/python-utils
@@ -26,34 +26,33 @@
2626
]
2727

2828
# Init/load config file
29-
DEFAULT_CONFIG = { 'include_langs': '', 'exclude_langs': '', 'ignore_keys': '' }
3029
script_name = os.path.splitext(os.path.basename(__file__))[0]
3130
config_filename = f'{script_name}.config.json'
3231
config_path = os.path.join(os.path.dirname(__file__), config_filename)
33-
config_data = DEFAULT_CONFIG.copy()
32+
config_data = {}
3433
if os.path.exists(config_path):
3534
with open(config_path, 'r', encoding='utf-8') as file_config:
3635
config_data.update(json.load(file_config))
3736

3837
# Parse CLI args
3938
parser = argparse.ArgumentParser(description='Translate en/messages.json to other locales')
40-
parser.add_argument('--include-langs', type=str, help='Comma-separated list of languages to include (e.g. "en,es,fr")')
41-
parser.add_argument('--exclude-langs', type=str, help='Comma-separated list of languages to exclude (e.g. "en,es")')
42-
parser.add_argument('--ignore-keys', type=str, help='Comma-separated list of keys to ignore (e.g. "appName,author")')
43-
parser.add_argument('--init', action='store_true', help='Create a .config.json adjacent to this script')
39+
parser.add_argument('--include-langs', type=str, help='Languages to include (e.g. "en,es,fr")')
40+
parser.add_argument('--exclude-langs', type=str, help='Languages to exclude (e.g. "en,es")')
41+
parser.add_argument('--ignore-keys', type=str, help='Keys to ignore (e.g. "appName,author")')
42+
parser.add_argument('--init', action='store_true', help='Create .config.json file to store defaults')
4443
args = parser.parse_args()
4544

4645
if args.init: # create config file
4746
if os.path.exists(config_path):
4847
print(f'Config already exists at {config_path}')
4948
else:
50-
try: # to use jsDelivr copy
49+
try: # try to fetch template from jsDelivr
5150
jsd_url = f'https://cdn.jsdelivr.net/gh/adamlui/python-utils/translate-messages/{config_filename}'
5251
with urlopen(jsd_url) as resp:
5352
if resp.status == 200 : config_data = json.loads(resp.read().decode('utf-8'))
54-
except Exception:
55-
config_data = { 'include_langs': '', 'exclude_langs': '' }
56-
with open(config_path, 'w', encoding='utf-8') as f: json.dump(config_data, f, indent=2)
53+
except Exception : pass
54+
with open(config_path, 'w', encoding='utf-8') as configFile:
55+
json.dump(config_data, configFile, indent=2)
5756
print(f'Default config created at {config_path}')
5857
exit()
5958

brave-omnibox/chromium/utils/translate-en-messages.py

Lines changed: 10 additions & 11 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.14
3+
Version: 2026.2.10.15
44
Author: Adam Lui
55
Description: Translate en/messages.json to other locales
66
Homepage: https://github.com/adamlui/python-utils
@@ -26,34 +26,33 @@
2626
]
2727

2828
# Init/load config file
29-
DEFAULT_CONFIG = { 'include_langs': '', 'exclude_langs': '', 'ignore_keys': '' }
3029
script_name = os.path.splitext(os.path.basename(__file__))[0]
3130
config_filename = f'{script_name}.config.json'
3231
config_path = os.path.join(os.path.dirname(__file__), config_filename)
33-
config_data = DEFAULT_CONFIG.copy()
32+
config_data = {}
3433
if os.path.exists(config_path):
3534
with open(config_path, 'r', encoding='utf-8') as file_config:
3635
config_data.update(json.load(file_config))
3736

3837
# Parse CLI args
3938
parser = argparse.ArgumentParser(description='Translate en/messages.json to other locales')
40-
parser.add_argument('--include-langs', type=str, help='Comma-separated list of languages to include (e.g. "en,es,fr")')
41-
parser.add_argument('--exclude-langs', type=str, help='Comma-separated list of languages to exclude (e.g. "en,es")')
42-
parser.add_argument('--ignore-keys', type=str, help='Comma-separated list of keys to ignore (e.g. "appName,author")')
43-
parser.add_argument('--init', action='store_true', help='Create a .config.json adjacent to this script')
39+
parser.add_argument('--include-langs', type=str, help='Languages to include (e.g. "en,es,fr")')
40+
parser.add_argument('--exclude-langs', type=str, help='Languages to exclude (e.g. "en,es")')
41+
parser.add_argument('--ignore-keys', type=str, help='Keys to ignore (e.g. "appName,author")')
42+
parser.add_argument('--init', action='store_true', help='Create .config.json file to store defaults')
4443
args = parser.parse_args()
4544

4645
if args.init: # create config file
4746
if os.path.exists(config_path):
4847
print(f'Config already exists at {config_path}')
4948
else:
50-
try: # to use jsDelivr copy
49+
try: # try to fetch template from jsDelivr
5150
jsd_url = f'https://cdn.jsdelivr.net/gh/adamlui/python-utils/translate-messages/{config_filename}'
5251
with urlopen(jsd_url) as resp:
5352
if resp.status == 200 : config_data = json.loads(resp.read().decode('utf-8'))
54-
except Exception:
55-
config_data = { 'include_langs': '', 'exclude_langs': '' }
56-
with open(config_path, 'w', encoding='utf-8') as f: json.dump(config_data, f, indent=2)
53+
except Exception : pass
54+
with open(config_path, 'w', encoding='utf-8') as configFile:
55+
json.dump(config_data, configFile, indent=2)
5756
print(f'Default config created at {config_path}')
5857
exit()
5958

brave-omnibox/firefox/utils/translate-en-messages.py

Lines changed: 10 additions & 11 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.14
3+
Version: 2026.2.10.15
44
Author: Adam Lui
55
Description: Translate en/messages.json to other locales
66
Homepage: https://github.com/adamlui/python-utils
@@ -26,34 +26,33 @@
2626
]
2727

2828
# Init/load config file
29-
DEFAULT_CONFIG = { 'include_langs': '', 'exclude_langs': '', 'ignore_keys': '' }
3029
script_name = os.path.splitext(os.path.basename(__file__))[0]
3130
config_filename = f'{script_name}.config.json'
3231
config_path = os.path.join(os.path.dirname(__file__), config_filename)
33-
config_data = DEFAULT_CONFIG.copy()
32+
config_data = {}
3433
if os.path.exists(config_path):
3534
with open(config_path, 'r', encoding='utf-8') as file_config:
3635
config_data.update(json.load(file_config))
3736

3837
# Parse CLI args
3938
parser = argparse.ArgumentParser(description='Translate en/messages.json to other locales')
40-
parser.add_argument('--include-langs', type=str, help='Comma-separated list of languages to include (e.g. "en,es,fr")')
41-
parser.add_argument('--exclude-langs', type=str, help='Comma-separated list of languages to exclude (e.g. "en,es")')
42-
parser.add_argument('--ignore-keys', type=str, help='Comma-separated list of keys to ignore (e.g. "appName,author")')
43-
parser.add_argument('--init', action='store_true', help='Create a .config.json adjacent to this script')
39+
parser.add_argument('--include-langs', type=str, help='Languages to include (e.g. "en,es,fr")')
40+
parser.add_argument('--exclude-langs', type=str, help='Languages to exclude (e.g. "en,es")')
41+
parser.add_argument('--ignore-keys', type=str, help='Keys to ignore (e.g. "appName,author")')
42+
parser.add_argument('--init', action='store_true', help='Create .config.json file to store defaults')
4443
args = parser.parse_args()
4544

4645
if args.init: # create config file
4746
if os.path.exists(config_path):
4847
print(f'Config already exists at {config_path}')
4948
else:
50-
try: # to use jsDelivr copy
49+
try: # try to fetch template from jsDelivr
5150
jsd_url = f'https://cdn.jsdelivr.net/gh/adamlui/python-utils/translate-messages/{config_filename}'
5251
with urlopen(jsd_url) as resp:
5352
if resp.status == 200 : config_data = json.loads(resp.read().decode('utf-8'))
54-
except Exception:
55-
config_data = { 'include_langs': '', 'exclude_langs': '' }
56-
with open(config_path, 'w', encoding='utf-8') as f: json.dump(config_data, f, indent=2)
53+
except Exception : pass
54+
with open(config_path, 'w', encoding='utf-8') as configFile:
55+
json.dump(config_data, configFile, indent=2)
5756
print(f'Default config created at {config_path}')
5857
exit()
5958

bravegpt/greasemonkey/utils/translate-en-messages.py

Lines changed: 10 additions & 11 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.14
3+
Version: 2026.2.10.15
44
Author: Adam Lui
55
Description: Translate en/messages.json to other locales
66
Homepage: https://github.com/adamlui/python-utils
@@ -26,34 +26,33 @@
2626
]
2727

2828
# Init/load config file
29-
DEFAULT_CONFIG = { 'include_langs': '', 'exclude_langs': '', 'ignore_keys': '' }
3029
script_name = os.path.splitext(os.path.basename(__file__))[0]
3130
config_filename = f'{script_name}.config.json'
3231
config_path = os.path.join(os.path.dirname(__file__), config_filename)
33-
config_data = DEFAULT_CONFIG.copy()
32+
config_data = {}
3433
if os.path.exists(config_path):
3534
with open(config_path, 'r', encoding='utf-8') as file_config:
3635
config_data.update(json.load(file_config))
3736

3837
# Parse CLI args
3938
parser = argparse.ArgumentParser(description='Translate en/messages.json to other locales')
40-
parser.add_argument('--include-langs', type=str, help='Comma-separated list of languages to include (e.g. "en,es,fr")')
41-
parser.add_argument('--exclude-langs', type=str, help='Comma-separated list of languages to exclude (e.g. "en,es")')
42-
parser.add_argument('--ignore-keys', type=str, help='Comma-separated list of keys to ignore (e.g. "appName,author")')
43-
parser.add_argument('--init', action='store_true', help='Create a .config.json adjacent to this script')
39+
parser.add_argument('--include-langs', type=str, help='Languages to include (e.g. "en,es,fr")')
40+
parser.add_argument('--exclude-langs', type=str, help='Languages to exclude (e.g. "en,es")')
41+
parser.add_argument('--ignore-keys', type=str, help='Keys to ignore (e.g. "appName,author")')
42+
parser.add_argument('--init', action='store_true', help='Create .config.json file to store defaults')
4443
args = parser.parse_args()
4544

4645
if args.init: # create config file
4746
if os.path.exists(config_path):
4847
print(f'Config already exists at {config_path}')
4948
else:
50-
try: # to use jsDelivr copy
49+
try: # try to fetch template from jsDelivr
5150
jsd_url = f'https://cdn.jsdelivr.net/gh/adamlui/python-utils/translate-messages/{config_filename}'
5251
with urlopen(jsd_url) as resp:
5352
if resp.status == 200 : config_data = json.loads(resp.read().decode('utf-8'))
54-
except Exception:
55-
config_data = { 'include_langs': '', 'exclude_langs': '' }
56-
with open(config_path, 'w', encoding='utf-8') as f: json.dump(config_data, f, indent=2)
53+
except Exception : pass
54+
with open(config_path, 'w', encoding='utf-8') as configFile:
55+
json.dump(config_data, configFile, indent=2)
5756
print(f'Default config created at {config_path}')
5857
exit()
5958

chatgpt-auto-continue/chromium/utils/translate-en-messages.py

Lines changed: 10 additions & 11 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.14
3+
Version: 2026.2.10.15
44
Author: Adam Lui
55
Description: Translate en/messages.json to other locales
66
Homepage: https://github.com/adamlui/python-utils
@@ -26,34 +26,33 @@
2626
]
2727

2828
# Init/load config file
29-
DEFAULT_CONFIG = { 'include_langs': '', 'exclude_langs': '', 'ignore_keys': '' }
3029
script_name = os.path.splitext(os.path.basename(__file__))[0]
3130
config_filename = f'{script_name}.config.json'
3231
config_path = os.path.join(os.path.dirname(__file__), config_filename)
33-
config_data = DEFAULT_CONFIG.copy()
32+
config_data = {}
3433
if os.path.exists(config_path):
3534
with open(config_path, 'r', encoding='utf-8') as file_config:
3635
config_data.update(json.load(file_config))
3736

3837
# Parse CLI args
3938
parser = argparse.ArgumentParser(description='Translate en/messages.json to other locales')
40-
parser.add_argument('--include-langs', type=str, help='Comma-separated list of languages to include (e.g. "en,es,fr")')
41-
parser.add_argument('--exclude-langs', type=str, help='Comma-separated list of languages to exclude (e.g. "en,es")')
42-
parser.add_argument('--ignore-keys', type=str, help='Comma-separated list of keys to ignore (e.g. "appName,author")')
43-
parser.add_argument('--init', action='store_true', help='Create a .config.json adjacent to this script')
39+
parser.add_argument('--include-langs', type=str, help='Languages to include (e.g. "en,es,fr")')
40+
parser.add_argument('--exclude-langs', type=str, help='Languages to exclude (e.g. "en,es")')
41+
parser.add_argument('--ignore-keys', type=str, help='Keys to ignore (e.g. "appName,author")')
42+
parser.add_argument('--init', action='store_true', help='Create .config.json file to store defaults')
4443
args = parser.parse_args()
4544

4645
if args.init: # create config file
4746
if os.path.exists(config_path):
4847
print(f'Config already exists at {config_path}')
4948
else:
50-
try: # to use jsDelivr copy
49+
try: # try to fetch template from jsDelivr
5150
jsd_url = f'https://cdn.jsdelivr.net/gh/adamlui/python-utils/translate-messages/{config_filename}'
5251
with urlopen(jsd_url) as resp:
5352
if resp.status == 200 : config_data = json.loads(resp.read().decode('utf-8'))
54-
except Exception:
55-
config_data = { 'include_langs': '', 'exclude_langs': '' }
56-
with open(config_path, 'w', encoding='utf-8') as f: json.dump(config_data, f, indent=2)
53+
except Exception : pass
54+
with open(config_path, 'w', encoding='utf-8') as configFile:
55+
json.dump(config_data, configFile, indent=2)
5756
print(f'Default config created at {config_path}')
5857
exit()
5958

chatgpt-auto-continue/firefox/utils/translate-en-messages.py

Lines changed: 10 additions & 11 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.14
3+
Version: 2026.2.10.15
44
Author: Adam Lui
55
Description: Translate en/messages.json to other locales
66
Homepage: https://github.com/adamlui/python-utils
@@ -26,34 +26,33 @@
2626
]
2727

2828
# Init/load config file
29-
DEFAULT_CONFIG = { 'include_langs': '', 'exclude_langs': '', 'ignore_keys': '' }
3029
script_name = os.path.splitext(os.path.basename(__file__))[0]
3130
config_filename = f'{script_name}.config.json'
3231
config_path = os.path.join(os.path.dirname(__file__), config_filename)
33-
config_data = DEFAULT_CONFIG.copy()
32+
config_data = {}
3433
if os.path.exists(config_path):
3534
with open(config_path, 'r', encoding='utf-8') as file_config:
3635
config_data.update(json.load(file_config))
3736

3837
# Parse CLI args
3938
parser = argparse.ArgumentParser(description='Translate en/messages.json to other locales')
40-
parser.add_argument('--include-langs', type=str, help='Comma-separated list of languages to include (e.g. "en,es,fr")')
41-
parser.add_argument('--exclude-langs', type=str, help='Comma-separated list of languages to exclude (e.g. "en,es")')
42-
parser.add_argument('--ignore-keys', type=str, help='Comma-separated list of keys to ignore (e.g. "appName,author")')
43-
parser.add_argument('--init', action='store_true', help='Create a .config.json adjacent to this script')
39+
parser.add_argument('--include-langs', type=str, help='Languages to include (e.g. "en,es,fr")')
40+
parser.add_argument('--exclude-langs', type=str, help='Languages to exclude (e.g. "en,es")')
41+
parser.add_argument('--ignore-keys', type=str, help='Keys to ignore (e.g. "appName,author")')
42+
parser.add_argument('--init', action='store_true', help='Create .config.json file to store defaults')
4443
args = parser.parse_args()
4544

4645
if args.init: # create config file
4746
if os.path.exists(config_path):
4847
print(f'Config already exists at {config_path}')
4948
else:
50-
try: # to use jsDelivr copy
49+
try: # try to fetch template from jsDelivr
5150
jsd_url = f'https://cdn.jsdelivr.net/gh/adamlui/python-utils/translate-messages/{config_filename}'
5251
with urlopen(jsd_url) as resp:
5352
if resp.status == 200 : config_data = json.loads(resp.read().decode('utf-8'))
54-
except Exception:
55-
config_data = { 'include_langs': '', 'exclude_langs': '' }
56-
with open(config_path, 'w', encoding='utf-8') as f: json.dump(config_data, f, indent=2)
53+
except Exception : pass
54+
with open(config_path, 'w', encoding='utf-8') as configFile:
55+
json.dump(config_data, configFile, indent=2)
5756
print(f'Default config created at {config_path}')
5857
exit()
5958

0 commit comments

Comments
 (0)