Changeset View
Changeset View
Standalone View
Standalone View
swh/scanner/cli.py
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | for pattern in patterns: | ||||
dirpath = PosixPath(path) | dirpath = PosixPath(path) | ||||
if root_path not in dirpath.parents: | if root_path not in dirpath.parents: | ||||
error_msg = ( | error_msg = ( | ||||
f'The path "{dirpath}" is not a subdirectory or relative ' | f'The path "{dirpath}" is not a subdirectory or relative ' | ||||
f'to the root directory path: "{root_path}"' | f'to the root directory path: "{root_path}"' | ||||
) | ) | ||||
raise InvalidDirectoryPath(error_msg) | raise InvalidDirectoryPath(error_msg) | ||||
if glob.glob(pattern): | |||||
regex = fnmatch.translate(str(PosixPath(pattern))) | regex = fnmatch.translate(str(PosixPath(pattern))) | ||||
yield re.compile(regex) | yield re.compile(regex) | ||||
@scanner.command(name="scan") | @scanner.command(name="scan") | ||||
@click.argument("root_path", required=True, type=click.Path(exists=True)) | @click.argument("root_path", required=True, type=click.Path(exists=True)) | ||||
@click.option( | @click.option( | ||||
"-u", | "-u", | ||||
"--api-url", | "--api-url", | ||||
default="https://archive.softwareheritage.org/api/1", | default="https://archive.softwareheritage.org/api/1", | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |