mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🎨 Improved imports (#357)
This commit is contained in:
@@ -4,6 +4,7 @@ import sys
|
|||||||
from environs import Env
|
from environs import Env
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
from src.app import APP
|
||||||
from src.config import RevancedConfig
|
from src.config import RevancedConfig
|
||||||
from src.exceptions import AppNotFoundError, BuilderError, PatchesJsonLoadError, PatchingFailedError
|
from src.exceptions import AppNotFoundError, BuilderError, PatchesJsonLoadError, PatchingFailedError
|
||||||
from src.parser import Parser
|
from src.parser import Parser
|
||||||
@@ -11,10 +12,15 @@ from src.patches import Patches
|
|||||||
from src.utils import check_java, extra_downloads
|
from src.utils import check_java, extra_downloads
|
||||||
|
|
||||||
|
|
||||||
|
def get_app(config: RevancedConfig, app_name: str) -> APP:
|
||||||
|
"""Get App object."""
|
||||||
|
env_package_name = config.env.str(f"{app_name}_PACKAGE_NAME".upper(), None)
|
||||||
|
package_name = env_package_name or Patches.get_package_name(app_name)
|
||||||
|
return APP(app_name=app_name, package_name=package_name, config=config)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
"""Entry point."""
|
"""Entry point."""
|
||||||
from src.app import APP
|
|
||||||
|
|
||||||
env = Env()
|
env = Env()
|
||||||
env.read_env()
|
env.read_env()
|
||||||
config = RevancedConfig(env)
|
config = RevancedConfig(env)
|
||||||
@@ -26,7 +32,7 @@ def main() -> None:
|
|||||||
for possible_app in config.apps:
|
for possible_app in config.apps:
|
||||||
logger.info(f"Trying to build {possible_app}")
|
logger.info(f"Trying to build {possible_app}")
|
||||||
try:
|
try:
|
||||||
app = APP(app_name=possible_app, config=config)
|
app = get_app(config, possible_app)
|
||||||
patcher = Patches(config, app)
|
patcher = Patches(config, app)
|
||||||
parser = Parser(patcher, config)
|
parser = Parser(patcher, config)
|
||||||
app_all_patches = patcher.get_app_configs(app)
|
app_all_patches = patcher.get_app_configs(app)
|
||||||
|
|||||||
+2
-5
@@ -16,7 +16,7 @@ from src.utils import slugify
|
|||||||
class APP(object):
|
class APP(object):
|
||||||
"""Patched APK."""
|
"""Patched APK."""
|
||||||
|
|
||||||
def __init__(self: Self, app_name: str, config: RevancedConfig) -> None:
|
def __init__(self: Self, app_name: str, package_name: str, config: RevancedConfig) -> None:
|
||||||
"""Initialize APP.
|
"""Initialize APP.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -24,8 +24,6 @@ class APP(object):
|
|||||||
app_name (str): Name of the app.
|
app_name (str): Name of the app.
|
||||||
config (RevancedConfig): Configuration object.
|
config (RevancedConfig): Configuration object.
|
||||||
"""
|
"""
|
||||||
from src.patches import Patches
|
|
||||||
|
|
||||||
self.app_name = app_name
|
self.app_name = app_name
|
||||||
self.app_version = config.env.str(f"{app_name}_VERSION".upper(), None)
|
self.app_version = config.env.str(f"{app_name}_VERSION".upper(), None)
|
||||||
self.experiment = False
|
self.experiment = False
|
||||||
@@ -43,8 +41,7 @@ class APP(object):
|
|||||||
self.download_dl = config.env.str(f"{app_name}_DL".upper(), "")
|
self.download_dl = config.env.str(f"{app_name}_DL".upper(), "")
|
||||||
self.download_patch_resources(config)
|
self.download_patch_resources(config)
|
||||||
self.download_source = config.env.str(f"{app_name}_DL_SOURCE".upper(), "")
|
self.download_source = config.env.str(f"{app_name}_DL_SOURCE".upper(), "")
|
||||||
env_package_name = config.env.str(f"{app_name}_PACKAGE_NAME".upper(), None)
|
self.package_name = package_name
|
||||||
self.package_name = env_package_name or Patches.get_package_name(app_name)
|
|
||||||
|
|
||||||
def download_apk_for_patching(self: Self, config: RevancedConfig) -> None:
|
def download_apk_for_patching(self: Self, config: RevancedConfig) -> None:
|
||||||
"""Download apk to be patched."""
|
"""Download apk to be patched."""
|
||||||
|
|||||||
+12
-7
@@ -15,17 +15,11 @@ class RevancedConfig(object):
|
|||||||
"""Revanced Configurations."""
|
"""Revanced Configurations."""
|
||||||
|
|
||||||
def __init__(self: Self, env: Env) -> None:
|
def __init__(self: Self, env: Env) -> None:
|
||||||
from src.utils import default_build, request_header
|
|
||||||
|
|
||||||
self.env = env
|
self.env = env
|
||||||
self.temp_folder = Path("apks")
|
self.temp_folder = Path("apks")
|
||||||
self.session = Session()
|
self.session = Session()
|
||||||
self.session.headers["User-Agent"] = request_header["User-Agent"]
|
|
||||||
self.ci_test = env.bool("CI_TEST", False)
|
self.ci_test = env.bool("CI_TEST", False)
|
||||||
self.apps = env.list(
|
|
||||||
"PATCH_APPS",
|
|
||||||
default_build,
|
|
||||||
)
|
|
||||||
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)
|
||||||
@@ -39,3 +33,14 @@ class RevancedConfig(object):
|
|||||||
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._fetch_or_default(env)
|
||||||
|
|
||||||
|
def _fetch_or_default(self: Self, env: Env) -> None:
|
||||||
|
"""Get config from env or use default."""
|
||||||
|
from src.utils import default_build, request_header
|
||||||
|
|
||||||
|
self.apps = env.list(
|
||||||
|
"PATCH_APPS",
|
||||||
|
default_build,
|
||||||
|
)
|
||||||
|
self.session.headers["User-Agent"] = request_header["User-Agent"]
|
||||||
|
|||||||
Reference in New Issue
Block a user