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

Add script to help with Trove imports and update Trove data #92

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
99 changes: 99 additions & 0 deletions licenses/trove/trove.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
}
]
},
{
"id": "BSL-1.0",
"identifiers": [
{
"identifier": "License :: OSI Approved :: Boost Software License 1.0 (BSL-1.0)",
"scheme": "Trove"
}
]
},
{
"id": "CECILL-2.1",
"identifiers": [
Expand All @@ -62,6 +71,15 @@
}
]
},
{
"id": "CDDL-1.0",
"identifiers": [
{
"identifier": "License :: OSI Approved :: Common Development and Distribution License 1.0 (CDDL-1.0)",
"scheme": "Trove"
}
]
},
{
"id": "CPL-1.0",
"identifiers": [
Expand All @@ -71,6 +89,24 @@
}
]
},
{
"id": "EPL-1.0",
"identifiers": [
{
"identifier": "License :: OSI Approved :: Eclipse Public License 1.0 (EPL-1.0)",
"scheme": "Trove"
}
]
},
{
"id": "EPL-2.0",
"identifiers": [
{
"identifier": "License :: OSI Approved :: Eclipse Public License 2.0 (EPL-2.0)",
"scheme": "Trove"
}
]
},
{
"id": "EFL-2.0",
"identifiers": [
Expand All @@ -89,6 +125,15 @@
}
]
},
{
"id": "EUPL-1.2",
"identifiers": [
{
"identifier": "License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)",
"scheme": "Trove"
}
]
},
{
"id": "AGPL-3.0",
"identifiers": [
Expand Down Expand Up @@ -152,6 +197,15 @@
}
]
},
{
"id": "HPND",
"identifiers": [
{
"identifier": "License :: OSI Approved :: Historical Permission Notice and Disclaimer (HPND)",
"scheme": "Trove"
}
]
},
{
"id": "IPL-1.0",
"identifiers": [
Expand Down Expand Up @@ -197,6 +251,15 @@
}
]
},
{
"id": "MIT-0",
"identifiers": [
{
"identifier": "License :: OSI Approved :: MIT No Attribution License (MIT-0)",
"scheme": "Trove"
}
]
},
{
"id": "CVW",
"identifiers": [
Expand All @@ -206,6 +269,15 @@
}
]
},
{
"id": "MirOS",
"identifiers": [
{
"identifier": "License :: OSI Approved :: MirOS License (MirOS)",
"scheme": "Trove"
}
]
},
{
"id": "Motosoto",
"identifiers": [
Expand Down Expand Up @@ -269,6 +341,24 @@
}
]
},
{
"id": "OSL-3.0",
"identifiers": [
{
"identifier": "License :: OSI Approved :: Open Software License 3.0 (OSL-3.0)",
"scheme": "Trove"
}
]
},
{
"id": "PostgreSQL",
"identifiers": [
{
"identifier": "License :: OSI Approved :: PostgreSQL License",
"scheme": "Trove"
}
]
},
{
"id": "CNRI-Python",
"identifiers": [
Expand Down Expand Up @@ -305,6 +395,15 @@
}
]
},
{
"id": "OFL-1.1",
"identifiers": [
{
"identifier": "License :: OSI Approved :: SIL Open Font License 1.1 (OFL-1.1)",
"scheme": "Trove"
}
]
},
{
"id": "Sleepycat",
"identifiers": [
Expand Down
55 changes: 55 additions & 0 deletions licenses/trove/update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
# Script to update the imported Trove license data.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#
# Intended to be run in order to update trove.json with new Trove license
# identifiers, e.g. like this:
#
# ./scrape.py > trove-new.json
# ./update.py > trove-updated.json
# diff -u trove.json trove-updated.json
#
# # Now manually merge content from trove-updated.json into trove.json;
# # _might_ even execute this (at some time in future):
# #mv trove-updates.json trove.json

import json
from sys import stdout

def update():
with open('trove.json', 'r') as fc, open('trove-new.json', 'r') as fn:
trove_cur = json.load(fc)
trove_new = json.load(fn)

# keep it simple and just assume 1:1 mapping
id_mapping = {}
for lic in trove_cur:
osi_id = lic['id']
for id_ in lic['identifiers']:
if id_['scheme'] == 'Trove':
trove_id = id_['identifier']
id_mapping[trove_id] = osi_id

for lic in trove_new:
for id_ in lic['identifiers']:
if id_['scheme'] == 'Trove':
trove_id = id_['identifier']
if id_mapping.__contains__(trove_id):
lic['id'] = id_mapping[trove_id]

json.dump(trove_new, stdout, indent=4, sort_keys=True)

update()