Spaces:
Sleeping
Sleeping
File size: 1,066 Bytes
ccf0698 77f290b 69cbe77 77f290b ccf0698 77f290b eac755c 77f290b eac755c 77f290b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from .utils import log
import re
def evaluate(verbose, llm, zip, readme):
log(verbose, "TITLE", "\nEvaluating repository licensing...")
overall = "No"
license_files = [license for license in zip.namelist() if ((("LICENSE" in license) | ("license" in license)) & (len(license.split("/")) == 2))]
if (len(license_files) > 0):
license = zip.open(license_files[0]).read().decode("utf-8")
ans = [row for row in license.split("\n") if row != ""]
if (llm):
license = license
prompt = f"{license}. Please describe this type of license, what it allows and what it doesn't."
ans = llm.predict("HELP", prompt)
log(verbose, "LOG", f"Found license: {ans}")
else:
log(verbose, "LOG", f"Found license file: {license_files[0]}")
overall = "Yes"
return overall
if (readme):
if ("License" in readme):
log(verbose, "LOG", "License found in README.")
overall = "Yes"
return overall
log(verbose, "ERROR", "LICENSE file not found.")
return overall |