INNER CODE UNIT · Python
pct
pairinteraction/pairinteraction · src/pairinteraction/cli.py:225
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
if version.major != compatible_major:
raise ValueError( # noqa: TRY301