Skip to content

Commit ef1b117

Browse files
committed
Renamed cli.config_path to .config_filepath, used log.tip()
1 parent a5ff0a7 commit ef1b117

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

translate-messages/src/translate_messages/lib/init.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ def cli(caller_file):
77
return cli
88

99
def config_file(cli):
10-
if os.path.exists(cli.config_path):
10+
if os.path.exists(cli.config_filepath):
1111
if cli.config.force:
12-
log.info(f'Overwriting existing config at {cli.config_path}...')
12+
log.info(f'Overwriting existing config at {cli.config_filepath}...')
1313
else:
14-
log.warn(f'Config already exists at {cli.config_path}.Skipping --init.')
15-
log.tip('TIP: Pass --force to overwrite.')
14+
log.warn(f'Config already exists at {cli.config_filepath}. Skipping --init.')
15+
log.tip('Pass --force to overwrite.')
1616
return
1717
cli.config_filename = '.translate-msgs.config.json'
18-
cli.config_path = os.path.join(cli.project_root, cli.config_filename)
18+
cli.config_filepath = os.path.join(cli.project_root, cli.config_filename)
1919
try:
2020
jsd_url = f'{cli.urls.jsdelivr}/{cli.name}/{cli.config_filename}'
2121
resp = requests.get(jsd_url, timeout=5)
2222
resp.raise_for_status()
2323
cli.file_config = resp.json()
2424
except (requests.RequestException, ValueError) as err:
2525
raise RuntimeError(f"Failed to fetch default config from {jsd_url}: {err}")
26-
data.json.write(cli.file_config, cli.config_path)
27-
log.success(f'Default config created at {cli.config_path}')
26+
data.json.write(cli.file_config, cli.config_filepath)
27+
log.success(f'Default config created at {cli.config_filepath}')
2828

2929
def locales_dir(target_dir):
3030
for root, dirs, _ in os.walk(os.getcwd()):

translate-messages/src/translate_messages/lib/settings.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ def load(cli, caller_file):
5353
f'.{cli.name}.config.json', f'{cli.name}.config.json'
5454
]
5555
for filename in possile_config_filenames:
56-
cli.config_path = path.join(cli.project_root, filename)
57-
if path.exists(cli.config_path):
58-
cli.config = data.sns.from_dict(data.json.read(cli.config_path))
56+
cli.config_filepath = path.join(cli.project_root, filename)
57+
if path.exists(cli.config_filepath):
58+
cli.config = data.sns.from_dict(data.json.read(cli.config_filepath))
5959
cli.config_filename = filename
6060
break
6161

@@ -70,7 +70,7 @@ def load(cli, caller_file):
7070
for forbidden in ('default_val', 'parser'): # remove custom attrs
7171
kwargs.pop(forbidden, None)
7272
argp.add_argument(*args, **kwargs)
73-
cli.config.__dict__.update({ key:val for key,val in vars(argp.parse_args()).items() if val is not None})
73+
cli.config.__dict__.update({ key:val for key,val in vars(argp.parse_args()).items() if val is not None })
7474

7575
# Init cli.config vals
7676
for name, ctrl in vars(controls).items():
@@ -83,5 +83,5 @@ def load(cli, caller_file):
8383
val = ctrl.default_val
8484
setattr(cli.config, name, val)
8585

86-
if cli.config.exclude_langs:
86+
if cli.config.exclude_langs: # trim cli.config.target_langs
8787
cli.config.target_langs = [lang for lang in cli.config.target_langs if lang not in cli.config.exclude_langs]

0 commit comments

Comments
 (0)