Download tasks/codeql_python_benchmark51_v2/pyvul-89a9ff0f9cf4f2f4cc91/patch.diff from Benchanything/checkerbench: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-89a9ff0f9cf4f2f4cc91/patch.diff
- Command line
-
hf download hf://datasets/Benchanything/checkerbench/tasks/codeql_python_benchmark51_v2/pyvul-89a9ff0f9cf4f2f4cc91/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_python_benchmark51_v2/pyvul-89a9ff0f9cf4f2f4cc91/patch.diff
1.22 kB
| diff --git a/mangadex_downloader/cli/validator.py b/mangadex_downloader/cli/validator.py | |
| index dd3f636..deb4f81 100644 | |
| --- a/mangadex_downloader/cli/validator.py | |
| +++ b/mangadex_downloader/cli/validator.py | |
| def _validate(url): | |
| raise argparse.ArgumentTypeError(str(e)) | |
| return _url | |
| -def validate_url(url): | |
| - if os.path.exists(url): | |
| - with open(url, 'r') as opener: | |
| - content = opener.read() | |
| - else: | |
| - content = url | |
| +def _try_read(path): | |
| + if not os.path.exists(path): | |
| + return None | |
| + | |
| + with open(path, 'r') as o: | |
| + return o.read() | |
| +def validate_url(url): | |
| urls = [] | |
| - for _url in content.splitlines(): | |
| + for _url in url.splitlines(): | |
| if not _url: | |
| continue | |
| def validate(parser, args): | |
| elif not os.path.exists(file_path): | |
| parser.error(f"File \"{file_path}\" is not exist") | |
| else: | |
| - file_path = urls | |
| + file_content = _try_read(urls) | |
| + file_path = file_content if file_content is not None else urls | |
| try: | |
| args.URL = validate_url(file_path) | |
| except argparse.ArgumentTypeError as e: | |