Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPDX list of 598 common licenses (name, ID, URL...) #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions spdx_licenses.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# getwd()

download.file(url = "https://raw.githubusercontent.com/spdx/license-list-data/main/json/licenses.json",
destfile = "spdx_licenses.json")

spdx_licenses_1_v <- scan(
file="spdx_licenses.json",
sep="\n",
what="character"
)

spdx_licenses_2_v <- paste0(spdx_licenses_1_v, collapse = "")

# There is currently only one license with empty "seeAlso" slot, which needs to be changed
# (otherwise the rest fails)
spdx_licenses_3_v <-
gsub(pattern = '"seeAlso": [],',
replacement = '"seeAlso": [""],',
x = spdx_licenses_2_v,
fixed = T)

spdx_licenses_1_df <- dplyr::bind_rows(
lapply(rjson::fromJSON(spdx_licenses_3_v)[2]$licenses, as.data.frame)
)

# The above duplicates licenses that have various values for the seeAlso slot
# FIXME: For those duplicates, we keep only the first seeAlso value
# (still, in a number of cases, the additional "seeAlso" slot is just the same page at archive.org)
spdx_licenses_2_df <- dplyr::distinct(
spdx_licenses_1_df,
# Variables for checking uniqueness; this list does not include "seeAlso":
reference, isDeprecatedLicenseId, detailsUrl, referenceNumber, name, licenseId, isOsiApproved, isFsfLibre,
.keep_all = TRUE # Keep first value of "seeAlso"
)

write.csv(spdx_licenses_2_df,
file = "spdx_licenses.csv",
row.names = FALSE
)
Loading