This commit is contained in:
ge committed 2025-01-22 03:23:08 +03:00
commit d5931aa5e0
13 files changed
+8849

No files matched your search

+65
View File
@@ -0,0 +1,65 @@
module licenseid
import json
import net.http
const licenses_file = $embed_file('licenselist.min.json')
const licenses = json.decode(LicenseList, licenses_file.to_string()) or { LicenseList{} }
struct LicenseList {
licenses []License
}
pub struct License {
pub:
license_id string @[json: licenseId]
name string
reference string
reference_number int @[json: referenceNumber]
details_url string @[json: detailsUrl]
is_osi_approved bool @[json: isOsiApproved]
is_deprecated_license_id bool @[json: isDeprecatedLicenseId]
see_also []string @[json: seeAlso]
}
pub struct LicenseDetails {
pub:
license_id string @[json: licenseId]
name string
license_text string @[json: licenseText]
license_text_html string @[json: licenseTextHtml]
license_template string @[json: standardLicenseTemplate]
is_osi_approved bool @[json: isOsiApproved]
is_deprecated_license_id bool @[json: isDeprecatedLicenseId]
cross_ref []Reference @[json: crossRef]
see_also []string @[json: seeAlso]
}
pub struct Reference {
pub:
match string
url string
is_valid bool @[json: isValid]
is_live bool @[json: isLive]
is_way_backlink bool @[json: isWayBackLink]
timestamp string
order int
}
// details fetches the license details object from SPDX data file using the
// details_url. Requires access to public network.
pub fn (l License) details() !LicenseDetails {
response := http.get(l.details_url)!
details := json.decode(LicenseDetails, response.body)!
return details
}
// query returns license object from embedded SPDX license list data file.
pub fn query(license_id string) !License {
for license in licenses.licenses {
if license.license_id == license_id {
return license
}
}
return error('${license_id} is not valid SPDX license ID')
}
+8533
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
{"licenseListVersion":"3.26.0","licenses":[{"reference":"https://spdx.org/licenses/DSDP.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/DSDP.json","referenceNumber":0,"name":"DSDP License","licenseId":"DSDP","seeAlso":["https://fedoraproject.org/wiki/Licensing/DSDP"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/NIST-PD.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/NIST-PD.json","referenceNumber":1,"name":"NIST Public Domain Notice","licenseId":"NIST-PD","seeAlso":["https://github.com/tcheneau/simpleRPL/blob/e645e69e38dd4e3ccfeceb2db8cba05b7c2e0cd3/LICENSE.txt","https://github.com/tcheneau/Routing/blob/f09f46fcfe636107f22f2c98348188a65a135d98/README.md"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/CC-BY-NC-SA-2.0.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/CC-BY-NC-SA-2.0.json","referenceNumber":2,"name":"Creative Commons Attribution Non Commercial Share Alike 2.0 Generic","licenseId":"CC-BY-NC-SA-2.0","seeAlso":["https://creativecommons.org/licenses/by-nc-sa/2.0/legalcode"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/NLOD-1.0.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/NLOD-1.0.json","referenceNumber":3,"name":"Norwegian Licence for Open Government Data (NLOD) 1.0","licenseId":"NLOD-1.0","seeAlso":["http://data.norge.no/nlod/en/1.0"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/RHeCos-1.1.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/RHeCos-1.1.json","referenceNumber":4,"name":"Red Hat eCos Public License v1.1","licenseId":"RHeCos-1.1","seeAlso":["http://ecos.sourceware.org/old-license.html"],"isOsiApproved":false,"isFsfLibre":false},{"reference":"https://spdx.org/licenses/GFDL-1.3-no-invariants-only.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/GFDL-1.3-no-invariants-only.json","referenceNumber":5,"name":"GNU Free Documentation License v1.3 only - no invariants","licenseId":"GFDL-1.3-no-invariants-only","seeAlso":["https://www.gnu.org/licenses/fdl-1.3.txt"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/RSCPL.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/RSCPL.json","referenceNumber":6,"name":"Ricoh Source Code Public License","licenseId":"RSCPL","seeAlso":["http://wayback.archive.org/web/20060715140826/http://www.risource.org/RPL/RPL-1.0A.shtml","https://opensource.org/licenses/RSCPL"],"isOsiApproved":true},{"reference":"https://spdx.org/licenses/ASWF-Digital-Assets-1.1.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/ASWF-Digital-Assets-1.1.json","referenceNumber":7,"name":"ASWF Digital Assets License 1.1","licenseId":"ASWF-Digital-Assets-1.1","seeAlso":["https://github.com/AcademySoftwareFoundation/foundation/blob/main/digital_assets/aswf_digital_assets_license_v1.1.txt"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/eCos-2.0.html","isDeprecatedLicenseId":true,"detailsUrl":"https://spdx.org/licenses/eCos-2.0.json","referenceNumber":8,"name":"eCos license version 2.0","licenseId":"eCos-2.0","seeAlso":["https://www.gnu.org/licenses/ecos-license.html"],"isOsiApproved":false,"isFsfLibre":true},{"reference":"https://spdx.org/licenses/GLWTPL.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/GLWTPL.json","referenceNumber":9,"name":"Good Luck With That Public License","licenseId":"GLWTPL","seeAlso":["https://github.com/me-shaon/GLWTPL/commit/da5f6bc734095efbacb442c0b31e33a65b9d6e85"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/Info-ZIP.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/Info-ZIP.json","referenceNumber":10,"name":"Info-ZIP License","licenseId":"Info-ZIP","seeAlso":["http://www.info-zip.org/license.html"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/LPPL-1.3c.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/LPPL-1.3c.json","referenceNumber":11,"name":"LaTeX Project Public License v1.3c","licenseId":"LPPL-1.3c","seeAlso":["http://www.latex-project.org/lppl/lppl-1-3c.txt","https://opensource.org/licenses/LPPL-1.3c"],"isOsiApproved":true},{"reference":"https://spdx.org/licenses/zlib-acknowledgement.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/zlib-acknowledgement.json","referenceNumber":12,"name":"zlib/libpng License with Acknowledgement","licenseId":"zlib-acknowledgement","seeAlso":["https://fedoraproject.org/wiki/Licensing/ZlibWithAcknowledgement"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/checkmk.html","isDeprecatedLicenseId":false,"detailsUrl":"https://spdx.org/licenses/checkmk.json","referenceNumber":13,"name":"Checkmk License","licenseId":"checkmk","seeAlso":["https://github.com/libcheck/check/blob/master/checkmk/checkmk.in"],"isOsiApproved":false},{"reference":"https://spdx.org/licenses/OLLine truncated