Use Dict for storing patches (#304)

This commit is contained in:
Nikhil Badyal
2023-08-23 23:23:13 +05:30
committed by GitHub
parent ecd80dffda
commit 2ace3aa05a
10 changed files with 85 additions and 73 deletions
+8 -7
View File
@@ -6,6 +6,7 @@ from urllib.parse import urlparse
import requests
from loguru import logger
from src.app import APP
from src.config import RevancedConfig
from src.downloader.download import Downloader
from src.exceptions import DownloadFailure
@@ -15,17 +16,17 @@ from src.utils import handle_request_response, update_changelog
class Github(Downloader):
"""Files downloader."""
def latest_version(self, app: str, **kwargs: Dict[str, str]) -> Tuple[str, str]:
def latest_version(self, app: APP, **kwargs: Dict[str, str]) -> Tuple[str, str]:
"""Function to download files from GitHub repositories.
:param app: App to download
"""
logger.debug(f"Trying to download {app} from github")
if self.config.dry_run or app == "microg":
logger.debug(f"Trying to download {app.app_name} from github")
if self.config.dry_run:
logger.debug(
f"Skipping download of {app}. File already exists or dry running."
f"Skipping download of {app.app_name}. File already exists or dry running."
)
return app, f"local://{app}"
return app.app_name, f"local://{app.app_name}"
owner = str(kwargs["owner"])
repo_name = str(kwargs["name"])
repo_url = f"https://api.github.com/repos/{owner}/{repo_name}/releases/latest"
@@ -42,8 +43,8 @@ class Github(Downloader):
else:
download_url = response.json()["assets"][0]["browser_download_url"]
update_changelog(f"{owner}/{repo_name}", response.json())
self._download(download_url, file_name=app)
return app, download_url
self._download(download_url, file_name=app.app_name)
return app.app_name, download_url
@staticmethod
def _extract_repo_owner_and_tag(url: str) -> Tuple[str, str, str]: