Upload files to 'modules'
This commit is contained in:
parent
2d12250bc3
commit
0f293528b9
2 changed files with 13 additions and 6 deletions
|
@ -67,10 +67,15 @@ def suggestions(page, json):
|
||||||
|
|
||||||
page = page + "<br><br><h1>Replacements:</h1><br><br>"
|
page = page + "<br><br><h1>Replacements:</h1><br><br>"
|
||||||
|
|
||||||
|
print("json request")
|
||||||
|
|
||||||
found = search.suggest(json)
|
found = search.suggest(json)
|
||||||
|
print("json received", len(found))
|
||||||
|
|
||||||
for i in found:
|
for i in found:
|
||||||
|
|
||||||
|
print(i[-1].get("names",["no name"])[0], "Drawing")
|
||||||
|
|
||||||
free = False
|
free = False
|
||||||
if "licenses" in i[-1] and i[-1]["licenses"]:
|
if "licenses" in i[-1] and i[-1]["licenses"]:
|
||||||
free = True
|
free = True
|
||||||
|
|
|
@ -27,7 +27,7 @@ def search_app(name):
|
||||||
with open("apps/"+i) as json_file:
|
with open("apps/"+i) as json_file:
|
||||||
idata = json.load(json_file)
|
idata = json.load(json_file)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error!", e)
|
print("Error!", i, e)
|
||||||
idata = {}
|
idata = {}
|
||||||
|
|
||||||
all_apps.append(idata)
|
all_apps.append(idata)
|
||||||
|
@ -69,7 +69,7 @@ def suggest(json_data):
|
||||||
with open("apps/"+i) as json_file:
|
with open("apps/"+i) as json_file:
|
||||||
idata = json.load(json_file)
|
idata = json.load(json_file)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error!", e)
|
print("Error!", i, e)
|
||||||
idata = {}
|
idata = {}
|
||||||
|
|
||||||
all_apps.append(idata)
|
all_apps.append(idata)
|
||||||
|
@ -81,12 +81,14 @@ def suggest(json_data):
|
||||||
for b in json_data.get(c, []):
|
for b in json_data.get(c, []):
|
||||||
if b in i.get(c, []):
|
if b in i.get(c, []):
|
||||||
score += 1
|
score += 1
|
||||||
print(score, "SCORE")
|
print(score, i.get("names",["no name"])[0], "SCORE")
|
||||||
found.append([score, i])
|
found.append([score, i])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
found = reversed(sorted(found))
|
found.sort(key=lambda x: x[0])
|
||||||
except:
|
found = list(reversed(found))
|
||||||
return []
|
except Exception as e:
|
||||||
|
print("Found problem:", e)
|
||||||
|
fount = []
|
||||||
|
|
||||||
return found
|
return found
|
||||||
|
|
Loading…
Reference in a new issue