Fix generated file output while target exists (#12062)

This commit is contained in:
Joel Challis 2021-02-28 20:19:07 +00:00 committed by GitHub
parent 1a7f2c8f45
commit 59c7deab09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 9 deletions

View File

@ -47,7 +47,7 @@ def c2json(cli):
if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.name + '.bak')
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(json.dumps(keymap_json, cls=InfoJSONEncoder))
if not cli.args.quiet:

View File

@ -82,7 +82,7 @@ def generate_config_h(cli):
"""
# Determine our keyboard(s)
if not cli.config.generate_config_h.keyboard:
cli.log.error('Missing paramater: --keyboard')
cli.log.error('Missing parameter: --keyboard')
cli.subcommands['info'].print_help()
return False
@ -142,7 +142,7 @@ def generate_config_h(cli):
if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.name + '.bak')
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(config_h)
if not cli.args.quiet:

View File

@ -25,7 +25,7 @@ def generate_layouts(cli):
"""
# Determine our keyboard(s)
if not cli.config.generate_layouts.keyboard:
cli.log.error('Missing paramater: --keyboard')
cli.log.error('Missing parameter: --keyboard')
cli.subcommands['info'].print_help()
return False
@ -92,7 +92,7 @@ def generate_layouts(cli):
if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.name + '.bak')
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(layouts_h)
if not cli.args.quiet:

View File

@ -70,7 +70,7 @@ static const int table_scale = 256 / sizeof(rgblight_effect_breathe_table);
if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.name + '.bak')
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(table_template)
if not cli.args.quiet:

View File

@ -44,7 +44,7 @@ def generate_rules_mk(cli):
"""Generates a rules.mk file from info.json.
"""
if not cli.config.generate_rules_mk.keyboard:
cli.log.error('Missing paramater: --keyboard')
cli.log.error('Missing parameter: --keyboard')
cli.subcommands['info'].print_help()
return False
@ -79,7 +79,7 @@ def generate_rules_mk(cli):
if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.name + '.bak')
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(rules_mk)
if cli.args.quiet:

View File

@ -37,7 +37,7 @@ def json2c(cli):
if cli.args.output:
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.name + '.bak')
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(keymap_c)
if not cli.args.quiet: