Skip to content

Commit 4dea896

Browse files
committed
Updated json_folder refs
1 parent bd7dc5b commit 4dea896

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'''
22
Name: remove-json-keys.py
3-
Version: 2026.2.10.9
3+
Version: 2026.2.10.10
44
Author: Adam Lui
5-
Description: Remove key/value pairs from json_folder/**.json
5+
Description: Remove key/value pairs from json_dir/**.json
66
Homepage: https://github.com/adamlui/python-utils
77
Support: https://github.com/adamlui/python-utils/issues
88
Sponsor: https://github.com/sponsors/adamlui
@@ -17,7 +17,7 @@
1717
parser.add_argument('--remove-keys', type=str, help='Keys to remove')
1818
parser.add_argument('--json-dir', type=str, help='Name of folder containing JSON files')
1919
args = parser.parse_args()
20-
json_folder = args.json_folder or '_locales'
20+
json_dir = args.json_dir or '_locales'
2121

2222
# UI initializations
2323
try:
@@ -41,24 +41,24 @@ def parse_csv_str(str) : return [lang.strip() for lang in str.split(',') if lang
4141
remove_keys.append(key)
4242

4343
# Determine closest JSON dir
44-
print_trunc(f'Searching for { json_folder }...')
44+
print_trunc(f'Searching for { json_dir }...')
4545
script_dir = os.path.abspath(os.path.dirname(__file__))
4646
for root, dirs, files in os.walk(script_dir): # search script dir recursively
47-
if json_folder in dirs:
48-
json_dir = os.path.join(root, json_folder) ; break
47+
if json_dir in dirs:
48+
json_dir = os.path.join(root, json_dir) ; break
4949
else: # search script parent dirs recursively
5050
parent_dir = os.path.dirname(script_dir)
5151
while parent_dir and parent_dir != script_dir:
5252
for root, dirs, files in os.walk(parent_dir):
53-
if json_folder in dirs:
54-
json_dir = os.path.join(root, json_folder) ; break
53+
if json_dir in dirs:
54+
json_dir = os.path.join(root, json_dir) ; break
5555
if json_dir : break
5656
parent_dir = os.path.dirname(parent_dir)
5757
else : json_dir = None
5858

5959
# Print result
6060
if json_dir : print_trunc(f'JSON directory found!\n\n>> { json_dir }\n')
61-
else : print_trunc(f'Unable to locate a { json_folder } directory.') ; exit()
61+
else : print_trunc(f'Unable to locate a { json_dir } directory.') ; exit()
6262

6363
# Process JSON files and remove specified keys
6464
keys_removed, keys_skipped, processed_count = [], [], 0

0 commit comments

Comments
 (0)