Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def kas_get_argparser():
"""
Creates an argparser for kas with all plugins.
"""
parser = argparse.ArgumentParser(description='kas - setup tool for '
'bitbake based project')
verstr = '%(prog)s {} (configuration format version {}, ' \
'earliest compatible version {})'.format(__version__, __file_version__,
__compatible_file_version__)
parser.add_argument('--version', action='version', version=verstr)
parser.add_argument('-d', '--debug',
action='store_true',
help='Enable debug logging')
subparser = parser.add_subparsers(help='sub command help', dest='cmd')
for ext_plugin in pkg_resources.iter_entry_points('kas.plugins'):
ext_plugin.load()
for plugin in getattr(kasplugin, 'plugins', []):
plugin_parser = subparser.add_parser(plugin.name, help=plugin.helpmsg)
setup_parser_common_args(plugin_parser)
plugin.setup_parser(plugin_parser)
'config file', filename)
try:
version_value = int(config['header']['version'])
except ValueError:
# Be compatible: version string '0.10' is equivalent to file version 1
# This check is already done in the config schema so here just set the
# right version
version_value = 1
if version_value < __compatible_file_version__ or \
version_value > __file_version__:
raise LoadConfigException('This version of kas is compatible with '
'version {} to {}, file has version {}'
.format(__compatible_file_version__,
__file_version__, version_value),
filename)
return config
logging.error('Config file validation Error:\n%s', error)
if validation_error:
raise LoadConfigException('Error(s) occured while validating the '
'config file', filename)
try:
version_value = int(config['header']['version'])
except ValueError:
# Be compatible: version string '0.10' is equivalent to file version 1
# This check is already done in the config schema so here just set the
# right version
version_value = 1
if version_value < __compatible_file_version__ or \
version_value > __file_version__:
raise LoadConfigException('This version of kas is compatible with '
'version {} to {}, file has version {}'
.format(__compatible_file_version__,
__file_version__, version_value),
filename)
return config