diff options
| author | 2024-01-16 21:57:38 +0800 | |
|---|---|---|
| committer | 2024-01-16 21:57:38 +0800 | |
| commit | 6619c9d08b80eef5b3cc6a614a49e7ad6bfa03d8 (patch) | |
| tree | c152f6db2eec03b525da96d33d9300929bed40ca /src | |
| parent | 8a95ec7348dee1ba5d29ba539c56098a847a8193 (diff) | |
| download | ipm-6619c9d08b80eef5b3cc6a614a49e7ad6bfa03d8.tar.gz ipm-6619c9d08b80eef5b3cc6a614a49e7ad6bfa03d8.zip | |
:art: docs(annotation): improve code annotation
Diffstat (limited to 'src')
| -rw-r--r-- | src/ipm/__init__.py | 7 | ||||
| -rw-r--r-- | src/ipm/api.py | 6 | ||||
| -rw-r--r-- | src/ipm/utils/_freeze.py | 4 | ||||
| -rw-r--r-- | src/ipm/utils/freeze.py | 4 | ||||
| -rw-r--r-- | src/ipm/utils/hash.py | 2 | ||||
| -rw-r--r-- | src/ipm/utils/loader.py | 2 | ||||
| -rw-r--r-- | src/ipm/utils/urlparser.py | 4 |
7 files changed, 17 insertions, 12 deletions
diff --git a/src/ipm/__init__.py b/src/ipm/__init__.py index 061d700..9ebcc2d 100644 --- a/src/ipm/__init__.py +++ b/src/ipm/__init__.py @@ -1 +1,8 @@ +from .api import install, extract, build + __author__ = "苏向夜 <fu050409@163.com>" +__organization__ = ( + "Noctisynth", + "HydroRoll-Team", +) +__all__ = ["install", "extract", "build"] diff --git a/src/ipm/api.py b/src/ipm/api.py index 784f9d6..50f1a32 100644 --- a/src/ipm/api.py +++ b/src/ipm/api.py @@ -8,18 +8,18 @@ from .const import INDEX, HOME import os -def build(source_path: StrPath): +def build(source_path: StrPath) -> None: freeze.build_ipk(InfiniPackage(source_path)) -def extract(source_path: StrPath, dist_path: StrPath | None = None): +def extract(source_path: StrPath, dist_path: StrPath | None = None) -> None: dist_path = ( Path(dist_path).resolve() if dist_path else Path(source_path).resolve().parent ) freeze.extract_ipk(source_path, dist_path) -def install(uri: str, index: str = ""): +def install(uri: str, index: str = "") -> None: HOME.mkdir(parents=True, exist_ok=True) index = index if index else INDEX diff --git a/src/ipm/utils/_freeze.py b/src/ipm/utils/_freeze.py index d6d5791..b209915 100644 --- a/src/ipm/utils/_freeze.py +++ b/src/ipm/utils/_freeze.py @@ -4,7 +4,7 @@ import tarfile import shutil -def create_tar_gz(source_folder: str, output_filepath: str): +def create_tar_gz(source_folder: str, output_filepath: str) -> None: shutil.move( shutil.make_archive(output_filepath + ".build", "gztar", source_folder), output_filepath, @@ -12,6 +12,6 @@ def create_tar_gz(source_folder: str, output_filepath: str): ) -def extract_tar_gz(input_filename: str, output_folder: str): +def extract_tar_gz(input_filename: str, output_folder: str) -> None: with tarfile.open(input_filename, "r:gz") as tar: tar.extractall(output_folder) diff --git a/src/ipm/utils/freeze.py b/src/ipm/utils/freeze.py index 6fd454f..f03078f 100644 --- a/src/ipm/utils/freeze.py +++ b/src/ipm/utils/freeze.py @@ -9,9 +9,7 @@ import tempfile import shutil -def build_ipk( - ipk: InfiniPackage, -) -> InfiniFrozenPackage: +def build_ipk(ipk: InfiniPackage) -> InfiniFrozenPackage: build_dir = ipk.source_path / ".build" src_path = ipk.source_path / "src" dist_path = ipk.source_path / "dist" diff --git a/src/ipm/utils/hash.py b/src/ipm/utils/hash.py index efd66ca..54d5b13 100644 --- a/src/ipm/utils/hash.py +++ b/src/ipm/utils/hash.py @@ -10,6 +10,6 @@ def hash_ifp(lfp_path: str | Path, block_size=65536) -> bytes: return sha256.digest() -def verify_ifp(lfp_path, expected_hash): +def verify_ifp(lfp_path, expected_hash) -> bool: actual_hash = hash_ifp(lfp_path) return actual_hash == expected_hash diff --git a/src/ipm/utils/loader.py b/src/ipm/utils/loader.py index d74d85c..ccbf47a 100644 --- a/src/ipm/utils/loader.py +++ b/src/ipm/utils/loader.py @@ -6,7 +6,7 @@ import requests import tempfile -def load(name: str, baseurl: str = "", filename: str = ""): +def load(name: str, baseurl: str = "", filename: str = "") -> None: ipk_bytes = requests.get(baseurl.rstrip("/") + "/" + filename).content hash_bytes = requests.get(baseurl.rstrip("/") + "/" + filename + ".hash").content diff --git a/src/ipm/utils/urlparser.py b/src/ipm/utils/urlparser.py index 89bc064..68aa1e9 100644 --- a/src/ipm/utils/urlparser.py +++ b/src/ipm/utils/urlparser.py @@ -1,6 +1,6 @@ from urllib.parse import urlparse -def is_valid_url(uri: str): +def is_valid_url(uri: str) -> bool: parsed_uri = urlparse(uri) - return parsed_uri.scheme and parsed_uri.netloc + return bool(parsed_uri.scheme and parsed_uri.netloc) |
