diff options
| author | Nick Brassel <[email protected]> | 2021-02-28 07:22:21 +1100 | 
|---|---|---|
| committer | Nick Brassel <[email protected]> | 2021-02-28 07:22:21 +1100 | 
| commit | 1a5f6b54aff179732e3f4f4eb79e47454f0a1eb5 (patch) | |
| tree | ebf645f55cb0442899c894765b1af4344fb734db /lib/python/qmk/cli/chibios/confmigrate.py | |
| parent | 804d5c1c5d59d9a12c1d793289ccbd59cb650ec2 (diff) | |
| parent | 624359b725c9bfe8176cf72cdc2c8bbb7513949f (diff) | |
| download | qmk_firmware-1a5f6b54aff179732e3f4f4eb79e47454f0a1eb5.tar.gz qmk_firmware-1a5f6b54aff179732e3f4f4eb79e47454f0a1eb5.zip | |
Diffstat (limited to 'lib/python/qmk/cli/chibios/confmigrate.py')
| -rw-r--r-- | lib/python/qmk/cli/chibios/confmigrate.py | 17 | 
1 files changed, 9 insertions, 8 deletions
| diff --git a/lib/python/qmk/cli/chibios/confmigrate.py b/lib/python/qmk/cli/chibios/confmigrate.py index b9cfda9614..89995931a4 100644 --- a/lib/python/qmk/cli/chibios/confmigrate.py +++ b/lib/python/qmk/cli/chibios/confmigrate.py @@ -32,7 +32,7 @@ file_header = """\  /*   * This file was auto-generated by: - *    `qmk chibios-confupdate -i {0} -r {1}` + *    `qmk chibios-confmigrate -i {0} -r {1}`   */  #pragma once @@ -40,7 +40,7 @@ file_header = """\  def collect_defines(filepath): -    with open(filepath, 'r') as f: +    with open(filepath, 'r', encoding='utf-8') as f:          content = f.read()          define_search = re.compile(r'(?m)^#\s*define\s+(?:.*\\\r?\n)*.*$', re.MULTILINE)          value_search = re.compile(r'^#\s*define\s+(?P<name>[a-zA-Z0-9_]+(\([^\)]*\))?)\s*(?P<value>.*)', re.DOTALL) @@ -111,6 +111,7 @@ def migrate_mcuconf_h(to_override, outfile):  @cli.argument('-r', '--reference', type=normpath, arg_only=True, help='Specify the reference file to compare against')  @cli.argument('-o', '--overwrite', arg_only=True, action='store_true', help='Overwrites the input file during migration.')  @cli.argument('-d', '--delete', arg_only=True, action='store_true', help='If the file has no overrides, migration will delete the input file.') [email protected]('-f', '--force', arg_only=True, action='store_true', help='Re-migrates an already migrated file, even if it doesn\'t detect a full ChibiOS config.')  @cli.subcommand('Generates a migrated ChibiOS configuration file, as a result of comparing the input against a reference')  def chibios_confmigrate(cli):      """Generates a usable ChibiOS replacement configuration file, based on a fully-defined conf and a reference config. @@ -142,20 +143,20 @@ def chibios_confmigrate(cli):          eprint('--------------------------------------') -        if "CHCONF_H" in input_defs["dict"] or "_CHCONF_H_" in input_defs["dict"]: +        if cli.args.input.name == "chconf.h" and ("CHCONF_H" in input_defs["dict"] or "_CHCONF_H_" in input_defs["dict"] or cli.args.force):              migrate_chconf_h(to_override, outfile=sys.stdout)              if cli.args.overwrite: -                with open(cli.args.input, "w") as out_file: +                with open(cli.args.input, "w", encoding='utf-8') as out_file:                      migrate_chconf_h(to_override, outfile=out_file) -        elif "HALCONF_H" in input_defs["dict"] or "_HALCONF_H_" in input_defs["dict"]: +        elif cli.args.input.name == "halconf.h" and ("HALCONF_H" in input_defs["dict"] or "_HALCONF_H_" in input_defs["dict"] or cli.args.force):              migrate_halconf_h(to_override, outfile=sys.stdout)              if cli.args.overwrite: -                with open(cli.args.input, "w") as out_file: +                with open(cli.args.input, "w", encoding='utf-8') as out_file:                      migrate_halconf_h(to_override, outfile=out_file) -        elif "MCUCONF_H" in input_defs["dict"] or "_MCUCONF_H_" in input_defs["dict"]: +        elif cli.args.input.name == "mcuconf.h" and ("MCUCONF_H" in input_defs["dict"] or "_MCUCONF_H_" in input_defs["dict"] or cli.args.force):              migrate_mcuconf_h(to_override, outfile=sys.stdout)              if cli.args.overwrite: -                with open(cli.args.input, "w") as out_file: +                with open(cli.args.input, "w", encoding='utf-8') as out_file:                      migrate_mcuconf_h(to_override, outfile=out_file) | 
