Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
args.__dict__[client.type] = True
command = CustomCommand(args)
# filter repositories by specified client types
clients = find_repositories(command.paths, nested=command.nested)
clients = [c for c in clients if c.type in args and args.__dict__[c.type]]
if command.output_repos:
output_repositories(clients)
jobs = generate_jobs(clients, command)
results = execute_jobs(
jobs, show_progress=True, number_of_workers=args.workers,
debug_jobs=args.debug)
output_results(results, hide_empty=args.hide_empty)
any_error = any(r['returncode'] for r in results)
return 1 if any_error else 0
# check if at least one repo was found in the client directory
basename = None
for result in results:
result['path'] = get_relative_path_of_result(result)
if result['path'] == '.':
basename = os.path.basename(os.path.abspath(result['client'].path))
# in that case prefix all relative paths with the client directory basename
if basename is not None:
for result in results:
if result['path'] == '.':
result['path'] = basename
else:
result['path'] = os.path.join(basename, result['path'])
print('repositories:')
output_results(results, output_handler=output_export_data)
output_results(results, output_handler=output_error_information)
any_error = any(r['returncode'] for r in results)
return 1 if any_error else 0
args = parser.parse_args(args)
try:
repos = get_repositories(args.input)
except RuntimeError as e:
print(ansi('redf') + str(e) + ansi('reset'), file=sys.stderr)
return 1
jobs = generate_jobs(repos, args)
add_dependencies(jobs)
if args.repos:
output_repositories([job['client'] for job in jobs])
results = execute_jobs(
jobs, show_progress=True, number_of_workers=args.workers,
debug_jobs=args.debug)
output_results(results)
any_error = any(r['returncode'] for r in results)
return 1 if any_error else 0
def simple_main(parser, command_class, args=None):
add_common_arguments(parser)
args = parser.parse_args(args)
command = command_class(args)
clients = find_repositories(command.paths, nested=command.nested)
if command.output_repos:
output_repositories(clients)
jobs = generate_jobs(clients, command)
results = execute_jobs(
jobs, show_progress=True, number_of_workers=args.workers,
debug_jobs=args.debug)
output_results(results, hide_empty=args.hide_empty)
any_error = any(r['returncode'] for r in results)
return 1 if any_error else 0