feat: add re-exports
This commit is contained in:
parent
e8ee174146
commit
9cb18a26c4
@ -0,0 +1,6 @@
|
|||||||
|
# Re-exports
|
||||||
|
from vollerei.hsr.patcher import Patcher
|
||||||
|
from vollerei.hsr.launcher import Game, GameChannel
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["Patcher", "Game", "GameChannel"]
|
@ -0,0 +1,5 @@
|
|||||||
|
# Re-exports
|
||||||
|
from vollerei.hsr.launcher.game import Game, GameChannel
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["Game", "GameChannel"]
|
@ -1,12 +1,13 @@
|
|||||||
|
from io import BytesIO
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from zipfile import ZipFile
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import which, rmtree
|
from shutil import which, rmtree
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from vollerei.constants import utils_cache_path
|
from vollerei.paths import utils_cache_path
|
||||||
from vollerei.utils.git.exceptions import GitCloneError
|
from vollerei.utils.git.exceptions import GitCloneError
|
||||||
from vollerei.utils import download_and_extract
|
|
||||||
|
|
||||||
|
|
||||||
class Git:
|
class Git:
|
||||||
@ -36,7 +37,7 @@ class Git:
|
|||||||
"""
|
"""
|
||||||
Check if the url is a Gitea server
|
Check if the url is a Gitea server
|
||||||
"""
|
"""
|
||||||
rsp = requests.get(f"https://{netloc}/api/v1/meta")
|
rsp = requests.get(f"https://{netloc}/api/v1/version")
|
||||||
try:
|
try:
|
||||||
data: dict = rsp.json()
|
data: dict = rsp.json()
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
@ -61,7 +62,15 @@ class Git:
|
|||||||
return data[0]["sha"]
|
return data[0]["sha"]
|
||||||
|
|
||||||
def _download_and_extract_zip(self, url: str, path: Path) -> None:
|
def _download_and_extract_zip(self, url: str, path: Path) -> None:
|
||||||
download_and_extract(url, path)
|
# Copied code so it doesn't depend on vollerei.utils.download_and_extract
|
||||||
|
rsp = requests.get(url, stream=True)
|
||||||
|
rsp.raise_for_status()
|
||||||
|
with BytesIO() as f:
|
||||||
|
for chunk in rsp.iter_content(chunk_size=32768):
|
||||||
|
f.write(chunk)
|
||||||
|
f.seek(0)
|
||||||
|
with ZipFile(f) as z:
|
||||||
|
z.extractall(path)
|
||||||
path.joinpath(".git/PLEASE_INSTALL_GIT").touch()
|
path.joinpath(".git/PLEASE_INSTALL_GIT").touch()
|
||||||
|
|
||||||
def _clone(self, url: str, path: str = None) -> None:
|
def _clone(self, url: str, path: str = None) -> None:
|
||||||
@ -91,8 +100,7 @@ class Git:
|
|||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def get_latest_release_dl(self, url: str) -> list[str]:
|
def get_latest_release(self, url: str) -> dict:
|
||||||
dl = []
|
|
||||||
if Path(url).suffix == ".git":
|
if Path(url).suffix == ".git":
|
||||||
url = url[:-4]
|
url = url[:-4]
|
||||||
url_info = urlparse(url)
|
url_info = urlparse(url)
|
||||||
@ -103,11 +111,18 @@ class Git:
|
|||||||
)
|
)
|
||||||
rsp.raise_for_status()
|
rsp.raise_for_status()
|
||||||
data = rsp.json()
|
data = rsp.json()
|
||||||
for asset in data["assets"]:
|
return data
|
||||||
dl.append(asset["browser_download_url"])
|
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def get_latest_release_dl(self, data: dict) -> list[str]:
|
||||||
|
dl = []
|
||||||
|
if not data.get("assets"):
|
||||||
|
return dl
|
||||||
|
for asset in data["assets"]:
|
||||||
|
dl.append(asset["browser_download_url"])
|
||||||
|
return dl
|
||||||
|
|
||||||
def pull_or_clone(self, url: str, path: str = None) -> None:
|
def pull_or_clone(self, url: str, path: str = None) -> None:
|
||||||
"""
|
"""
|
||||||
Pulls or clones a git repository
|
Pulls or clones a git repository
|
||||||
|
@ -4,7 +4,7 @@ import requests
|
|||||||
from os import PathLike
|
from os import PathLike
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
from shutil import which
|
from shutil import which
|
||||||
from vollerei.constants import tools_cache_path
|
from vollerei.paths import tools_cache_path
|
||||||
from vollerei.utils.xdelta3.exceptions import (
|
from vollerei.utils.xdelta3.exceptions import (
|
||||||
Xdelta3NotInstalledError,
|
Xdelta3NotInstalledError,
|
||||||
Xdelta3PatchError,
|
Xdelta3PatchError,
|
||||||
|
Loading…
Reference in New Issue
Block a user