aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDafydd Harries <daf@rhydd.org>2013-03-18 15:56:50 -0400
committerDafydd Harries <daf@rhydd.org>2013-03-18 15:56:50 -0400
commited5ca84e96e5c84cd35e5a387471eb3165d66174 (patch)
tree588120992704a4d1de29926188dd8a53d6731f37
parentac5c04d05661a66b4ea4ed622020a9c0e9ffd108 (diff)
refactor license extraction
-rw-r--r--export.py60
1 files changed, 32 insertions, 28 deletions
diff --git a/export.py b/export.py
index 934f70f..91e19a0 100644
--- a/export.py
+++ b/export.py
@@ -65,6 +65,34 @@ def get_license_map():
return map
+def srcpkg_extract_licenses(header, filess):
+ # XXX: generate template from header stanza
+ # XXX: flag CC licenses
+ # XXX: check all License stanzas were included
+ lmap = get_license_map()
+
+ for (_ix, files) in filess.iterrows():
+ lname = files['_license'].strip()
+
+ if '\n' not in lname:
+ # Looks like license text is present.
+ txt = files['License']
+ else:
+ # Licens information is a stub.
+ # XXX: look it up
+ txt = lname
+
+ canon = lmap.get(lname.lower(), 'Other')
+ cp = ''.join(
+ u'© %s\n' % line
+ for line in files['Copyright'].splitlines())
+ cp = cp.encode('utf8')
+ txt = txt.encode('utf8')
+
+ yield Template('Project license', [
+ ('License', canon),
+ ('License note', (cp + '\n' + txt))])
+
def export(pkgs, descs, cps, cpf, name):
pkg_cps = cps[cps['Upstream-Name'] == name]
srcpkg_names = list(pkg_cps['_srcpkg'])
@@ -109,9 +137,8 @@ def export(pkgs, descs, cps, cpf, name):
('Status', ''),
('Is GNU', 'No')])
- lmap = get_license_map()
-
for srcpkg in srcpkg_names:
+ pkg_cps = cps[cps['_srcpkg'] == srcpkg].ix[0]
pkg_cpf = cpf[cpf['_srcpkg'] == srcpkg]
#licenses = license.parse_licenses(list(pkg_cpf['_license']))
#licenses = [
@@ -120,32 +147,9 @@ def export(pkgs, descs, cps, cpf, name):
#print licenses
#all = set(concat(l.flatten() for l in licenses))
- for (_ix, files) in pkg_cpf.iterrows():
- lname = files['_license'].strip()
-
- if '\n' not in lname:
- # Looks like license text is present.
- txt = files['License']
- else:
- # Licens information is a stub.
- # XXX: look it up
- txt = lname
-
- canon = lmap.get(lname.lower(), 'Other')
- cp = ''.join(
- u'© %s\n' % line
- for line in files['Copyright'].splitlines())
- cp = cp.encode('utf8')
- txt = txt.encode('utf8')
-
- print Template('Project license', [
- ('License', canon),
- ('License note', (cp + '\n' + txt))])
-
- # XXX: eliminate duplicates
- # XXX: check all License stanzas were included
- # XXX: generate template from header stanza
- # XXX: flag CC licenses
+ for template in srcpkg_extract_licenses(pkg_cps, pkg_cpf):
+ # XXX: eliminate duplicates
+ print template
print Template('Person', [
('Real name', ''),