pull: Add {scheme}/{id}.json hardlinks
authorW. Trevor King <wking@tremily.us>
Wed, 25 Oct 2017 18:05:19 +0000 (11:05 -0700)
committerW. Trevor King <wking@tremily.us>
Wed, 25 Oct 2017 18:19:16 +0000 (11:19 -0700)
commit94fe202d1b633f5f472a237df0875e6207055138
tree6148627838cdaa79beb28f8aba2fe7b261fb9dd5
parenta1be759aaea94fa1ec77207abc785941c9739d66
pull: Add {scheme}/{id}.json hardlinks

Putting additional metadata in the licenses.json index is a
slippery-slope.  This commit strips it down to an array of IDs, and
*all* per-license metadata must be fetched via a single-license
endpoint.

The new per-scheme links allow folks to retrieve per-license metadata
using their chosen scheme (assuming they trust the mapping maintained
in this API) without having to iterate over licenses.json retrieving
{FSF-id}.json until they find a match.  The OSI API uses the same
approach [1], although they currently have a fatter index [2,3,4,5].

os.link is implemented on Unix and Windows [6].  The ** recursive glob
pattern is new in Python 3.5 [7]; for older Pythons I'm falling back
to two non-recursive glob calls.

[1]: https://github.com/OpenSourceOrg/api/blob/c903651ef26c35202d6561b61b97d29ead1e08c5/doc/endpoints.md#licenseschemeidentifier
[2]: https://github.com/OpenSourceOrg/api/blob/c903651ef26c35202d6561b61b97d29ead1e08c5/doc/endpoints.md#licenses
[3]: https://github.com/OpenSourceOrg/api/blob/c903651ef26c35202d6561b61b97d29ead1e08c5/api.go#L52
[4]: https://github.com/OpenSourceOrg/api/blob/c903651ef26c35202d6561b61b97d29ead1e08c5/reload.go#L28
[5]: https://github.com/OpenSourceOrg/api/blob/c903651ef26c35202d6561b61b97d29ead1e08c5/license/license.go#L67
[6]: https://docs.python.org/3.6/library/os.html#os.link
[7]: https://docs.python.org/3.6/library/glob.html#glob.glob
README.md
pull.py