Xpertians / xmonkey-namonica

Tool to translate PURLs into Legal Notices
https://osscompliance.blog
Apache License 2.0
0 stars 0 forks source link

Golang licensing #35

Closed oscarvalenzuelab closed 6 months ago

oscarvalenzuelab commented 6 months ago
def get_module_info(package_name, version):
    base_url = "https://proxy.golang.org"
    package_path = package_name.replace("/", "/")
    info_url = f"{base_url}/{package_path}/@v/{version}.info"

    response = requests.get(info_url)
    if response.status_code == 200:
        info = response.json()
        return info
    else:
        raise Exception(f"Failed to fetch module info for {package_name}@{version}: {response.status_code}")

def get_module_license(package_name, version):
    info = get_module_info(package_name, version)
    return info.get("license", "License information not available")
oscarvalenzuelab commented 6 months ago

Proposed code didn't worked as license it's not always present. moving to use detected license and SPDX for package license.