INNER CODE UNIT · Python

_hook

pairinteraction/pairinteraction · src/pairinteraction/cli.py:223

                def _hook(blocks: int, block_size: int, total_size: int, _msg: str = msg) -> None:
                    if total_size > 0:
                        pct = min(100, int(blocks * block_size * 100 / total_size))
                        print(f"\r{_msg} {pct:3}%", end="", flush=True)

                urlretrieve(url, tmp, reporthook=_hook)  # noqa: S310
            finally:
                print()

            with ZipFile(tmp) as z:
                roots = {Path(n).parts[0] for n in z.namelist() if Path(n).parts}
                root = roots.pop() if len(roots) == 1 else None

                if not root or f"{root}/" not in z.namelist():
                    raise ValueError("The ZIP archive must contain exactly one top-level folder.")  # noqa: TRY301
                species, version_str = root.rsplit("_v", 1)
                version = Version(version_str)  # validate version
                compatible_major = COMPATIBLE_DATABASE_VERSION_MAJOR

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…