Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _parse(args):
with open(os.devnull, 'w') as null:
return parse_filter_arg(args, file=null)
def find_with_filter(args):
if getattr(args, 'job_id', None):
if args.filter or args.doc_filter:
raise ValueError("Can't provide both 'job-id' and filter arguments!")
else:
return args.job_id
project = get_project()
if hasattr(args, 'index'):
index = _read_index(project, args.index)
else:
index = None
f = parse_filter_arg(args.filter)
df = parse_filter_arg(args.doc_filter)
return get_project()._find_job_ids(index=index, filter=f, doc_filter=df)
def find_with_filter(args):
if getattr(args, 'job_id', None):
if args.filter or args.doc_filter:
raise ValueError("Can't provide both 'job-id' and filter arguments!")
else:
return args.job_id
project = get_project()
if hasattr(args, 'index'):
index = _read_index(project, args.index)
else:
index = None
f = parse_filter_arg(args.filter)
df = parse_filter_arg(args.doc_filter)
return get_project()._find_job_ids(index=index, filter=f, doc_filter=df)
def _select_jobs_from_args(self, args):
"Select jobs with the given command line arguments ('-j/-f/--doc-filter')."
if args.job_id and (args.filter or args.doc_filter):
raise ValueError(
"Cannot provide both -j/--job-id and -f/--filter or --doc-filter in combination.")
if args.job_id:
try:
return [self.open_job(id=job_id) for job_id in args.job_id]
except KeyError as error:
raise LookupError("Did not find job with id {}.".format(error))
else:
filter_ = parse_filter_arg(args.filter)
doc_filter = parse_filter_arg(args.doc_filter)
return JobsCursor(self, filter_, doc_filter)
def _select_jobs_from_args(self, args):
"Select jobs with the given command line arguments ('-j/-f/--doc-filter')."
if args.job_id and (args.filter or args.doc_filter):
raise ValueError(
"Cannot provide both -j/--job-id and -f/--filter or --doc-filter in combination.")
if args.job_id:
try:
return [self.open_job(id=job_id) for job_id in args.job_id]
except KeyError as error:
raise LookupError("Did not find job with id {}.".format(error))
else:
filter_ = parse_filter_arg(args.filter)
doc_filter = parse_filter_arg(args.doc_filter)
return JobsCursor(self, filter_, doc_filter)