mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🌱 Updated linter
This commit is contained in:
committed by
Nikhil Badyal
parent
e533912ccf
commit
1366c6c663
@@ -23,7 +23,7 @@ repos:
|
|||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: 'v0.0.288'
|
rev: 'v0.0.289'
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args:
|
args:
|
||||||
|
|||||||
+2
-43
@@ -1,48 +1,6 @@
|
|||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
line-length = 120
|
line-length = 120
|
||||||
select = [
|
select = [ "ALL"]
|
||||||
"F", # pyflakes
|
|
||||||
"E", # pycodestyle Error
|
|
||||||
"W", # pycodestyle Warning
|
|
||||||
"C90", #mccabe
|
|
||||||
"I", #isort
|
|
||||||
"N", #isort
|
|
||||||
"D", #isort
|
|
||||||
"UP", # pyupgrade
|
|
||||||
"ANN", # flake8-annotations
|
|
||||||
"ASYNC", # flake8-async
|
|
||||||
"S", # flake8-bandit
|
|
||||||
"BLE", # flake8-blind-except
|
|
||||||
"FBT", #flake8-boolean-trap
|
|
||||||
"B", #flake8-bugbear
|
|
||||||
"A" , #flake8-builtins
|
|
||||||
"C4" , #flake8-comprehensions
|
|
||||||
"DTZ" , #flake8-datetimez
|
|
||||||
"T10" , #flake8-debugger
|
|
||||||
"EM" , #flake8-errmsg
|
|
||||||
"EXE" , #flake8-executable
|
|
||||||
"ISC" , #flake8-implicit-str-concat
|
|
||||||
"ICN" , #flake8-import-conventions
|
|
||||||
"G" , #flake8-logging-format
|
|
||||||
"INP" , #flake8-no-pep420
|
|
||||||
"PIE" , #flake8-pie
|
|
||||||
"PYI" , #flake8-pyi
|
|
||||||
"RSE" , #flake8-raise
|
|
||||||
"RET" , #flake8-return
|
|
||||||
"SLF" , #flake8-self
|
|
||||||
"SIM" , #flake8-simplify
|
|
||||||
"TCH" , #flake8-type-checking
|
|
||||||
"INT" , #flake8-gettext
|
|
||||||
"ARG" , #flake8-unused-arguments
|
|
||||||
"PTH" , #flake8-use-pathlib
|
|
||||||
"ERA" , #eradicate
|
|
||||||
"PGH" , #pygrep-hooks
|
|
||||||
"PL" , #Pylint
|
|
||||||
"TRY" , #tryceratops
|
|
||||||
"FLY" , #flynt
|
|
||||||
"PERF" , #flynt
|
|
||||||
"RUF" , #Ruff-specific rules
|
|
||||||
]
|
|
||||||
ignore = [
|
ignore = [
|
||||||
"D401",
|
"D401",
|
||||||
"ANN401",
|
"ANN401",
|
||||||
@@ -55,6 +13,7 @@ ignore = [
|
|||||||
"UP004", #useless-object-inheritance
|
"UP004", #useless-object-inheritance
|
||||||
"PLR0911" #too many returns
|
"PLR0911" #too many returns
|
||||||
]
|
]
|
||||||
|
target-version = "py311"
|
||||||
fix = true
|
fix = true
|
||||||
show-fixes = true
|
show-fixes = true
|
||||||
[tool.ruff.pydocstyle]
|
[tool.ruff.pydocstyle]
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"""Status check."""
|
"""Status check."""
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup, Tag
|
from bs4 import BeautifulSoup, Tag
|
||||||
@@ -53,7 +52,7 @@ def apkcombo_scrapper(package_name: str) -> str:
|
|||||||
raise APKComboIconScrapError(url=apkcombo_url) from e
|
raise APKComboIconScrapError(url=apkcombo_url) from e
|
||||||
|
|
||||||
|
|
||||||
def bigger_image(possible_links: List[str]) -> str:
|
def bigger_image(possible_links: list[str]) -> str:
|
||||||
"""Select image with higher dimension."""
|
"""Select image with higher dimension."""
|
||||||
higher_dimension_url = ""
|
higher_dimension_url = ""
|
||||||
max_dimension = 0
|
max_dimension = 0
|
||||||
@@ -125,7 +124,7 @@ def gplay_icon_scrapper(package_name: str) -> str:
|
|||||||
return str(
|
return str(
|
||||||
gplay_app(
|
gplay_app(
|
||||||
package_name,
|
package_name,
|
||||||
)["icon"]
|
)["icon"],
|
||||||
)
|
)
|
||||||
except BuilderError as e:
|
except BuilderError as e:
|
||||||
raise GooglePlayScraperException from e
|
raise GooglePlayScraperException from e
|
||||||
@@ -168,7 +167,7 @@ def icon_scrapper(package_name: str) -> str:
|
|||||||
return not_found_icon
|
return not_found_icon
|
||||||
|
|
||||||
|
|
||||||
def generate_markdown_table(data: List[List[str]]) -> str:
|
def generate_markdown_table(data: list[list[str]]) -> str:
|
||||||
"""Generate markdown table."""
|
"""Generate markdown table."""
|
||||||
if not data:
|
if not data:
|
||||||
return "No data to generate for the table."
|
return "No data to generate for the table."
|
||||||
@@ -219,7 +218,7 @@ def main() -> None:
|
|||||||
output += table
|
output += table
|
||||||
with Path("status.md").open("w", encoding="utf_8") as status:
|
with Path("status.md").open("w", encoding="utf_8") as status:
|
||||||
status.write(output)
|
status.write(output)
|
||||||
print(output)
|
print(output) # noqa: T201
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
+4
-4
@@ -3,7 +3,7 @@ import concurrent
|
|||||||
import hashlib
|
import hashlib
|
||||||
import pathlib
|
import pathlib
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from typing import Dict, List, Self
|
from typing import Self
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
@@ -31,9 +31,9 @@ class APP(object):
|
|||||||
self.patches_dl = config.env.str(f"{app_name}_PATCHES_DL".upper(), config.global_patches_dl)
|
self.patches_dl = config.env.str(f"{app_name}_PATCHES_DL".upper(), config.global_patches_dl)
|
||||||
self.integrations_dl = config.env.str(f"{app_name}_INTEGRATIONS_DL".upper(), config.global_integrations_dl)
|
self.integrations_dl = config.env.str(f"{app_name}_INTEGRATIONS_DL".upper(), config.global_integrations_dl)
|
||||||
self.patches_json_dl = config.env.str(f"{app_name}_PATCHES_JSON_DL".upper(), config.global_patches_json_dl)
|
self.patches_json_dl = config.env.str(f"{app_name}_PATCHES_JSON_DL".upper(), config.global_patches_json_dl)
|
||||||
self.exclude_request: List[str] = config.env.list(f"{app_name}_EXCLUDE_PATCH".upper(), [])
|
self.exclude_request: list[str] = config.env.list(f"{app_name}_EXCLUDE_PATCH".upper(), [])
|
||||||
self.include_request: List[str] = config.env.list(f"{app_name}_INCLUDE_PATCH".upper(), [])
|
self.include_request: list[str] = config.env.list(f"{app_name}_INCLUDE_PATCH".upper(), [])
|
||||||
self.resource: Dict[str, str] = {}
|
self.resource: dict[str, str] = {}
|
||||||
self.no_of_patches: int = 0
|
self.no_of_patches: int = 0
|
||||||
self.keystore_name = config.env.str(f"{app_name}_KEYSTORE_FILE_NAME".upper(), config.global_keystore_name)
|
self.keystore_name = config.env.str(f"{app_name}_KEYSTORE_FILE_NAME".upper(), config.global_keystore_name)
|
||||||
self.archs_to_build = config.env.list(f"{app_name}_ARCHS_TO_BUILD".upper(), config.global_archs_to_build)
|
self.archs_to_build = config.env.list(f"{app_name}_ARCHS_TO_BUILD".upper(), config.global_archs_to_build)
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
"""Revanced Configurations."""
|
"""Revanced Configurations."""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Self
|
from typing import Self
|
||||||
|
|
||||||
from environs import Env
|
from environs import Env
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class RevancedConfig(object):
|
|||||||
self.temp_folder_name = "apks"
|
self.temp_folder_name = "apks"
|
||||||
self.temp_folder = Path(self.temp_folder_name)
|
self.temp_folder = Path(self.temp_folder_name)
|
||||||
self.ci_test = env.bool("CI_TEST", False)
|
self.ci_test = env.bool("CI_TEST", False)
|
||||||
self.rip_libs_apps: List[str] = []
|
self.rip_libs_apps: list[str] = []
|
||||||
self.existing_downloaded_apks = env.list("EXISTING_DOWNLOADED_APKS", [])
|
self.existing_downloaded_apks = env.list("EXISTING_DOWNLOADED_APKS", [])
|
||||||
self.personal_access_token = env.str("PERSONAL_ACCESS_TOKEN", None)
|
self.personal_access_token = env.str("PERSONAL_ACCESS_TOKEN", None)
|
||||||
self.dry_run = env.bool("DRY_RUN", False)
|
self.dry_run = env.bool("DRY_RUN", False)
|
||||||
@@ -30,7 +30,7 @@ class RevancedConfig(object):
|
|||||||
self.global_integrations_dl = env.str("GLOBAL_INTEGRATIONS_DL", default_integrations)
|
self.global_integrations_dl = env.str("GLOBAL_INTEGRATIONS_DL", default_integrations)
|
||||||
self.global_keystore_name = env.str("GLOBAL_KEYSTORE_FILE_NAME", "revanced.keystore")
|
self.global_keystore_name = env.str("GLOBAL_KEYSTORE_FILE_NAME", "revanced.keystore")
|
||||||
self.global_archs_to_build = env.list("GLOBAL_ARCHS_TO_BUILD", [])
|
self.global_archs_to_build = env.list("GLOBAL_ARCHS_TO_BUILD", [])
|
||||||
self.extra_download_files: List[str] = env.list("EXTRA_FILES", [])
|
self.extra_download_files: list[str] = env.list("EXTRA_FILES", [])
|
||||||
self.apk_editor = "apkeditor-output.jar"
|
self.apk_editor = "apkeditor-output.jar"
|
||||||
self.extra_download_files.append("https://github.com/REAndroid/APKEditor@apkeditor.jar")
|
self.extra_download_files.append("https://github.com/REAndroid/APKEditor@apkeditor.jar")
|
||||||
self.apps = env.list("PATCH_APPS", default_build)
|
self.apps = env.list("PATCH_APPS", default_build)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""Downloader Class."""
|
"""Downloader Class."""
|
||||||
from typing import Any, Dict, Self, Tuple
|
from typing import Any, Self
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup, Tag
|
from bs4 import BeautifulSoup, Tag
|
||||||
@@ -15,7 +15,7 @@ from src.utils import bs4_parser, contains_any_word, handle_request_response, re
|
|||||||
class ApkMirror(Downloader):
|
class ApkMirror(Downloader):
|
||||||
"""Files downloader."""
|
"""Files downloader."""
|
||||||
|
|
||||||
def _extract_force_download_link(self: Self, link: str, app: str) -> Tuple[str, str]:
|
def _extract_force_download_link(self: Self, link: str, app: str) -> tuple[str, str]:
|
||||||
"""Extract force download link."""
|
"""Extract force download link."""
|
||||||
notes_divs = self._extracted_search_div(link, "tab-pane")
|
notes_divs = self._extracted_search_div(link, "tab-pane")
|
||||||
apk_type = self._extracted_search_div(link, "apkm-badge").get_text()
|
apk_type = self._extracted_search_div(link, "apkm-badge").get_text()
|
||||||
@@ -29,7 +29,7 @@ class ApkMirror(Downloader):
|
|||||||
msg = f"Unable to extract force download for {app}"
|
msg = f"Unable to extract force download for {app}"
|
||||||
raise APKMirrorAPKDownloadError(msg, url=link)
|
raise APKMirrorAPKDownloadError(msg, url=link)
|
||||||
|
|
||||||
def extract_download_link(self: Self, page: str, app: str) -> Tuple[str, str]:
|
def extract_download_link(self: Self, page: str, app: str) -> tuple[str, str]:
|
||||||
"""Function to extract the download link from apkmirror html page.
|
"""Function to extract the download link from apkmirror html page.
|
||||||
|
|
||||||
:param page: Url of the page
|
:param page: Url of the page
|
||||||
@@ -58,7 +58,7 @@ class ApkMirror(Downloader):
|
|||||||
"""
|
"""
|
||||||
list_widget = self._extracted_search_div(main_page, "listWidget")
|
list_widget = self._extracted_search_div(main_page, "listWidget")
|
||||||
table_rows = list_widget.find_all(class_="table-row")
|
table_rows = list_widget.find_all(class_="table-row")
|
||||||
links: Dict[str, str] = {}
|
links: dict[str, str] = {}
|
||||||
apk_archs = ["arm64-v8a", "universal", "noarch"]
|
apk_archs = ["arm64-v8a", "universal", "noarch"]
|
||||||
for row in table_rows:
|
for row in table_rows:
|
||||||
if row.find(class_="accent_color"):
|
if row.find(class_="accent_color"):
|
||||||
@@ -81,7 +81,7 @@ class ApkMirror(Downloader):
|
|||||||
soup = BeautifulSoup(r.text, bs4_parser)
|
soup = BeautifulSoup(r.text, bs4_parser)
|
||||||
return soup.find(class_=search_class) # type: ignore[return-value]
|
return soup.find(class_=search_class) # type: ignore[return-value]
|
||||||
|
|
||||||
def specific_version(self: Self, app: APP, version: str, main_page: str = "") -> Tuple[str, str]:
|
def specific_version(self: Self, app: APP, version: str, main_page: str = "") -> tuple[str, str]:
|
||||||
"""Function to download the specified version of app from apkmirror.
|
"""Function to download the specified version of app from apkmirror.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
@@ -97,7 +97,7 @@ class ApkMirror(Downloader):
|
|||||||
download_page = self.get_download_page(main_page)
|
download_page = self.get_download_page(main_page)
|
||||||
return self.extract_download_link(download_page, app.app_name)
|
return self.extract_download_link(download_page, app.app_name)
|
||||||
|
|
||||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||||
"""Function to download whatever the latest version of app from apkmirror.
|
"""Function to download whatever the latest version of app from apkmirror.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""APK Monk Downloader Class."""
|
"""APK Monk Downloader Class."""
|
||||||
import re
|
import re
|
||||||
from typing import Any, Self, Tuple
|
from typing import Any, Self
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@@ -16,7 +16,7 @@ from src.utils import bs4_parser, handle_request_response, request_header, reque
|
|||||||
class ApkMonk(Downloader):
|
class ApkMonk(Downloader):
|
||||||
"""Files downloader."""
|
"""Files downloader."""
|
||||||
|
|
||||||
def extract_download_link(self: Self, page: str, app: str) -> Tuple[str, str]:
|
def extract_download_link(self: Self, page: str, app: str) -> tuple[str, str]:
|
||||||
"""Function to extract the download link from apkmonk html page.
|
"""Function to extract the download link from apkmonk html page.
|
||||||
|
|
||||||
:param page: Url of the page
|
:param page: Url of the page
|
||||||
@@ -48,7 +48,7 @@ class ApkMonk(Downloader):
|
|||||||
self._download(final_download_url, file_name)
|
self._download(final_download_url, file_name)
|
||||||
return file_name, final_download_url
|
return file_name, final_download_url
|
||||||
|
|
||||||
def specific_version(self: Self, app: APP, version: str, main_page: str = "") -> Tuple[str, str]:
|
def specific_version(self: Self, app: APP, version: str, main_page: str = "") -> tuple[str, str]:
|
||||||
"""Function to download the specified version of app from apkmirror.
|
"""Function to download the specified version of app from apkmirror.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
@@ -73,7 +73,7 @@ class ApkMonk(Downloader):
|
|||||||
url=app.download_source,
|
url=app.download_source,
|
||||||
)
|
)
|
||||||
|
|
||||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||||
"""Function to download whatever the latest version of app from apkmonkP.
|
"""Function to download whatever the latest version of app from apkmonkP.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""APK Pure Downloader Class."""
|
"""APK Pure Downloader Class."""
|
||||||
from typing import Any, Self, Tuple
|
from typing import Any, Self
|
||||||
|
|
||||||
from src.app import APP
|
from src.app import APP
|
||||||
from src.downloader.download import Downloader
|
from src.downloader.download import Downloader
|
||||||
@@ -8,7 +8,7 @@ from src.downloader.download import Downloader
|
|||||||
class ApkPure(Downloader):
|
class ApkPure(Downloader):
|
||||||
"""Files downloader."""
|
"""Files downloader."""
|
||||||
|
|
||||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||||
"""Function to download whatever the latest version of app from apkmirror.
|
"""Function to download whatever the latest version of app from apkmirror.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""APK SOS Downloader Class."""
|
"""APK SOS Downloader Class."""
|
||||||
from typing import Any, Self, Tuple
|
from typing import Any, Self
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@@ -13,7 +13,7 @@ from src.utils import bs4_parser, handle_request_response, request_header, reque
|
|||||||
class ApkSos(Downloader):
|
class ApkSos(Downloader):
|
||||||
"""Files downloader."""
|
"""Files downloader."""
|
||||||
|
|
||||||
def extract_download_link(self: Self, page: str, app: str) -> Tuple[str, str]:
|
def extract_download_link(self: Self, page: str, app: str) -> tuple[str, str]:
|
||||||
"""Function to extract the download link from apkmirror html page.
|
"""Function to extract the download link from apkmirror html page.
|
||||||
|
|
||||||
:param page: Url of the page
|
:param page: Url of the page
|
||||||
@@ -32,7 +32,7 @@ class ApkSos(Downloader):
|
|||||||
msg = f"Unable to download {app}"
|
msg = f"Unable to download {app}"
|
||||||
raise APKSosAPKDownloadError(msg, url=page)
|
raise APKSosAPKDownloadError(msg, url=page)
|
||||||
|
|
||||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||||
"""Function to download whatever the latest version of app from apkmirror.
|
"""Function to download whatever the latest version of app from apkmirror.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import subprocess
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from queue import PriorityQueue
|
from queue import PriorityQueue
|
||||||
from time import perf_counter
|
from time import perf_counter
|
||||||
from typing import Any, Self, Tuple
|
from typing import Any, Self
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
@@ -21,7 +21,7 @@ class Downloader(object):
|
|||||||
|
|
||||||
def __init__(self: Self, config: RevancedConfig) -> None:
|
def __init__(self: Self, config: RevancedConfig) -> None:
|
||||||
self._CHUNK_SIZE = 10485760
|
self._CHUNK_SIZE = 10485760
|
||||||
self._QUEUE: PriorityQueue[Tuple[float, str]] = PriorityQueue()
|
self._QUEUE: PriorityQueue[tuple[float, str]] = PriorityQueue()
|
||||||
self._QUEUE_LENGTH = 0
|
self._QUEUE_LENGTH = 0
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
@@ -61,11 +61,11 @@ class Downloader(object):
|
|||||||
self._QUEUE.put((perf_counter() - start, file_name))
|
self._QUEUE.put((perf_counter() - start, file_name))
|
||||||
logger.debug(f"Downloaded {file_name}")
|
logger.debug(f"Downloaded {file_name}")
|
||||||
|
|
||||||
def extract_download_link(self: Self, page: str, app: str) -> Tuple[str, str]:
|
def extract_download_link(self: Self, page: str, app: str) -> tuple[str, str]:
|
||||||
"""Extract download link from web page."""
|
"""Extract download link from web page."""
|
||||||
raise NotImplementedError(implement_method)
|
raise NotImplementedError(implement_method)
|
||||||
|
|
||||||
def specific_version(self: Self, app: APP, version: str) -> Tuple[str, str]:
|
def specific_version(self: Self, app: APP, version: str) -> tuple[str, str]:
|
||||||
"""Function to download the specified version of app from apkmirror.
|
"""Function to download the specified version of app from apkmirror.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
@@ -74,7 +74,7 @@ class Downloader(object):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError(implement_method)
|
raise NotImplementedError(implement_method)
|
||||||
|
|
||||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||||
"""Function to download the latest version of app.
|
"""Function to download the latest version of app.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
@@ -112,7 +112,7 @@ class Downloader(object):
|
|||||||
base_name, _ = os.path.splitext(filename)
|
base_name, _ = os.path.splitext(filename)
|
||||||
return base_name + new_extension
|
return base_name + new_extension
|
||||||
|
|
||||||
def download(self: Self, version: str, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
def download(self: Self, version: str, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||||
"""Public function to download apk to patch.
|
"""Public function to download apk to patch.
|
||||||
|
|
||||||
:param version: version to download
|
:param version: version to download
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Github Downloader."""
|
"""Github Downloader."""
|
||||||
import re
|
import re
|
||||||
from typing import Dict, Self, Tuple
|
from typing import Self
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@@ -16,7 +16,7 @@ from src.utils import handle_request_response, request_timeout, update_changelog
|
|||||||
class Github(Downloader):
|
class Github(Downloader):
|
||||||
"""Files downloader."""
|
"""Files downloader."""
|
||||||
|
|
||||||
def latest_version(self: Self, app: APP, **kwargs: Dict[str, str]) -> Tuple[str, str]:
|
def latest_version(self: Self, app: APP, **kwargs: dict[str, str]) -> tuple[str, str]:
|
||||||
"""Function to download files from GitHub repositories.
|
"""Function to download files from GitHub repositories.
|
||||||
|
|
||||||
:param app: App to download
|
:param app: App to download
|
||||||
@@ -45,7 +45,7 @@ class Github(Downloader):
|
|||||||
return app.app_name, download_url
|
return app.app_name, download_url
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extract_repo_owner_and_tag(url: str) -> Tuple[str, str, str]:
|
def _extract_repo_owner_and_tag(url: str) -> tuple[str, str, str]:
|
||||||
"""Extract repo owner and url from github url."""
|
"""Extract repo owner and url from github url."""
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
path_segments = parsed_url.path.strip("/").split("/")
|
path_segments = parsed_url.path.strip("/").split("/")
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""Google Drive downloader Class."""
|
"""Google Drive downloader Class."""
|
||||||
from typing import Any, Self, Tuple
|
from typing import Any, Self
|
||||||
|
|
||||||
import gdown
|
import gdown
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ from src.downloader.download import Downloader
|
|||||||
class GoogleDrive(Downloader):
|
class GoogleDrive(Downloader):
|
||||||
"""Google Driver downloader."""
|
"""Google Driver downloader."""
|
||||||
|
|
||||||
def specific_version(self: Self, app: APP, version: str) -> Tuple[str, str]:
|
def specific_version(self: Self, app: APP, version: str) -> tuple[str, str]:
|
||||||
"""Function to download the specified version of app from apkmirror.
|
"""Function to download the specified version of app from apkmirror.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
@@ -19,7 +19,7 @@ class GoogleDrive(Downloader):
|
|||||||
"""
|
"""
|
||||||
return self.latest_version(app)
|
return self.latest_version(app)
|
||||||
|
|
||||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||||
"""Function to download whatever the latest version of app from Google Driver.
|
"""Function to download whatever the latest version of app from Google Driver.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""Upto Down Downloader."""
|
"""Upto Down Downloader."""
|
||||||
from typing import Any, Self, Tuple
|
from typing import Any, Self
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@@ -14,7 +14,7 @@ from src.utils import bs4_parser, handle_request_response, request_header, reque
|
|||||||
class UptoDown(Downloader):
|
class UptoDown(Downloader):
|
||||||
"""Files downloader."""
|
"""Files downloader."""
|
||||||
|
|
||||||
def extract_download_link(self: Self, page: str, app: str) -> Tuple[str, str]:
|
def extract_download_link(self: Self, page: str, app: str) -> tuple[str, str]:
|
||||||
"""Extract download link from uptodown url."""
|
"""Extract download link from uptodown url."""
|
||||||
r = requests.get(page, headers=request_header, allow_redirects=True, timeout=request_timeout)
|
r = requests.get(page, headers=request_header, allow_redirects=True, timeout=request_timeout)
|
||||||
handle_request_response(r, page)
|
handle_request_response(r, page)
|
||||||
@@ -34,7 +34,7 @@ class UptoDown(Downloader):
|
|||||||
msg = f"Unable to download {app} from uptodown."
|
msg = f"Unable to download {app} from uptodown."
|
||||||
raise UptoDownAPKDownloadError(msg, url=page)
|
raise UptoDownAPKDownloadError(msg, url=page)
|
||||||
|
|
||||||
def specific_version(self: Self, app: APP, version: str) -> Tuple[str, str]:
|
def specific_version(self: Self, app: APP, version: str) -> tuple[str, str]:
|
||||||
"""Function to download the specified version of app from apkmirror.
|
"""Function to download the specified version of app from apkmirror.
|
||||||
|
|
||||||
:param app: Name of the application
|
:param app: Name of the application
|
||||||
@@ -57,7 +57,7 @@ class UptoDown(Downloader):
|
|||||||
raise UptoDownAPKDownloadError(msg, url=url)
|
raise UptoDownAPKDownloadError(msg, url=url)
|
||||||
return self.extract_download_link(download_url, app.app_name)
|
return self.extract_download_link(download_url, app.app_name)
|
||||||
|
|
||||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||||
"""Function to download the latest version of app from uptodown."""
|
"""Function to download the latest version of app from uptodown."""
|
||||||
logger.debug("downloading latest version of app from uptodown.")
|
logger.debug("downloading latest version of app from uptodown.")
|
||||||
page = f"{app.download_source}/download"
|
page = f"{app.download_source}/download"
|
||||||
|
|||||||
+10
-7
@@ -2,7 +2,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import PIPE, Popen
|
||||||
from time import perf_counter
|
from time import perf_counter
|
||||||
from typing import Dict, List, Self
|
from typing import Self
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
@@ -26,8 +26,8 @@ class Parser(object):
|
|||||||
OPTIONS_ARG = "--options"
|
OPTIONS_ARG = "--options"
|
||||||
|
|
||||||
def __init__(self: Self, patcher: Patches, config: RevancedConfig) -> None:
|
def __init__(self: Self, patcher: Patches, config: RevancedConfig) -> None:
|
||||||
self._PATCHES: List[str] = []
|
self._PATCHES: list[str] = []
|
||||||
self._EXCLUDED: List[str] = []
|
self._EXCLUDED: list[str] = []
|
||||||
self.patcher = patcher
|
self.patcher = patcher
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ class Parser(object):
|
|||||||
self._PATCHES.extend(["-e", name])
|
self._PATCHES.extend(["-e", name])
|
||||||
self._EXCLUDED.append(name)
|
self._EXCLUDED.append(name)
|
||||||
|
|
||||||
def get_excluded_patches(self: Self) -> List[str]:
|
def get_excluded_patches(self: Self) -> list[str]:
|
||||||
"""The function `get_excluded_patches` is a getter method that returns a list of excluded patches.
|
"""The function `get_excluded_patches` is a getter method that returns a list of excluded patches.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
@@ -61,7 +61,7 @@ class Parser(object):
|
|||||||
"""
|
"""
|
||||||
return self._EXCLUDED
|
return self._EXCLUDED
|
||||||
|
|
||||||
def get_all_patches(self: Self) -> List[str]:
|
def get_all_patches(self: Self) -> list[str]:
|
||||||
"""The function "get_all_patches" is a getter method that returns a ist of all patches.
|
"""The function "get_all_patches" is a getter method that returns a ist of all patches.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
@@ -104,13 +104,16 @@ class Parser(object):
|
|||||||
self._PATCHES[idx] = "-e"
|
self._PATCHES[idx] = "-e"
|
||||||
|
|
||||||
def include_exclude_patch(
|
def include_exclude_patch(
|
||||||
self: Self, app: APP, patches: List[Dict[str, str]], patches_dict: Dict[str, str]
|
self: Self,
|
||||||
|
app: APP,
|
||||||
|
patches: list[dict[str, str]],
|
||||||
|
patches_dict: dict[str, str],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""The function `include_exclude_patch` includes and excludes patches for a given app."""
|
"""The function `include_exclude_patch` includes and excludes patches for a given app."""
|
||||||
for patch in patches:
|
for patch in patches:
|
||||||
normalized_patch = patch["name"].lower().replace(" ", "-")
|
normalized_patch = patch["name"].lower().replace(" ", "-")
|
||||||
self.include(normalized_patch) if normalized_patch not in app.exclude_request else self.exclude(
|
self.include(normalized_patch) if normalized_patch not in app.exclude_request else self.exclude(
|
||||||
normalized_patch
|
normalized_patch,
|
||||||
)
|
)
|
||||||
for normalized_patch in app.include_request:
|
for normalized_patch in app.include_request:
|
||||||
self.include(normalized_patch) if normalized_patch not in patches_dict["universal_patch"] else ()
|
self.include(normalized_patch) if normalized_patch not in patches_dict["universal_patch"] else ()
|
||||||
|
|||||||
+6
-6
@@ -3,7 +3,7 @@
|
|||||||
import contextlib
|
import contextlib
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, ClassVar, Dict, List, Self, Tuple
|
from typing import Any, ClassVar, Self
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ from src.exceptions import AppNotFoundError, PatchesJsonLoadError
|
|||||||
class Patches(object):
|
class Patches(object):
|
||||||
"""Revanced Patches."""
|
"""Revanced Patches."""
|
||||||
|
|
||||||
revanced_package_names: ClassVar[Dict[str, str]] = {
|
revanced_package_names: ClassVar[dict[str, str]] = {
|
||||||
"com.reddit.frontpage": "reddit",
|
"com.reddit.frontpage": "reddit",
|
||||||
"com.duolingo": "duolingo",
|
"com.duolingo": "duolingo",
|
||||||
"com.ss.android.ugc.trill": "tiktok",
|
"com.ss.android.ugc.trill": "tiktok",
|
||||||
@@ -91,7 +91,7 @@ class Patches(object):
|
|||||||
raise AppNotFoundError(msg)
|
raise AppNotFoundError(msg)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def support_app() -> Dict[str, str]:
|
def support_app() -> dict[str, str]:
|
||||||
"""The function returns a dictionary of supported app IDs.
|
"""The function returns a dictionary of supported app IDs.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
@@ -132,10 +132,10 @@ class Patches(object):
|
|||||||
app.no_of_patches = len(self.patches_dict[app.app_name])
|
app.no_of_patches = len(self.patches_dict[app.app_name])
|
||||||
|
|
||||||
def __init__(self: Self, config: RevancedConfig, app: APP) -> None:
|
def __init__(self: Self, config: RevancedConfig, app: APP) -> None:
|
||||||
self.patches_dict: Dict[str, Any] = {"universal_patch": []}
|
self.patches_dict: dict[str, Any] = {"universal_patch": []}
|
||||||
self.fetch_patches(config, app)
|
self.fetch_patches(config, app)
|
||||||
|
|
||||||
def get(self: Self, app: str) -> Tuple[List[Dict[str, str]], str]:
|
def get(self: Self, app: str) -> tuple[list[dict[str, str]], str]:
|
||||||
"""The function `get` returns all patches and version for a given application.
|
"""The function `get` returns all patches and version for a given application.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -156,7 +156,7 @@ class Patches(object):
|
|||||||
version = next(i["version"] for i in patches if i["version"] != "all")
|
version = next(i["version"] for i in patches if i["version"] != "all")
|
||||||
return patches, version
|
return patches, version
|
||||||
|
|
||||||
def get_app_configs(self: Self, app: "APP") -> List[Dict[str, str]]:
|
def get_app_configs(self: Self, app: "APP") -> list[dict[str, str]]:
|
||||||
"""The function `get_app_configs` returns configurations for a given app.
|
"""The function `get_app_configs` returns configurations for a given app.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|||||||
+4
-4
@@ -3,7 +3,7 @@ import re
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List
|
from typing import Any
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@@ -32,7 +32,7 @@ session = Session()
|
|||||||
session.headers["User-Agent"] = request_header["User-Agent"]
|
session.headers["User-Agent"] = request_header["User-Agent"]
|
||||||
|
|
||||||
|
|
||||||
def update_changelog(name: str, response: Dict[str, str]) -> None:
|
def update_changelog(name: str, response: dict[str, str]) -> None:
|
||||||
"""The function `update_changelog` updates the changelog file.
|
"""The function `update_changelog` updates the changelog file.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -49,7 +49,7 @@ def update_changelog(name: str, response: Dict[str, str]) -> None:
|
|||||||
write_to_file(change_log)
|
write_to_file(change_log)
|
||||||
|
|
||||||
|
|
||||||
def format_changelog(name: str, response: Dict[str, str], parent_repo: str) -> str:
|
def format_changelog(name: str, response: dict[str, str], parent_repo: str) -> str:
|
||||||
"""The `format_changelog` returns formatted changelog string.
|
"""The `format_changelog` returns formatted changelog string.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -194,6 +194,6 @@ def apkmirror_status_check(package_name: str) -> Any:
|
|||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
def contains_any_word(string: str, words: List[str]) -> bool:
|
def contains_any_word(string: str, words: list[str]) -> bool:
|
||||||
"""Checks if a string contains any word."""
|
"""Checks if a string contains any word."""
|
||||||
return any(word in string for word in words)
|
return any(word in string for word in words)
|
||||||
|
|||||||
Reference in New Issue
Block a user