diff --git a/modules/render.py b/modules/render.py index cf020d0..b85ef32 100644 --- a/modules/render.py +++ b/modules/render.py @@ -66,11 +66,16 @@ def suggestions(page, json): # This function will render suggestions page = page + "

Replacements:



" + + print("json request") found = search.suggest(json) + print("json received", len(found)) for i in found: + print(i[-1].get("names",["no name"])[0], "Drawing") + free = False if "licenses" in i[-1] and i[-1]["licenses"]: free = True diff --git a/modules/search.py b/modules/search.py index 76fedf5..0297812 100644 --- a/modules/search.py +++ b/modules/search.py @@ -27,7 +27,7 @@ def search_app(name): with open("apps/"+i) as json_file: idata = json.load(json_file) except Exception as e: - print("Error!", e) + print("Error!", i, e) idata = {} all_apps.append(idata) @@ -69,7 +69,7 @@ def suggest(json_data): with open("apps/"+i) as json_file: idata = json.load(json_file) except Exception as e: - print("Error!", e) + print("Error!", i, e) idata = {} all_apps.append(idata) @@ -81,12 +81,14 @@ def suggest(json_data): for b in json_data.get(c, []): if b in i.get(c, []): score += 1 - print(score, "SCORE") + print(score, i.get("names",["no name"])[0], "SCORE") found.append([score, i]) try: - found = reversed(sorted(found)) - except: - return [] + found.sort(key=lambda x: x[0]) + found = list(reversed(found)) + except Exception as e: + print("Found problem:", e) + fount = [] return found