aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author苏向夜 <fu050409@163.com>2024-01-18 21:11:29 +0800
committer苏向夜 <fu050409@163.com>2024-01-18 21:11:29 +0800
commit3ebc89dfeb77cf90b1760fbb17780bf896681b7e (patch)
tree14c747be0556344a6f1819fb71cda0346a32b933 /src
parentd081893762555ee481720be2897c1950480d95b0 (diff)
downloadipm-3ebc89dfeb77cf90b1760fbb17780bf896681b7e.tar.gz
ipm-3ebc89dfeb77cf90b1760fbb17780bf896681b7e.zip
:recycle: refactor(const): refact const vars
Diffstat (limited to 'src')
-rw-r--r--src/ipm/__init__.py4
-rw-r--r--src/ipm/api.py6
-rw-r--r--src/ipm/const.py3
-rw-r--r--src/ipm/utils/loader.py4
4 files changed, 9 insertions, 8 deletions
diff --git a/src/ipm/__init__.py b/src/ipm/__init__.py
index 9ebcc2d..d72a4e9 100644
--- a/src/ipm/__init__.py
+++ b/src/ipm/__init__.py
@@ -1,8 +1,8 @@
-from .api import install, extract, build
+from .api import install, extract, build, uninstall, init, new
__author__ = "苏向夜 <fu050409@163.com>"
__organization__ = (
"Noctisynth",
"HydroRoll-Team",
)
-__all__ = ["install", "extract", "build"]
+__all__ = ["install", "extract", "build", "uninstall", "init", "new"]
diff --git a/src/ipm/api.py b/src/ipm/api.py
index 2cb6eee..ea55afb 100644
--- a/src/ipm/api.py
+++ b/src/ipm/api.py
@@ -3,7 +3,7 @@ from .typing import StrPath
from .utils import freeze, urlparser, loader
from .models.ipk import InfiniPackage, InfiniFrozenPackage
from .exceptions import FileTypeMismatch, TomlLoadFailed, FileNotFoundError
-from .const import INDEX, HOME
+from .const import INDEX, SRC_HOME
from .logging import info, success, warning, error
import toml
@@ -67,7 +67,7 @@ def extract(
def install(uri: str, index: str = "", echo: bool = False) -> None:
info("正在初始化 IPM 环境...", echo)
- HOME.mkdir(parents=True, exist_ok=True)
+ SRC_HOME.mkdir(parents=True, exist_ok=True)
index = index or INDEX
if uri.isalpha():
@@ -87,7 +87,7 @@ def install(uri: str, index: str = "", echo: bool = False) -> None:
if uri.endswith(".ipk"):
info("安装中...", echo)
- ipk = extract(Path(uri).resolve(), HOME, echo)
+ ipk = extract(Path(uri).resolve(), SRC_HOME, echo)
else:
raise FileTypeMismatch("文件类型与预期[.ipk]不匹配.")
diff --git a/src/ipm/const.py b/src/ipm/const.py
index d31b10a..439903a 100644
--- a/src/ipm/const.py
+++ b/src/ipm/const.py
@@ -5,7 +5,8 @@ DEBUG = False
# 初始化参数
INDEX = "https://ipm.hydroroll.team/index/"
-HOME = Path.home() / ".ipm" / "src"
+IPM_PATH = Path.home() / ".ipm"
+SRC_HOME = IPM_PATH / "src"
# 文本参数
ATTENSION = """# This file is @generated by IPM.
diff --git a/src/ipm/utils/loader.py b/src/ipm/utils/loader.py
index 41b19f9..6c1bf25 100644
--- a/src/ipm/utils/loader.py
+++ b/src/ipm/utils/loader.py
@@ -1,6 +1,6 @@
from pathlib import Path
from .freeze import extract_ipk
-from ..const import HOME
+from ..const import SRC_HOME
from ..models.ipk import InfiniPackage
import requests
@@ -22,6 +22,6 @@ def load(name: str, baseurl: str = "", filename: str = "") -> InfiniPackage:
hash_file.write(hash_bytes)
hash_file.close()
- ipk = extract_ipk(ipk_file, HOME)
+ ipk = extract_ipk(ipk_file, SRC_HOME)
temp_dir.cleanup()
return ipk