Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (36 sloc) 3.28 KB
# -*- coding: utf-8 -*-
import re
import requests
import codecs
import os.path
import os
from HTMLParser import HTMLParser
import json
h = HTMLParser()
licenses = [x for x in os.listdir('.') if '.html' in x]
database = []
for license in licenses:
with, 'r', 'utf-8') as myfile:
data =
name = [h.unescape(x) for x in re.findall('<code property="spdx:name">(.*?)</code>', data)][0]
shortname = [h.unescape(x) for x in re.findall('<code property="spdx:licenseId">(.*?)</code>', data)][0]
res = re.findall('<div property="spdx:licenseText" class="license-text">(.*?)</div>', data, re.MULTILINE | re.DOTALL)
license = ' '.join(re.sub('<[^<]+?>', '', h.unescape(res[0])).split())
res = re.findall('<div property="spdx:standardLicenseHeader" class="license-text">(.*?)</div>', data, re.MULTILINE | re.DOTALL)
header = ' '.join(re.sub('<[^<]+?>', '', h.unescape(res[0])).split())
if 'There is no standard license header for the license' in header:
header = ''
'fullname': name,
'shortname': shortname,
'text': license,
'header': header
'fullname': 'Fair Source License v0.9',
'shortname': "Fair-Source-0.9",
'text': 'Fair Source License, version 0.9 Copyright (C) [year] [copyright owner] Licensor: [legal name of licensor] Software: [name software and version if applicable] Use Limitation: [number] users License Grant. Licensor hereby grants to each recipient of the Software (\"you\") a non-exclusive, non-transferable, royalty-free and fully-paid-up license, under all of the Licensor’s copyright and patent rights, to use, copy, distribute, prepare derivative works of, publicly perform and display the Software, subject to the Use Limitation and the conditions set forth below. Use Limitation. The license granted above allows use by up to the number of users per entity set forth above (the \"Use Limitation\"). For determining the number of users, \"you\" includes all affiliates, meaning legal entities controlling, controlled by, or under common control with you. If you exceed the Use Limitation, your use is subject to payment of Licensor’s then-current list price for licenses. Conditions. Redistribution in source code or other forms must include a copy of this license document to be provided in a reasonable manner. Any redistribution of the Software is only allowed subject to this license. Trademarks. This license does not grant you any right in the trademarks, service marks, brand names or logos of Licensor. DISCLAIMER. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OR CONDITION, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. LICENSORS HEREBY DISCLAIM ALL LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE. Termination. If you violate the terms of this license, your rights will terminate automatically and will not be reinstated without the prior written consent of Licensor. Any such termination will not affect the right of others who may have received copies of the Software from you.',
'header': ''
print json.dumps(database)