Skip to content
Merged
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
52 changes: 52 additions & 0 deletions etc/scripts/osikeys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import json
import licensedcode.index
import urllib.request
from licensedcode.cache import get_index
from licensedcode.models import load_licenses


def find_osi_map(license: "OSI License Object"):
"""
Return Scancode key mapped to OSI License `license`
"""
Comment thread
pombredanne marked this conversation as resolved.
idx = get_index()
osi_key = license['id']
# search for Scancode License matching OSI Key
matches = list(idx.match(query_string = osi_key))
if not matches:
return None
return matches[0].rule.license_expression

Comment thread
pombredanne marked this conversation as resolved.

def add_osi_key(obj: "OSI License Object"):
"""
Add OSI License Key derived from OSI License Object `obj`
"""
licenses = licensedcode.cache.get_licenses_db()
# find matching Scancode License Object for `obj`
result = find_osi_map(obj)
# derive OSI License Key from `obj`
osi_key = obj['id']
if not result: # no matching Scancode License found
return None
mapped_license = licenses[result] # license object from Scancode
licenses_path = "src/licensedcode/data/licenses/" # licenses directory
file_to_modify = open(licenses_path + mapped_license.key + ".yml", "a")
file_to_modify.write("osi_license_key: " + osi_key)
file_to_modify.write("\n")


def add_osi_keys():
"""
For every possible OSI License, match and add OSI Key to existing Scancode License
"""
#retrieve OSI License Objects
contents = urllib.request.urlopen("https://api.opensource.org/licenses/").read().decode()
data = json.loads(contents)
# for each OSI License Object, update matching Scancode License Object
for obj in data:
add_osi_key(obj)


if __name__ == '__main__':
add_osi_keys()
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/adapt-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ osi_url: http://www.opensource.org/licenses/apl1.0.php
other_urls:
- http://www.opensource.org/licenses/APL-1.0
- https://opensource.org/licenses/APL-1.0
osi_license_key: APL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/afl-3.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ignorable_copyrights:
- Copyright (c) 2005 Lawrence Rosen
ignorable_holders:
- Lawrence Rosen
osi_license_key: AFL-3.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/agpl-3.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ ignorable_holders:
ignorable_urls:
- https://fsf.org/
- https://www.gnu.org/licenses/
osi_license_key: AGPL-3.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/apache-1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ ignorable_urls:
- http://www.apache.org/
ignorable_emails:
- apache@apache.org
osi_license_key: Apache-1.1
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/apache-2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ other_urls:
ignorable_urls:
- http://www.apache.org/licenses/
- http://www.apache.org/licenses/LICENSE-2.0
osi_license_key: Apache-2.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/apsl-2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ignorable_holders:
ignorable_urls:
- http://www.apple.com/legal/guidelinesfor3rdparties.html
- http://www.opensource.apple.com/apsl/
osi_license_key: APSL-2.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/artistic-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ other_urls:
- https://opensource.org/licenses/Artistic-1.0
ignorable_urls:
- http://ftp.uu.net/
osi_license_key: Artistic-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/artistic-2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ ignorable_authors:
- The Perl Foundation
ignorable_holders:
- The Perl Foundation
osi_license_key: Artistic-2.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/bsd-new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ osi_url: http://www.opensource.org/licenses/BSD-3-Clause
other_urls:
- http://framework.zend.com/license/new-bsd
- https://opensource.org/licenses/BSD-3-Clause
osi_license_key: BSD-3
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/ca-tosl-1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ ignorable_urls:
- http://www.ca.com/catrdmrk.htm
ignorable_emails:
- opensource@ca.com
osi_license_key: CATOSL-1.1
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/cddl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ other_urls:
- http://www.oracle.com/us/sun/index.html
- https://glassfish.dev.java.net/public/CDDLv1.0.html
- https://opensource.org/licenses/cddl1
osi_license_key: CDDL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/cecill-2.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ other_urls:
- http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.html
ignorable_urls:
- http://www.cecill.info/index.en.html
osi_license_key: CECILL-2.1
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/cnri-python-1.6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ignorable_holders:
ignorable_urls:
- http://hdl.handle.net/1895.22/1012
- http://www.python.org/
osi_license_key: CNRI-Python
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/cpal-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ osi_url: http://opensource.org/licenses/cpal_1.0
other_urls:
- http://www.opensource.org/licenses/CPAL-1.0
- https://opensource.org/licenses/CPAL-1.0
osi_license_key: CPAL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/cpl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ other_urls:
- http://www.ibm.com/developerworks/library/os-cplfaq.html
- http://www.padsproj.org/License.html
- https://opensource.org/licenses/CPL-1.0
osi_license_key: CPL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/cua-opl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ other_urls:
- https://opensource.org/licenses/CUA-OPL-1.0
ignorable_urls:
- http://cuaoffice.sourceforge.net/
osi_license_key: CUA-OPL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/ecl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ osi_url: http://opensource.org/licenses/ecl1.php
other_urls:
- http://opensource.org/licenses/ECL-1.0
- https://opensource.org/licenses/ECL-1.0
osi_license_key: ECL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/ecl-2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ ignorable_urls:
- http://www.apache.org/licenses/LICENSE-2.0
- http://www.osedu.org/licenses/
- http://www.osedu.org/licenses/ECL-2.0
osi_license_key: ECL-2.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/efl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ osi_url: http://www.opensource.org/licenses/ver1_eiffel.php
other_urls:
- http://opensource.org/licenses/EFL-1.0
- https://opensource.org/licenses/EFL-1.0
osi_license_key: EFL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/efl-2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ other_urls:
- http://opensource.org/licenses/EFL-2.0
- http://www.eiffel-nice.org/license/eiffel-forum-license-2.html
- https://opensource.org/licenses/EFL-2.0
osi_license_key: EFL-2.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/epl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ faq_url: http://eclipse.org/legal/eplfaq.php
other_urls:
- http://www.opensource.org/licenses/EPL-1.0
- https://opensource.org/licenses/EPL-1.0
osi_license_key: EPL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/eu-datagrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ ignorable_urls:
- http://www.eu-datagrid.org/
ignorable_emails:
- hep-project-grid-edg-license@cern.ch
osi_license_key: EUDatagrid
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/eupl-1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ ignorable_copyrights:
- (c) the European Community 2007
ignorable_holders:
- the European Community
osi_license_key: EUPL-1.1
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/gpl-2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ ignorable_copyrights:
ignorable_holders:
- Free Software Foundation, Inc.
- the Free Software Foundation
osi_license_key: GPL-2.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/gpl-3.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ ignorable_urls:
- https://fsf.org/
- https://www.gnu.org/licenses/
- https://www.gnu.org/licenses/why-not-lgpl.html
osi_license_key: GPL-3.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/ibmpl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ ignorable_copyrights:
- Copyright (c) 1996, 1999 International Business Machines Corporation and others
ignorable_holders:
- International Business Machines Corporation and others
osi_license_key: IPL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/lgpl-2.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ ignorable_copyrights:
ignorable_holders:
- Free Software Foundation, Inc.
- the Free Software Foundation
osi_license_key: LGPL-2.1
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/lgpl-3.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ ignorable_holders:
ignorable_urls:
- https://fsf.org/

osi_license_key: LGPL-3.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/lppl-1.3c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ignorable_holders:
- LaTeX3 Project
ignorable_urls:
- http://www.latex-project.org/lppl.txt
osi_license_key: LPPL-1.3c
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/lucent-pl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ osi_url: http://www.opensource.org/licenses/plan9.php
other_urls:
- http://opensource.org/licenses/LPL-1.0
- https://opensource.org/licenses/LPL-1.0
osi_license_key: LPL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/lucent-pl-1.02.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ ignorable_copyrights:
- Copyright (c) YEAR, ORGANIZATION and others
ignorable_holders:
- YEAR, ORGANIZATION and others
osi_license_key: LPL-1.02
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/mpl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ other_urls:
- https://opensource.org/licenses/MPL-1.0
ignorable_urls:
- http://www.mozilla.org/MPL/
osi_license_key: MPL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/mpl-1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ other_urls:
- https://opensource.org/licenses/MPL-1.1
ignorable_urls:
- http://www.mozilla.org/MPL/
osi_license_key: MPL-1.1
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/mpl-2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ other_urls:
- https://opensource.org/licenses/MPL-2.0
ignorable_urls:
- http://mozilla.org/MPL/2.0
osi_license_key: MPL-2.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/nasa-1.3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ ignorable_copyrights:
- Copyright YEAR United States Government as represented by
ignorable_holders:
- United States Government as represented by
osi_license_key: NASA-1.3
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/nosl-3.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ ignorable_copyrights:
- Copyright (c) 2005 Lawrence Rosen
ignorable_holders:
- Lawrence Rosen
osi_license_key: NPOSL-3.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/oclc-2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ ignorable_holders:
ignorable_urls:
- http://purl.oclc.org/oclc/research/ORPL
- http://www.oclc.org/oclc/research
osi_license_key: OCLC-2.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/ofl-1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ other_urls:
- https://opensource.org/licenses/OFL-1.1
ignorable_urls:
- http://scripts.sil.org/OFL
osi_license_key: OFL-1.1
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/opengroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ other_urls:
- http://www.opengroup.org/testing/downloads/The_Open_Group_TSL.txt
- http://www.opensource.org/licenses/OGTSL
- https://opensource.org/licenses/OGTSL
osi_license_key: OGTSL
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/osl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ignorable_copyrights:
- Copyright (c) 2002 Lawrence E. Rosen
ignorable_holders:
- Lawrence E. Rosen
osi_license_key: OSL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/osl-2.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ ignorable_copyrights:
- Copyright (c) 2003-2004 Lawrence E. Rosen
ignorable_holders:
- Lawrence E. Rosen
osi_license_key: OSL-2.1
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/osl-3.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ignorable_copyrights:
- Copyright (c) 2005 Lawrence Rosen
ignorable_holders:
- Lawrence Rosen
osi_license_key: OSL-3.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/qpl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ ignorable_copyrights:
- Copyright (c) 1999 Trolltech AS, Norway
ignorable_holders:
- Trolltech AS, Norway
osi_license_key: QPL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/rpl-1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ ignorable_holders:
- Technical Pursuit Inc.
ignorable_urls:
- http://www.technicalpursuit.com/
osi_license_key: RPL-1.1
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/rpl-1.5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ ignorable_copyrights:
- Copyright (c) 2001-2007 Technical Pursuit Inc.
ignorable_holders:
- Technical Pursuit Inc.
osi_license_key: RPL-1.5
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/rpsl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ ignorable_urls:
- https://www.helixcommunity.org/content/complicense
- https://www.helixcommunity.org/content/rcsl
- https://www.helixcommunity.org/content/rpsl
osi_license_key: RPSL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/spl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ other_urls:
- https://opensource.org/licenses/SPL-1.0
ignorable_urls:
- http://www.sun.com/
osi_license_key: SPL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/sun-sissl-1.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ other_urls:
ignorable_urls:
- http://api.openoffice.org/
- http://xml.openoffice.org/
osi_license_key: SISSL
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/sybase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ ignorable_holders:
- Sybase, Inc.
ignorable_urls:
- http://www.sybase.com/developer/opensource
osi_license_key: Watcom-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/vsl-1.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ ignorable_urls:
- http://www.vovida.org/
ignorable_emails:
- vocal@vovida.org
osi_license_key: VSL-1.0
1 change: 1 addition & 0 deletions src/licensedcode/data/licenses/zpl-2.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ other_urls:
- https://opensource.org/licenses/ZPL-2.0
ignorable_urls:
- http://www.zope.com/Marks
osi_license_key: ZPL-2.0
3 changes: 2 additions & 1 deletion src/licensedcode/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class License(object):
spdx_license_key = __attrib(default=None)
# list of other keys, such as deprecated ones
other_spdx_license_keys = __attrib(default=attr.Factory(list))

# OSI License Key
osi_license_key = __attrib(default=None)
# Various URLs for info
text_urls = __attrib(default=attr.Factory(list))
osi_url = __attrib(default=None)
Expand Down