From: W. Trevor King Date: Sat, 30 Dec 2017 01:00:10 +0000 (-0800) Subject: pull: Convert 'uri' to the plural 'uris' X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ccf6b4265a5ca711019ce178eabba11ec88da87a;p=fsf-license-api.git pull: Convert 'uri' to the plural 'uris' There are enough hacks here that we should make it easy for folks to go back and double-check our calls. --- diff --git a/README.md b/README.md index 1365f67..ed1d37c 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,9 @@ Licenses have the following properties: * FSF ID: a short slug identifying the license. * `name`: a short string naming the license. -* `uri`: the FSF's recommendend URI for the license. +* `uris`: an array of URIs for the license. + The first entry in this array will always be an entry on the [the FSF's HTML page][fsf-list]. + The order of the remaining entries is not significant. * `tags`: an array of FSF categories for the license. The FSF currently defines the following categories: diff --git a/pull.py b/pull.py index 993fff7..ec471cb 100755 --- a/pull.py +++ b/pull.py @@ -243,11 +243,12 @@ def extract(root, base_uri=None): license['name'] = a.text.strip() else: continue + uris = ['{}#{}'.format(base_uri, oid)] uri = a.attrib.get('href') if uri: if base_uri: - uri = urllib.parse.urljoin(base=base_uri, url=uri) - license['uri'] = uri + uris.append(urllib.parse.urljoin(base=base_uri, url=uri)) + license['uris'] = uris identifiers = IDENTIFIERS.get(id) if identifiers: license['identifiers'] = identifiers @@ -255,6 +256,9 @@ def extract(root, base_uri=None): licenses[id] = license else: licenses[id]['tags'].update(tags) + for uri in uris: + if uri not in licenses[id]['uris']: + licenses[id]['uris'].append(uri) unused_splits = set(SPLITS.keys()).difference(oids) if unused_splits: raise ValueError('unused SPLITS keys: {}'.format(