From 0026e284b6846555b6b43fc8151261f82fac847c Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 24 Jan 2023 14:07:42 -0500 Subject: [PATCH] [21] mal_search fix --- VERSION | 2 +- docs/conf.py | 5 ++++- docs/home/kb.md | 19 +++++++++++++++++++ modules/builder.py | 15 +++++++++------ modules/meta.py | 10 +++++----- modules/util.py | 12 +++++++++--- 6 files changed, 47 insertions(+), 16 deletions(-) diff --git a/VERSION b/VERSION index c6805f8d..077472ac 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.3-develop20 +1.18.3-develop21 diff --git a/docs/conf.py b/docs/conf.py index f14423f3..baeceabf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -543,7 +543,10 @@ html_theme_options = { # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] -html_css_files = ["custom.css"] +html_css_files = [ + "custom.css", + "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" +] def setup(app): app.add_css_file("custom.css") diff --git a/docs/home/kb.md b/docs/home/kb.md index e91d484a..9e79e93f 100644 --- a/docs/home/kb.md +++ b/docs/home/kb.md @@ -1,5 +1,24 @@ # Frequently Asked Questions & Knowledgebase +## {} + +{fas}`spinner;sd-text-primary` + +- An icon {fas}`spinner;sd-text-primary`, some more text. +- An icon {fab}`github`, some more text. +- An icon {fab}`gitkraken;sd-text-success fa-xl`, some more text. +- An icon {fas}`skull;sd-text-danger`, some more text. + +## :: + +:fas:`spinner;sd-text-primary` + +- An icon :fas:`spinner;sd-text-primary`, some more text. +- An icon :fab:`github`, some more text. +- An icon :fab:`gitkraken;sd-text-success fa-xl`, some more text. +- An icon :fas:`skull;sd-text-danger`, some more text. + + This page aims to provide knowledge based on combined user experience, and to answer the frequent questions that we are asked in our [Discord Server](https://discord.gg/NfH6mGFuAB). ## Frequently Asked Questions diff --git a/modules/builder.py b/modules/builder.py index 16d4263b..3ba41472 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -1319,16 +1319,19 @@ class CollectionBuilder: final_text += f"\nStatus: {final_attributes['status']}" if "genre" in dict_methods: genre_str = str(util.parse(self.Type, "genre", dict_data, methods=dict_methods, parent=method_name)) - final_text += f"\nGenre: {util.parse_and_or(self.Type, 'Genre', genre_str, test_list=self.config.MyAnimeList.genres)}" - final_attributes["genres"] = genre_str + out_text, out_ints = util.parse_and_or(self.Type, 'Genre', genre_str, self.config.MyAnimeList.genres) + final_text += f"\nGenre: {out_text}" + final_attributes["genres"] = out_ints if "genre.not" in dict_methods: genre_str = str(util.parse(self.Type, "genre.not", dict_data, methods=dict_methods, parent=method_name)) - final_text += f"\nNot Genre: {util.parse_and_or(self.Type, 'Genre', genre_str, test_list=self.config.MyAnimeList.genres)}" - final_attributes["genres_exclude"] = genre_str + out_text, out_ints = util.parse_and_or(self.Type, 'Genre', genre_str, self.config.MyAnimeList.genres) + final_text += f"\nNot Genre: {out_text}" + final_attributes["genres_exclude"] = out_ints if "studio" in dict_methods: studio_str = str(util.parse(self.Type, "studio", dict_data, methods=dict_methods, parent=method_name)) - final_text += f"\nStudio: {util.parse_and_or(self.Type, 'Studio', studio_str, test_list=self.config.MyAnimeList.studios)}" - final_attributes["producers"] = studio_str + out_text, out_ints = util.parse_and_or(self.Type, 'Studio', studio_str, self.config.MyAnimeList.studios) + final_text += f"\nStudio: {out_text}" + final_attributes["producers"] = out_ints if "content_rating" in dict_methods: final_attributes["rating"] = util.parse(self.Type, "content_rating", dict_data, methods=dict_methods, parent=method_name, options=mal.search_ratings) final_text += f"\nContent Rating: {final_attributes['rating']}" diff --git a/modules/meta.py b/modules/meta.py index d97ae273..733a29d8 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -209,7 +209,7 @@ class DataFile: remove_variables = [] optional = [] - for tm in original_variables: + for tm in original_variables.copy(): if original_variables[tm] is None: remove_variables.append(tm) original_variables.pop(tm) @@ -385,12 +385,12 @@ class DataFile: logger.trace(f"Condition {i} Failed: {var_key}: {'true does not exist' if var_value else 'false exists'}") condition_passed = False elif var_key.endswith(".not"): - if (isinstance(var_value, list) and variables[var_key] in var_value) or \ - (not isinstance(var_value, list) and str(variables[var_key]) == str(var_value)): + if (isinstance(var_value, list) and variables[var_key[:-4]] in var_value) or \ + (not isinstance(var_value, list) and str(variables[var_key[:-4]]) == str(var_value)): if isinstance(var_value, list): - logger.trace(f'Condition {i} Failed: {var_key} "{variables[var_key]}" in {var_value}') + logger.trace(f'Condition {i} Failed: {var_key[:-4]} "{variables[var_key[:-4]]}" in {var_value}') else: - logger.trace(f'Condition {i} Failed: {var_key} "{variables[var_key]}" is "{var_value}"') + logger.trace(f'Condition {i} Failed: {var_key[:-4]} "{variables[var_key[:-4]]}" is "{var_value}"') condition_passed = False elif var_key in variables: if (isinstance(var_value, list) and variables[var_key] not in var_value) or \ diff --git a/modules/util.py b/modules/util.py index b5231072..e9d9aabf 100644 --- a/modules/util.py +++ b/modules/util.py @@ -699,16 +699,22 @@ def check_int(value, datatype="int", minimum=1, maximum=None): except ValueError: pass -def parse_and_or(error, attribute, data, test_list=None): +def parse_and_or(error, attribute, data, test_list): out = "" + final = "" ands = [d.strip() for d in data.split(",")] for an in ands: ors = [a.strip() for a in an.split("|")] + or_num = [] for item in ors: if not item: raise Failed(f"{error} Error: Cannot have a blank {attribute}") - if test_list and str(item) not in test_list: + if str(item) not in test_list: raise Failed(f"{error} Error: {attribute} {item} is invalid") + or_num.append(test_list[str(item)]) + if final: + final += "," + final += "|".join(or_num) if out: out += f" and " if len(ands) > 1 and len(ors) > 1: @@ -719,7 +725,7 @@ def parse_and_or(error, attribute, data, test_list=None): out += test_list[test_list[str(ors[0])]] if test_list else ors[0] if len(ands) > 1 and len(ors) > 1: out += ")" - return out + return out, final def parse(error, attribute, data, datatype=None, methods=None, parent=None, default=None, options=None, translation=None, minimum=1, maximum=None, regex=None, range_split=None): display = f"{parent + ' ' if parent else ''}{attribute} attribute"