import re from core.conversion import noop_logger def evaluate(llm, zip, readme, log_fn=noop_logger): log_fn("TITLE", "\nEvaluating repository licensing...") overall = "No" license_files = [license_path for license_path in zip.namelist() if ((("license" in license_path.lower())) & (len(license_path.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_fn("LOG", f"Found license: {ans}") else: log_fn("LOG", f"Found license file: {license_files[0]}") overall = "Yes" return overall for readme_file in readme: if ("license" in readme_file.lower()): log_fn("LOG", "License found in README.") overall = "Yes" return overall log_fn("ERROR", "LICENSE file not found.") return overall