📝 Updated inclusion logic

This commit is contained in:
Nikhil Badyal
2023-12-22 12:57:30 +05:30
committed by Nikhil Badyal
parent c0b34db784
commit 639382ed38
2 changed files with 9 additions and 11 deletions
+8 -10
View File
@@ -107,7 +107,7 @@ class Parser(object):
self: Self, self: Self,
app: APP, app: APP,
patches: list[dict[str, str]], patches: list[dict[str, str]],
patches_dict: dict[str, str], patches_dict: dict[str, list[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."""
if app.space_formatted: if app.space_formatted:
@@ -116,18 +116,16 @@ class Parser(object):
self.include(patch["name"]) if normalized_patch not in app.exclude_request else self.exclude( self.include(patch["name"]) if normalized_patch not in app.exclude_request else self.exclude(
patch["name"], patch["name"],
) )
for normalized_patch in app.include_request: for patch in patches_dict["universal_patch"]:
self.include(normalized_patch.lower().replace("-", " ")) if normalized_patch not in patches_dict[ normalized_patch = patch["name"].lower().replace(" ", "-")
"universal_patch" self.include(patch["name"]) if normalized_patch in app.include_request else ()
] else ()
else: else:
for patch in patches: for patch in patches:
normalized_patch = patch["name"].lower().replace(" ", "-") self.include(patch["name"]) if patch["name"] not in app.exclude_request else self.exclude(
self.include(normalized_patch) if normalized_patch not in app.exclude_request else self.exclude( patch["name"],
normalized_patch,
) )
for normalized_patch in app.include_request: for patch in patches_dict["universal_patch"]:
self.include(normalized_patch) if normalized_patch not in patches_dict["universal_patch"] else () self.include(patch["name"]) if patch["name"] in app.include_request else ()
@staticmethod @staticmethod
def is_new_cli(cli_path: Path) -> tuple[bool, str]: def is_new_cli(cli_path: Path) -> tuple[bool, str]:
+1 -1
View File
@@ -133,7 +133,7 @@ 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, list[dict[str, str]]] = {"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]: