|
1 | 1 | """ |
2 | | - Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
3 | | -
|
4 | | - Permission is hereby granted, free of charge, to any person obtaining a copy of this |
5 | | - software and associated documentation files (the "Software"), to deal in the Software |
6 | | - without restriction, including without limitation the rights to use, copy, modify, |
7 | | - merge, publish, distribute, sublicense, and/or sell copies of the Software, and to |
8 | | - permit persons to whom the Software is furnished to do so. |
9 | | -
|
10 | | - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
11 | | - INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
12 | | - PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
13 | | - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
14 | | - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
15 | | - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 2 | +Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | +SPDX-License-Identifier: MIT-0 |
16 | 4 | """ |
17 | 5 | import sys |
18 | 6 | import argparse |
@@ -66,7 +54,8 @@ def __init__(self, schema=None): |
66 | 54 | self.__user_config_file = None |
67 | 55 | self.__project_config_file = None |
68 | 56 | self.file_args = {} |
69 | | - self.default_schema_file = Path(__file__).parent.joinpath('data/CfnLintCli/config/schema.json') |
| 57 | + self.default_schema_file = Path(__file__).parent.joinpath( |
| 58 | + 'data/CfnLintCli/config/schema.json') |
70 | 59 | with self.default_schema_file.open() as f: |
71 | 60 | self.default_schema = json.load(f) |
72 | 61 | self.schema = self.default_schema if not schema else schema |
@@ -190,7 +179,8 @@ def merge_config(self, user_config, project_config): |
190 | 179 | self.merge_config(user_config[key], project_config[key]) |
191 | 180 | else: |
192 | 181 | user_config[key] = project_config[key] |
193 | | - LOGGER.debug('Overriding User\'s key %s with Project\'s specific value %s.', key, project_config[key]) |
| 182 | + LOGGER.debug( |
| 183 | + 'Overriding User\'s key %s with Project\'s specific value %s.', key, project_config[key]) |
194 | 184 |
|
195 | 185 | # Project may have unique config we need to copy over too |
196 | 186 | # so that we can have user+project config available as one |
@@ -233,6 +223,7 @@ def _ensure_value(namespace, name, value): |
233 | 223 |
|
234 | 224 | class RuleConfigurationAction(argparse.Action): |
235 | 225 | """ Override the default Action """ |
| 226 | + |
236 | 227 | def __init__(self, option_strings, dest, nargs=None, const=None, default=None, |
237 | 228 | type=None, choices=None, required=False, help=None, metavar=None): # pylint: disable=W0622 |
238 | 229 | super(RuleConfigurationAction, self).__init__( |
@@ -290,12 +281,14 @@ def create_parser(self): |
290 | 281 | """Do first round of parsing parameters to set options""" |
291 | 282 | class ArgumentParser(argparse.ArgumentParser): |
292 | 283 | """ Override Argument Parser so we can control the exit code""" |
| 284 | + |
293 | 285 | def error(self, message): |
294 | 286 | self.print_help(sys.stderr) |
295 | 287 | self.exit(32, '%s: error: %s\n' % (self.prog, message)) |
296 | 288 |
|
297 | 289 | class ExtendAction(argparse.Action): |
298 | 290 | """Support argument types that are lists and can be specified multiple times.""" |
| 291 | + |
299 | 292 | def __call__(self, parser, namespace, values, option_string=None): |
300 | 293 | items = getattr(namespace, self.dest) |
301 | 294 | items = [] if items is None else items |
@@ -407,6 +400,7 @@ def __call__(self, parser, namespace, values, option_string=None): |
407 | 400 |
|
408 | 401 | class TemplateArgs(object): |
409 | 402 | """ Per Template Args """ |
| 403 | + |
410 | 404 | def __init__(self, template_args): |
411 | 405 | self.set_template_args(template_args) |
412 | 406 |
|
|
0 commit comments