mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🎨 Custom class for loading patches
This commit is contained in:
+16
-12
@@ -63,19 +63,10 @@ class Patches(object):
|
||||
"""Return supported apps."""
|
||||
return Patches._revanced_app_ids
|
||||
|
||||
def scrap_patches(self, file_name: str) -> Any:
|
||||
"""Scrap Patches."""
|
||||
try:
|
||||
with open(file_name) as f:
|
||||
patches = json.load(f)
|
||||
return patches
|
||||
except FileNotFoundError:
|
||||
raise PatchesJsonFailed()
|
||||
|
||||
# noinspection DuplicatedCode
|
||||
def fetch_patches(self, config: RevancedConfig, app: APP) -> None:
|
||||
"""Function to fetch all patches."""
|
||||
patches = self.scrap_patches(
|
||||
patch_loader = PatchLoader()
|
||||
patches = patch_loader.load_patches(
|
||||
f'{config.temp_folder}/{app.resource["patches_json"]}'
|
||||
)
|
||||
for app_name in (self.revanced_app_ids[x][1] for x in self.revanced_app_ids):
|
||||
@@ -121,7 +112,6 @@ class Patches(object):
|
||||
pass
|
||||
return patches, version
|
||||
|
||||
# noinspection IncorrectFormatting
|
||||
def include_exclude_patch(
|
||||
self, app: APP, parser: Any, patches: List[Dict[str, str]]
|
||||
) -> None:
|
||||
@@ -164,3 +154,17 @@ class Patches(object):
|
||||
recommended_version = app.app_version
|
||||
app.set_recommended_version(recommended_version, experiment)
|
||||
return total_patches
|
||||
|
||||
|
||||
class PatchLoader:
|
||||
"""Patch Loader."""
|
||||
|
||||
@staticmethod
|
||||
def load_patches(file_name: str) -> Any:
|
||||
"""Load patches from a file."""
|
||||
try:
|
||||
with open(file_name) as f:
|
||||
patches = json.load(f)
|
||||
return patches
|
||||
except FileNotFoundError:
|
||||
raise PatchesJsonFailed()
|
||||
|
||||
Reference in New Issue
Block a user