mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🎨 Moved include exclude function
This commit is contained in:
committed by
Nikhil Badyal
parent
720bfe9a3c
commit
2d15330df3
@@ -37,7 +37,7 @@ def main() -> None:
|
|||||||
parser = Parser(patcher, config)
|
parser = Parser(patcher, config)
|
||||||
app_all_patches = patcher.get_app_configs(app)
|
app_all_patches = patcher.get_app_configs(app)
|
||||||
app.download_apk_for_patching(config)
|
app.download_apk_for_patching(config)
|
||||||
patcher.include_exclude_patch(app, parser, app_all_patches)
|
parser.include_exclude_patch(app, app_all_patches, patcher.patches_dict)
|
||||||
logger.info(app)
|
logger.info(app)
|
||||||
parser.patch_app(app)
|
parser.patch_app(app)
|
||||||
except AppNotFoundError as e:
|
except AppNotFoundError as e:
|
||||||
|
|||||||
+13
-1
@@ -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 List, Self
|
from typing import Dict, List, Self
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
@@ -103,6 +103,18 @@ class Parser(object):
|
|||||||
if item == "-i":
|
if item == "-i":
|
||||||
self._PATCHES[idx] = "-e"
|
self._PATCHES[idx] = "-e"
|
||||||
|
|
||||||
|
def include_exclude_patch(
|
||||||
|
self: Self, app: APP, patches: List[Dict[str, str]], patches_dict: Dict[str, str]
|
||||||
|
) -> None:
|
||||||
|
"""The function `include_exclude_patch` includes and excludes patches for a given app."""
|
||||||
|
for patch in patches:
|
||||||
|
normalized_patch = patch["name"].lower().replace(" ", "-")
|
||||||
|
self.include(normalized_patch) if normalized_patch not in app.exclude_request else self.exclude(
|
||||||
|
normalized_patch
|
||||||
|
)
|
||||||
|
for normalized_patch in app.include_request:
|
||||||
|
self.include(normalized_patch) if normalized_patch not in patches_dict["universal_patch"] else ()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_new_cli(cli_path: Path) -> bool:
|
def is_new_cli(cli_path: Path) -> bool:
|
||||||
"""Check if new cli is being used."""
|
"""Check if new cli is being used."""
|
||||||
|
|||||||
@@ -156,29 +156,6 @@ 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 include_exclude_patch(self: Self, app: APP, parser: Any, patches: List[Dict[str, str]]) -> None:
|
|
||||||
"""The function `include_exclude_patch` includes and excludes patches for a given app.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
app : APP
|
|
||||||
The "app" parameter is the name of the app for which the patches are being included or
|
|
||||||
excluded.
|
|
||||||
parser : Any
|
|
||||||
The `parser` parameter is an object of type `Any`, which means it can be any type of object. It
|
|
||||||
is used to perform parsing operations.
|
|
||||||
patches : List[Dict[str, str]]
|
|
||||||
A list of dictionaries, where each dictionary represents a patch and contains the following
|
|
||||||
keys:
|
|
||||||
"""
|
|
||||||
for patch in patches:
|
|
||||||
normalized_patch = patch["name"].lower().replace(" ", "-")
|
|
||||||
parser.include(normalized_patch) if normalized_patch not in app.exclude_request else parser.exclude(
|
|
||||||
normalized_patch
|
|
||||||
)
|
|
||||||
for normalized_patch in app.include_request:
|
|
||||||
parser.include(normalized_patch) if normalized_patch not in self.patches_dict["universal_patch"] else ()
|
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user