Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parser_competitions_list_optional.add_argument('-p',
'--page',
dest='page',
default=1,
required=False,
help=Help.param_page)
parser_competitions_list_optional.add_argument('-s',
'--search',
dest='search',
required=False,
help=Help.param_search)
parser_competitions_list_optional.add_argument('-v',
'--csv',
dest='csv_display',
action='store_true',
help=Help.param_csv)
parser_competitions_list._action_groups.append(
parser_competitions_list_optional)
parser_competitions_list.set_defaults(func=api.competitions_list_cli)
# Competitions list files
parser_competitions_files = subparsers_competitions.add_parser(
'files',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_competitions_files)
parser_competitions_files_optional = parser_competitions_files._action_groups.pop(
)
parser_competitions_files_optional.add_argument(
'competition', nargs='?', default=None, help=Help.param_competition)
parser_competitions_files_optional.add_argument('-c',
'--competition',
dest='competition_opt',
'set',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_config_set)
parser_config_set._action_groups.pop()
parser_config_set_required = parser_config_set.add_argument_group(
'required arguments')
parser_config_set_required.add_argument('-n',
'--name',
dest='name',
required=True,
help=Help.param_config_name)
parser_config_set_required.add_argument('-v',
'--value',
dest='value',
required=True,
help=Help.param_config_value)
parser_config_set.set_defaults(func=api.set_config_value)
parser_config_unset = subparsers_config.add_parser(
'unset',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_config_unset)
parser_config_unset._action_groups.pop()
parser_config_unset_required = parser_config_unset.add_argument_group(
'required arguments')
parser_config_unset_required.add_argument('-n',
'--name',
dest='name',
required=True,
help=Help.param_config_name)
parser_config_unset.set_defaults(func=api.unset_config_value)
dest='convert_to_csv',
action='store_false',
help=Help.param_keep_tabular)
parser_datasets_version_optional.add_argument(
'-r',
'--dir-mode',
dest='dir_mode',
choices=['skip', 'zip', 'tar'],
default='skip',
help=Help.param_dir_mode)
parser_datasets_version_optional.add_argument(
'-d',
'--delete-old-versions',
dest='delete_old_versions',
action='store_true',
help=Help.param_delete_old_version)
parser_datasets_version._action_groups.append(
parser_datasets_version_optional)
parser_datasets_version.set_defaults(func=api.dataset_create_version_cli)
# Datasets init
parser_datasets_init = subparsers_datasets.add_parser(
'init',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_datasets_init)
parser_datasets_init_optional = parser_datasets_init._action_groups.pop()
parser_datasets_init_optional.add_argument('-p',
'--path',
dest='folder',
required=False,
help=Help.param_dataset_upfile)
parser_datasets_init._action_groups.append(parser_datasets_init_optional)
else:
parser_competitions = subparsers.add_parser(
'competitions',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.group_competitions,
aliases=['c'])
subparsers_competitions = parser_competitions.add_subparsers(
title='commands', dest='command')
subparsers_competitions.required = True
subparsers_competitions.choices = Help.competitions_choices
# Competitions list
parser_competitions_list = subparsers_competitions.add_parser(
'list',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_competitions_list)
parser_competitions_list_optional = parser_competitions_list._action_groups.pop(
)
parser_competitions_list_optional.add_argument(
'--group',
dest='group',
required=False,
help=Help.param_competition_group)
parser_competitions_list_optional.add_argument(
'--category',
dest='category',
required=False,
help=Help.param_competition_category)
parser_competitions_list_optional.add_argument(
'--sort-by',
dest='sort_by',
required=False,
def parse_kernels(subparsers):
if six.PY2:
parser_kernels = subparsers.add_parser(
'kernels',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.group_kernels)
else:
parser_kernels = subparsers.add_parser(
'kernels',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.group_kernels,
aliases=['k'])
subparsers_kernels = parser_kernels.add_subparsers(title='commands',
dest='command')
subparsers_kernels.required = True
subparsers_kernels.choices = Help.kernels_choices
# Kernels list/search
parser_kernels_list = subparsers_kernels.add_parser(
'list',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_kernels_list)
parser_kernels_list_optional = parser_kernels_list._action_groups.pop()
parser_kernels_list_optional.add_argument('-m',
'--mine',
dest='mine',
action='store_true',
help=Help.param_mine)
parser_kernels_list_optional.add_argument('-p',
'--page',
dest='page',
default=1,
help=Help.group_config)
subparsers_config = parser_config.add_subparsers(title='commands',
dest='command')
subparsers_config.required = True
subparsers_config.choices = Help.config_choices
parser_config_view = subparsers_config.add_parser(
'view',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_config_view)
parser_config_view.set_defaults(func=api.print_config_values)
parser_config_set = subparsers_config.add_parser(
'set',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_config_set)
parser_config_set._action_groups.pop()
parser_config_set_required = parser_config_set.add_argument_group(
'required arguments')
parser_config_set_required.add_argument('-n',
'--name',
dest='name',
required=True,
help=Help.param_config_name)
parser_config_set_required.add_argument('-v',
'--value',
dest='value',
required=True,
help=Help.param_config_value)
parser_config_set.set_defaults(func=api.set_config_value)
parser_config_unset = subparsers_config.add_parser(
# Datasets update
parser_datasets_version = subparsers_datasets.add_parser(
'version',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_datasets_new_version)
parser_datasets_version_optional = parser_datasets_version._action_groups.pop(
)
parser_datasets_version_required = parser_datasets_version.add_argument_group(
'required arguments')
parser_datasets_version_required.add_argument(
'-m',
'--message',
dest='version_notes',
required=True,
help=Help.param_dataset_version_notes)
parser_datasets_version_optional.add_argument(
'-p',
'--path',
dest='folder',
required=False,
help=Help.param_dataset_upfile)
parser_datasets_version_optional.add_argument('-q',
'--quiet',
dest='quiet',
action='store_true',
help=Help.param_quiet)
parser_datasets_version_optional.add_argument('-t',
'--keep-tabular',
dest='convert_to_csv',
action='store_false',
help=Help.param_keep_tabular)
def main():
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-v',
'--version',
action='version',
version='Kaggle API ' + KaggleApi.__version__)
subparsers = parser.add_subparsers(title='commands',
help=Help.kaggle,
dest='command')
subparsers.required = True
subparsers.choices = Help.kaggle_choices
parse_competitions(subparsers)
parse_datasets(subparsers)
parse_kernels(subparsers)
parse_config(subparsers)
args = parser.parse_args()
command_args = {}
command_args.update(vars(args))
del command_args['func']
del command_args['command']
error = False
try:
out = args.func(**command_args)
except ApiException as e:
def parse_config(subparsers):
parser_config = subparsers.add_parser(
'config',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.group_config)
subparsers_config = parser_config.add_subparsers(title='commands',
dest='command')
subparsers_config.required = True
subparsers_config.choices = Help.config_choices
parser_config_view = subparsers_config.add_parser(
'view',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_config_view)
parser_config_view.set_defaults(func=api.print_config_values)
parser_config_set = subparsers_config.add_parser(
'set',
formatter_class=argparse.RawTextHelpFormatter,
help=Help.command_config_set)
parser_config_set._action_groups.pop()
parser_config_set_required = parser_config_set.add_argument_group(
'required arguments')
parser_config_set_required.add_argument('-n',
'--name',
parser_datasets_version_optional.add_argument(
'-p',
'--path',
dest='folder',
required=False,
help=Help.param_dataset_upfile)
parser_datasets_version_optional.add_argument('-q',
'--quiet',
dest='quiet',
action='store_true',
help=Help.param_quiet)
parser_datasets_version_optional.add_argument('-t',
'--keep-tabular',
dest='convert_to_csv',
action='store_false',
help=Help.param_keep_tabular)
parser_datasets_version_optional.add_argument(
'-r',
'--dir-mode',
dest='dir_mode',
choices=['skip', 'zip', 'tar'],
default='skip',
help=Help.param_dir_mode)
parser_datasets_version_optional.add_argument(
'-d',
'--delete-old-versions',
dest='delete_old_versions',
action='store_true',
help=Help.param_delete_old_version)
parser_datasets_version._action_groups.append(
parser_datasets_version_optional)
parser_datasets_version.set_defaults(func=api.dataset_create_version_cli)