Skip to content

Commit

Permalink
♻️ refactor(const): refact const vars
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 committed Jan 18, 2024
1 parent d081893 commit 3ebc89d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/ipm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .api import install, extract, build
from .api import install, extract, build, uninstall, init, new

__author__ = "苏向夜 <[email protected]>"
__organization__ = (
"Noctisynth",
"HydroRoll-Team",
)
__all__ = ["install", "extract", "build"]
__all__ = ["install", "extract", "build", "uninstall", "init", "new"]
6 changes: 3 additions & 3 deletions src/ipm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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
Expand Down Expand Up @@ -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():
Expand All @@ -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]不匹配.")

Expand Down
3 changes: 2 additions & 1 deletion src/ipm/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

# 初始化参数
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.
Expand Down
4 changes: 2 additions & 2 deletions src/ipm/utils/loader.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 3ebc89d

Please sign in to comment.