Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if 'parser_args' in subcmdmod.__dict__:
parser_args = subcmdmod.parser_args
else:
parser_args = dict()
# use module description, if no explicit description is available
if not 'description' in parser_args:
parser_args['description'] = subcmdmod.__doc__
# create subparser, use module suffix as cmd name
subparser = subparsers.add_parser(cmd_name, add_help=False, **parser_args)
# all subparser can report the version
helpers.parser_add_common_opt(
subparser, 'version',
version='duecredit %s %s\n\n%s' % (cmd_name, __version__,
_license_info()))
# our own custom help for all commands
helpers.parser_add_common_opt(subparser, 'help')
helpers.parser_add_common_opt(subparser, 'log_level')
# let module configure the parser
subcmdmod.setup_parser(subparser)
# logger for command
# configure 'run' function for this command
subparser.set_defaults(func=subcmdmod.run,
logger=logging.getLogger('duecredit.%s' % cmd))
# store short description for later
sdescr = getattr(subcmdmod, 'short_description',
parser_args['description'].split('\n')[0])
cmd_short_description.append((cmd_name, sdescr))
# create command summary
cmd_summary = []
for cd in cmd_short_description:
def setup_parser():
# setup cmdline args parser
# main parser
parser = argparse.ArgumentParser(
fromfile_prefix_chars='@',
# usage="%(prog)s ...",
description="""\
DueCredit simplifies citation of papers describing methods, software and data used by any given analysis script/pipeline.
""",
epilog='"Your Credit is Due"',
formatter_class=argparse.RawDescriptionHelpFormatter,
add_help=False
)
# common options
helpers.parser_add_common_opt(parser, 'help')
helpers.parser_add_common_opt(parser, 'log_level')
helpers.parser_add_common_opt(parser,
'version',
version='duecredit %s\n\n%s' % (__version__,
_license_info()))
if __debug__:
parser.add_argument(
'--dbg', action='store_true', dest='common_debug',
help="do not catch exceptions and show exception traceback")
# yoh: atm we only dump to console. Might adopt the same separation later on
# and for consistency will call it --verbose-level as well for now
# log-level is set via common_opts ATM
# parser.add_argument('--log-level',
# choices=('critical', 'error', 'warning', 'info', 'debug'),
# dest='common_log_level',
# main parser
parser = argparse.ArgumentParser(
fromfile_prefix_chars='@',
# usage="%(prog)s ...",
description="""\
DueCredit simplifies citation of papers describing methods, software and data used by any given analysis script/pipeline.
""",
epilog='"Your Credit is Due"',
formatter_class=argparse.RawDescriptionHelpFormatter,
add_help=False
)
# common options
helpers.parser_add_common_opt(parser, 'help')
helpers.parser_add_common_opt(parser, 'log_level')
helpers.parser_add_common_opt(parser,
'version',
version='duecredit %s\n\n%s' % (__version__,
_license_info()))
if __debug__:
parser.add_argument(
'--dbg', action='store_true', dest='common_debug',
help="do not catch exceptions and show exception traceback")
# yoh: atm we only dump to console. Might adopt the same separation later on
# and for consistency will call it --verbose-level as well for now
# log-level is set via common_opts ATM
# parser.add_argument('--log-level',
# choices=('critical', 'error', 'warning', 'info', 'debug'),
# dest='common_log_level',
# help="""level of verbosity in log files. By default
# everything, including debug messages is logged.""")
parser_args = subcmdmod.parser_args
else:
parser_args = dict()
# use module description, if no explicit description is available
if not 'description' in parser_args:
parser_args['description'] = subcmdmod.__doc__
# create subparser, use module suffix as cmd name
subparser = subparsers.add_parser(cmd_name, add_help=False, **parser_args)
# all subparser can report the version
helpers.parser_add_common_opt(
subparser, 'version',
version='duecredit %s %s\n\n%s' % (cmd_name, __version__,
_license_info()))
# our own custom help for all commands
helpers.parser_add_common_opt(subparser, 'help')
helpers.parser_add_common_opt(subparser, 'log_level')
# let module configure the parser
subcmdmod.setup_parser(subparser)
# logger for command
# configure 'run' function for this command
subparser.set_defaults(func=subcmdmod.run,
logger=logging.getLogger('duecredit.%s' % cmd))
# store short description for later
sdescr = getattr(subcmdmod, 'short_description',
parser_args['description'].split('\n')[0])
cmd_short_description.append((cmd_name, sdescr))
# create command summary
cmd_summary = []
for cd in cmd_short_description:
cmd_summary.append('%s\n%s\n\n' \
# setup cmdline args parser
# main parser
parser = argparse.ArgumentParser(
fromfile_prefix_chars='@',
# usage="%(prog)s ...",
description="""\
DueCredit simplifies citation of papers describing methods, software and data used by any given analysis script/pipeline.
""",
epilog='"Your Credit is Due"',
formatter_class=argparse.RawDescriptionHelpFormatter,
add_help=False
)
# common options
helpers.parser_add_common_opt(parser, 'help')
helpers.parser_add_common_opt(parser, 'log_level')
helpers.parser_add_common_opt(parser,
'version',
version='duecredit %s\n\n%s' % (__version__,
_license_info()))
if __debug__:
parser.add_argument(
'--dbg', action='store_true', dest='common_debug',
help="do not catch exceptions and show exception traceback")
# yoh: atm we only dump to console. Might adopt the same separation later on
# and for consistency will call it --verbose-level as well for now
# log-level is set via common_opts ATM
# parser.add_argument('--log-level',
# choices=('critical', 'error', 'warning', 'info', 'debug'),
# dest='common_log_level',
# help="""level of verbosity in log files. By default
subcmdmod = getattr(__import__('duecredit.cmdline',
globals(), locals(),
[cmd], 0),
cmd)
# deal with optional parser args
if 'parser_args' in subcmdmod.__dict__:
parser_args = subcmdmod.parser_args
else:
parser_args = dict()
# use module description, if no explicit description is available
if not 'description' in parser_args:
parser_args['description'] = subcmdmod.__doc__
# create subparser, use module suffix as cmd name
subparser = subparsers.add_parser(cmd_name, add_help=False, **parser_args)
# all subparser can report the version
helpers.parser_add_common_opt(
subparser, 'version',
version='duecredit %s %s\n\n%s' % (cmd_name, __version__,
_license_info()))
# our own custom help for all commands
helpers.parser_add_common_opt(subparser, 'help')
helpers.parser_add_common_opt(subparser, 'log_level')
# let module configure the parser
subcmdmod.setup_parser(subparser)
# logger for command
# configure 'run' function for this command
subparser.set_defaults(func=subcmdmod.run,
logger=logging.getLogger('duecredit.%s' % cmd))
# store short description for later
sdescr = getattr(subcmdmod, 'short_description',
parser_args['description'].split('\n')[0])