Checks if all licenses are free before marking the software as free

This commit is contained in:
BezierQuadratic 2022-04-02 00:10:18 +02:00
parent 9af4f6088c
commit 7f5f921fc0
4 changed files with 28 additions and 5 deletions

8
licenses.json Normal file
View file

@ -0,0 +1,8 @@
{
"licenses": [
"GNU GPL v3.0",
"GPL3",
"GPL3+",
"MIT"
]
}

Binary file not shown.

Binary file not shown.

View file

@ -7,6 +7,21 @@
# your ability to set it up and running.
from modules import search
import json
def isFree(licenses):
matches = 0
with open("licenses.json", "r") as data:
all_licenses = json.load(data)
for license in licenses:
for license2 in all_licenses["licenses"]:
if license2 == license:
matches = matches + 1
break
if matches == len(licenses):
return True
return False
def html(page, json):
@ -18,11 +33,10 @@ def html(page, json):
# the four essential freedoms.
free = False
has_license = False
if "licenses" in json and json["licenses"]:
free = True
has_license = True
free = isFree(json["licenses"])
page = page + "\n <h1>"
try:
page = page + '\n<img src="'+ json["links"]["icon"] + '" alt="Logo" style="width:50px;">'
@ -122,7 +136,8 @@ def suggestions(page, json):
free = False
if "licenses" in i[-1] and i[-1]["licenses"]:
free = True
has_license = True
free = isFree(i[-1]["licenses"])
if not i[0] or i[-1] == json or not free:
continue