From 6decdc0efbedf2bdcf7e1dc1aaa15e0c0396c8d5 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal Date: Wed, 5 Jul 2023 22:17:20 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Removed=20duplicate=20patches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 12 ++++++++++-- src/parser.py | 10 ++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index c62e41b..3528ef1 100644 --- a/main.py +++ b/main.py @@ -40,7 +40,11 @@ def main() -> None: logger.exception(f"Failed to build {app} because of {e}") if len(config.alternative_youtube_patches) and "youtube" in config.apps: for alternative_patch in config.alternative_youtube_patches: - _, version, is_experimental = patcher.get_app_configs("youtube") + parser = Parser(patcher, config) + app_all_patches, version, is_experimental = patcher.get_app_configs( + "youtube" + ) + patcher.include_exclude_patch("youtube", parser, app_all_patches) was_inverted = parser.invert_patch(alternative_patch) if was_inverted: logger.info( @@ -58,7 +62,11 @@ def main() -> None: ) if len(config.alternative_youtube_music_patches) and "youtube_music" in config.apps: for alternative_patch in config.alternative_youtube_music_patches: - _, version, is_experimental = patcher.get_app_configs("youtube_music") + parser = Parser(patcher, config) + app_all_patches, version, is_experimental = patcher.get_app_configs( + "youtube_music" + ) + patcher.include_exclude_patch("youtube_music", parser, app_all_patches) was_inverted = parser.invert_patch(alternative_patch) if was_inverted: logger.info( diff --git a/src/parser.py b/src/parser.py index cfbea88..7465714 100644 --- a/src/parser.py +++ b/src/parser.py @@ -50,10 +50,12 @@ class Parser(object): patches.""" try: patch_index = self._PATCHES.index(name) - if self._PATCHES[patch_index - 1] == "-e": - self._PATCHES[patch_index - 1] = "-i" - else: - self._PATCHES[patch_index - 1] = "-e" + indices = [i for i in range(len(self._PATCHES)) if self._PATCHES[i] == name] + for patch_index in indices: + if self._PATCHES[patch_index - 1] == "-e": + self._PATCHES[patch_index - 1] = "-i" + else: + self._PATCHES[patch_index - 1] = "-e" return True except ValueError: return False