|
15 | 15 |
|
16 | 16 | # Determine closest locales dir |
17 | 17 | log.trunc(f'\nSearching for {cli.json_dir}...') |
18 | | -script_dir = os.path.abspath(os.path.dirname(__file__)) |
19 | | -for root, dirs, files in os.walk(script_dir): # search script dir recursively |
20 | | - if cli.json_dir in dirs: |
21 | | - cli.json_dir = os.path.join(root, cli.json_dir) ; break |
22 | | -else: # search script parent dirs recursively |
23 | | - parent_dir = os.path.dirname(script_dir) |
24 | | - while parent_dir and parent_dir != script_dir: |
25 | | - for root, dirs, files in os.walk(parent_dir): |
26 | | - if cli.json_dir in dirs: |
27 | | - cli.json_dir = os.path.join(root, cli.json_dir) ; break |
28 | | - if cli.json_dir : break |
29 | | - parent_dir = os.path.dirname(parent_dir) |
30 | | - else : cli.json_dir = None |
31 | | - |
32 | | -# Print result |
33 | | -if cli.json_dir : log.trunc(f'JSON directory found!\n\n>> {cli.json_dir}\n') |
34 | | -else : log.trunc(f'Unable to locate a {cli.json_dir} directory.') ; exit() |
| 18 | +cli.json_dir = init.json_dir(cli.json_dir) |
| 19 | +if cli.json_dir: |
| 20 | + log.trunc(f'JSON directory found!\n\n>> {cli.json_dir}\n') |
| 21 | +else: |
| 22 | + log.trunc(f'Unable to locate a {cli.json_dir} directory.') ; exit() |
35 | 23 |
|
36 | 24 | # Process JSON files and remove specified keys |
37 | 25 | keys_removed, keys_skipped, processed_cnt = [], [], 0 |
|
0 commit comments