Checks if all licenses are free before marking the software as free
This commit is contained in:
parent
9af4f6088c
commit
7f5f921fc0
4 changed files with 28 additions and 5 deletions
8
licenses.json
Normal file
8
licenses.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"licenses": [
|
||||||
|
"GNU GPL v3.0",
|
||||||
|
"GPL3",
|
||||||
|
"GPL3+",
|
||||||
|
"MIT"
|
||||||
|
]
|
||||||
|
}
|
BIN
modules/__pycache__/render.cpython-310.pyc
Normal file
BIN
modules/__pycache__/render.cpython-310.pyc
Normal file
Binary file not shown.
BIN
modules/__pycache__/search.cpython-310.pyc
Normal file
BIN
modules/__pycache__/search.cpython-310.pyc
Normal file
Binary file not shown.
|
@ -7,6 +7,21 @@
|
||||||
# your ability to set it up and running.
|
# your ability to set it up and running.
|
||||||
|
|
||||||
from modules import search
|
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):
|
def html(page, json):
|
||||||
|
|
||||||
|
@ -18,11 +33,10 @@ def html(page, json):
|
||||||
# the four essential freedoms.
|
# the four essential freedoms.
|
||||||
|
|
||||||
free = False
|
free = False
|
||||||
|
has_license = False
|
||||||
if "licenses" in json and json["licenses"]:
|
if "licenses" in json and json["licenses"]:
|
||||||
free = True
|
has_license = True
|
||||||
|
free = isFree(json["licenses"])
|
||||||
|
|
||||||
|
|
||||||
page = page + "\n <h1>"
|
page = page + "\n <h1>"
|
||||||
try:
|
try:
|
||||||
page = page + '\n<img src="'+ json["links"]["icon"] + '" alt="Logo" style="width:50px;">'
|
page = page + '\n<img src="'+ json["links"]["icon"] + '" alt="Logo" style="width:50px;">'
|
||||||
|
@ -122,7 +136,8 @@ def suggestions(page, json):
|
||||||
|
|
||||||
free = False
|
free = False
|
||||||
if "licenses" in i[-1] and i[-1]["licenses"]:
|
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:
|
if not i[0] or i[-1] == json or not free:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue