pull: Convert 'uri' to the plural 'uris'
authorW. Trevor King <wking@tremily.us>
Sat, 30 Dec 2017 01:00:10 +0000 (17:00 -0800)
committerW. Trevor King <wking@tremily.us>
Sat, 30 Dec 2017 23:54:32 +0000 (15:54 -0800)
There are enough hacks here that we should make it easy for folks to
go back and double-check our calls.

README.md
pull.py

index 1365f67503a56e4ac137d5c994ce40cf74f60497..ed1d37c26498fea79ab40ad054c2d4bcaf3b9270 100644 (file)
--- 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 993fff7510ca8a1e2034c0bf900645d6eb4c495e..ec471cb6e32a16caf2aaa40ee2c05f6896c4ae01 100755 (executable)
--- 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(