diff options
| author | Adam Janovsky | 2023-11-10 12:22:59 +0100 |
|---|---|---|
| committer | Adam Janovsky | 2023-11-10 12:22:59 +0100 |
| commit | 4a316ad7b5cb88c0015117525cf7fbb939b5ce5e (patch) | |
| tree | 14ffd89e7d720040abcbcdd9bf4bbfab3517992c /src/sec_certs/utils | |
| parent | a6aeca3067d90428229c5240563cc69f58805a92 (diff) | |
| download | sec-certs-4a316ad7b5cb88c0015117525cf7fbb939b5ce5e.tar.gz sec-certs-4a316ad7b5cb88c0015117525cf7fbb939b5ce5e.tar.zst sec-certs-4a316ad7b5cb88c0015117525cf7fbb939b5ce5e.zip | |
fix new ruff errors
Diffstat (limited to 'src/sec_certs/utils')
| -rw-r--r-- | src/sec_certs/utils/extract.py | 2 | ||||
| -rw-r--r-- | src/sec_certs/utils/helpers.py | 6 | ||||
| -rw-r--r-- | src/sec_certs/utils/pandas.py | 4 | ||||
| -rw-r--r-- | src/sec_certs/utils/pdf.py | 3 |
4 files changed, 9 insertions, 6 deletions
diff --git a/src/sec_certs/utils/extract.py b/src/sec_certs/utils/extract.py index 933db4b8..e6312b8d 100644 --- a/src/sec_certs/utils/extract.py +++ b/src/sec_certs/utils/extract.py @@ -353,7 +353,7 @@ def search_only_headers_bsi(filepath: Path): # noqa: C901 for m in re.finditer(rule_and_sep, whole_text): # check if previous rules had at least one match - if constants.TAG_CERT_ID not in items_found.keys(): + if constants.TAG_CERT_ID not in items_found: logger.error(f"ERROR: front page not found for file: {filepath}") match_groups = m.groups() diff --git a/src/sec_certs/utils/helpers.py b/src/sec_certs/utils/helpers.py index 596ecf62..c103a2d3 100644 --- a/src/sec_certs/utils/helpers.py +++ b/src/sec_certs/utils/helpers.py @@ -28,7 +28,11 @@ def download_file( time.sleep(delay) # See https://github.com/psf/requests/issues/3953 for header justification r = requests.get( - url, allow_redirects=True, timeout=constants.REQUEST_TIMEOUT, stream=True, headers={"Accept-Encoding": None} # type: ignore + url, + allow_redirects=True, + timeout=constants.REQUEST_TIMEOUT, + stream=True, + headers={"Accept-Encoding": None}, # type: ignore ) ctx: Any if show_progress_bar: diff --git a/src/sec_certs/utils/pandas.py b/src/sec_certs/utils/pandas.py index 5b0a668d..661b669c 100644 --- a/src/sec_certs/utils/pandas.py +++ b/src/sec_certs/utils/pandas.py @@ -141,7 +141,7 @@ def get_sar_level_from_set(sars: set[SAR], sar_family: str) -> int | None: Given a set of SARs and a family name, will return level of the seeked SAR from the set. """ family_sars_dict = {x.family: x for x in sars} if (sars and not pd.isnull(sars)) else {} - if sar_family not in family_sars_dict.keys(): + if sar_family not in family_sars_dict: return None return family_sars_dict[sar_family].level @@ -211,7 +211,7 @@ def compute_cve_correlations( tuples = list( zip(n_cves_corrs, n_cves_pvalues, worst_cve_corrs, worst_cve_pvalues, avg_cve_corrs, avg_cve_pvalues, supports) ) - dct = {family: correlations for family, correlations in zip(["eal"] + families, tuples)} + dct = dict(zip(["eal"] + families, tuples)) df_corr = pd.DataFrame.from_dict( dct, orient="index", diff --git a/src/sec_certs/utils/pdf.py b/src/sec_certs/utils/pdf.py index 7736b5d0..f2c2c58e 100644 --- a/src/sec_certs/utils/pdf.py +++ b/src/sec_certs/utils/pdf.py @@ -1,6 +1,5 @@ from __future__ import annotations -import glob import logging import subprocess from datetime import datetime, timedelta, timezone @@ -54,7 +53,7 @@ def ocr_pdf_file(pdf_path: Path) -> str: if ppm.returncode != 0: raise ValueError(f"pdftoppm failed: {ppm.returncode}") - for ppm_path in map(Path, glob.glob(str(tmppath / "image*.ppm"))): + for ppm_path in tmppath.rglob("image*.ppm"): base = ppm_path.with_suffix("") content = pytesseract.image_to_string(Image.open(ppm_path), lang="eng+deu+fra") |
