|
5 | 5 |
|
6 | 6 | try:
|
7 | 7 | project_dir = f"{os.sep}".join(os.path.abspath(__file__).split(os.sep)[:-2])
|
8 |
| - src_dir = f"{os.sep}".join([project_dir, 'src']) |
| 8 | + src_dir = f"{os.sep}".join([project_dir, "src"]) |
9 | 9 | sys.path.append(src_dir)
|
10 | 10 | except Exception as ex:
|
11 | 11 | print(f"Can not add project path to system path! Exiting!\nERROR: {ex}")
|
|
19 | 19 | # get and validate args
|
20 | 20 | parser = argparse.ArgumentParser()
|
21 | 21 | default_pattern = [
|
22 |
| - './config/**/*[.yml][.yaml]', |
23 |
| - './tests/config/**/*[.yml][.yaml]' |
| 22 | + "./config/**/*[.yml][.yaml]", |
| 23 | + "./tests/config/**/*[.yml][.yaml]" |
24 | 24 | ]
|
25 |
| -parser.add_argument('-a', '--add', type=str, default=None, |
26 |
| - help='Key name (tree dot notation) to add') |
27 |
| -parser.add_argument('-r', '--remove', type=str, default=None, |
28 |
| - help='The key name (tree dot notation) to remove. e.g. `work_model.paramters.foo`. ' + |
29 |
| - 'Required for a remove operation.') |
30 |
| -parser.add_argument('-v', '--value', type=str, default=None, |
31 |
| - help='The initial value for a key to add. e.g. `42`. Required for a add operation.') |
32 |
| -parser.add_argument('-t', '--type', type=str, default='str', |
33 |
| - help='Optional. The type of the initial value to set for a new key. Ex. `int`. Default `str`') |
34 |
| -parser.add_argument('-p', '--pattern', nargs='+', type=str, default=default_pattern, |
35 |
| - help='The list of patterns indicating which configuration files reside (path must be defined ' + |
36 |
| - 'as relative to the project directory). Defaults `' + str.join(' ', default_pattern) + '`' |
| 25 | +parser.add_argument("-a", "--add", type=str, default=None, |
| 26 | + help="Key name (tree dot notation) to add") |
| 27 | +parser.add_argument("-r", "--remove", type=str, default=None, |
| 28 | + help="The key name (tree dot notation) to remove. e.g. `work_model.paramters.foo`. " + |
| 29 | + "Required for a remove operation.") |
| 30 | +parser.add_argument("-v", "--value", type=str, default=None, |
| 31 | + help="The initial value for a key to add. e.g. `42`. Required for a add operation.") |
| 32 | +parser.add_argument("-t", "--type", type=str, default="str", |
| 33 | + help="Optional. The type of the initial value to set for a new key. Ex. `int`. Default `str`") |
| 34 | +parser.add_argument("-p", "--pattern", nargs="+", type=str, default=default_pattern, |
| 35 | + help="The list of patterns indicating which configuration files reside (path must be defined " + |
| 36 | + "as relative to the project directory). Defaults `" + str.join(' ', default_pattern) + '`' |
37 | 37 | )
|
38 | 38 | args = parser.parse_args()
|
39 | 39 |
|
40 | 40 | if not args.add and not args.remove:
|
41 |
| - raise ValueError('Missing either add (-a or --add xxx) or remove arg (-r or --remove xxx)') |
| 41 | + raise ValueError("Missing either add (-a or --add xxx) or remove arg (-r or --remove xxx)") |
42 | 42 | if args.add and args.remove:
|
43 |
| - raise ValueError('Cannot set both add and remove args') |
| 43 | + raise ValueError("Cannot set both add and remove args") |
44 | 44 | if args.add and not args.value:
|
45 |
| - raise ValueError('Missing value (-v or --vvv xxx)') |
| 45 | + raise ValueError("Missing value (-v or --vvv xxx)") |
46 | 46 |
|
47 | 47 | # init logger
|
48 |
| -upg_logger = get_logger('upgrade', level='debug') |
49 |
| -upg_logger.info('Script to bulk add or remove key to/from LBAF configuration files within the project') |
| 48 | +upg_logger = get_logger("upgrade", level="debug") |
| 49 | +upg_logger.info("Script to bulk add or remove key to/from LBAF configuration files within the project") |
50 | 50 | upg_logger.info(
|
51 |
| - 'NOTICE: Remember that the keys must be defined first at the schema level defined in ' \ |
52 |
| - 'the ConfigurationValidator class' |
| 51 | + "NOTICE: Remember that the keys must be defined first at the schema level defined in " \ |
| 52 | + "the ConfigurationValidator class" |
53 | 53 | )
|
54 | 54 |
|
55 | 55 | upgrader = ConfigurationUpgrader(logger=upg_logger)
|
|
0 commit comments