<pre style='margin:0'>
Cyril Roelandt (Steap) pushed a commit to branch master
in repository upt-macports.
</pre>
<p><a href="https://github.com/macports/upt-macports/commit/bb4e67ed3779359cbf5213f3e48b023b010dff07">https://github.com/macports/upt-macports/commit/bb4e67ed3779359cbf5213f3e48b023b010dff07</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit bb4e67ed3779359cbf5213f3e48b023b010dff07
</span>Author: Korusuke <karan.sheth@somaiya.edu>
AuthorDate: Thu May 9 18:16:24 2019 +0530
<span style='display:block; white-space:pre;color:#404040;'> Add support for license conversion and Include tests
</span>---
MANIFEST.in | 1 +
upt_macports/spdx2macports.json | 78 +++++++++++++++++++++++++++++
upt_macports/templates/base.Portfile | 6 +--
upt_macports/tests/test_macports_package.py | 36 +++++++++++++
upt_macports/upt_macports.py | 12 +++++
5 files changed, 128 insertions(+), 5 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/MANIFEST.in b/MANIFEST.in
</span><span style='display:block; white-space:pre;color:#808080;'>index 71b2470..6e0d354 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/MANIFEST.in
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/MANIFEST.in
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2,4 +2,5 @@ include CHANGELOG
</span> include LICENSE
include README.md
include tox.ini
<span style='display:block; white-space:pre;background:#e0ffe0;'>+include upt_macports/spdx2macports.json
</span> include upt_macports/templates/*
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/upt_macports/spdx2macports.json b/upt_macports/spdx2macports.json
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..4a97730
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/upt_macports/spdx2macports.json
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,78 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "0BSD": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "AFL-2.1": "AFL-2.1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "AFL-3.0": "AFL-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "AGPL-1.0": "GPL-1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "AGPL-1.0-only": "GPL-1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "AGPL-1.0-or-later": "GPL-1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "AGPL-3.0": "AGPL-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "AGPL-3.0-only": "AGPL-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "AGPL-3.0-or-later": "AGPL-3+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "AMPAS": "AMPAS",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "APSL-1.0": "APSL",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "APSL-1.1": "APSL-1.1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "APSL-1.2": "APSL-1.2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "APSL-2.0": "APSL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Apache-1.0": "Apache",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Apache-1.1": "Apache-1.1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Apache-2.0": "Apache-2.0",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Artistic-1.0": "Artistic-1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Artistic-1.0-Perl": "Artistic-1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Artistic-1.0-cl8": "Artistic-1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Artistic-2.0": "Artistic-2.0",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-1-Clause": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-2-Clause": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-2-Clause-FreeBSD": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-2-Clause-NetBSD": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-2-Clause-Patent": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-3-Clause": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-3-Clause-Attribution": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-3-Clause-Clear": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-3-Clause-LBNL": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-3-Clause-No-Nuclear-License": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-3-Clause-No-Nuclear-License-2014": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-3-Clause-No-Nuclear-Warranty": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-4-Clause": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-4-Clause-UC": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-Protection": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "BSD-Source-Code": "BSD",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "Beerware": "Beerware",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CC-BY-1.0": "CC-BY",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CC-BY-NC-SA-3.0": "CC-BY-NC-SA-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CC-BY-SA-1.0": "CC-BY-SA",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CC-BY-SA-3.0": "CC-BY-SA-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "CC-BY-SA-4.0": "CC-BY-SA-4",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-1.0": "GPL-1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-1.0+": "GPL-1+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-1.0-only": "GPL-1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-1.0-or-later": "GPL-1+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-2.0": "GPL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-2.0+": "GPL-2+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-2.0-only": "GPL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-2.0-or-later": "GPL-2+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-2.0-with-GCC-exception": "GPL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-2.0-with-autoconf-exception": "GPL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-2.0-with-bison-exception": "GPL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-2.0-with-classpath-exception": "GPL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-2.0-with-font-exception": "GPL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-3.0": "GPL-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-3.0+": "GPL-3+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-3.0-only": "GPL-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-3.0-or-later": "GPL-3+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-3.0-with-GCC-exception": "GPL-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "GPL-3.0-with-autoconf-exception": "GPL-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-2.0": "LGPL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-2.0+": "LGPL-2+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-2.0-only": "LGPL-2",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-2.0-or-later": "LGPL-2+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-2.1": "LGPL-2.1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-2.1+": "LGPL-2.1+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-2.1-only": "LGPL-2.1",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-2.1-or-later": "LGPL-2.1+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-3.0": "LGPL-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-3.0+": "LGPL-3+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-3.0-only": "LGPL-3",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "LGPL-3.0-or-later": "LGPL-3+",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "MIT": "MIT",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ "MIT-0": "MIT"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/upt_macports/templates/base.Portfile b/upt_macports/templates/base.Portfile
</span><span style='display:block; white-space:pre;color:#808080;'>index ebf002a..7daf552 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/upt_macports/templates/base.Portfile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/upt_macports/templates/base.Portfile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -18,11 +18,7 @@ platforms darwin
</span> {% block dist_info %}
{% endblock %}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-{% if pkg.upt_pkg.licenses|length > 0 %}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-license {% for i in pkg.upt_pkg.licenses %}{{i.name}}{% endfor %}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-{% else %}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-license unknown
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-{% endif %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+licenses {{ pkg.licenses }}
</span>
checksums sha256 {{ pkg.upt_pkg.archives[0].sha256 }} \
rmd160 {{ pkg.upt_pkg.archives[0].rmd160 }} \
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/upt_macports/tests/test_macports_package.py b/upt_macports/tests/test_macports_package.py
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..ca9807b
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/upt_macports/tests/test_macports_package.py
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,36 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+import unittest
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+import upt
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+from upt_macports.upt_macports import MacPortsPackage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+class TestMacPortsPackageLicenses(unittest.TestCase):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def setUp(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package = MacPortsPackage()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg = upt.Package('foo', '42')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_no_licenses(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg.licenses = []
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ expected = ''
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.assertEqual(self.package.licenses, expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_one_license(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg.licenses = [upt.licenses.BSDThreeClauseLicense()]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ expected = 'BSD'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.assertEqual(self.package.licenses, expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_bad_license(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg.licenses = [upt.licenses.UnknownLicense()]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ expected = 'unknown'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.assertEqual(self.package.licenses, expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_multiple_license(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg.licenses = [
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ upt.licenses.BSDTwoClauseLicense(),
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ upt.licenses.BSDThreeClauseLicense()
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ expected = 'BSD BSD'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.assertEqual(self.package.licenses, expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+if __name__ == '__main__':
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ unittest.main()
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/upt_macports/upt_macports.py b/upt_macports/upt_macports.py
</span><span style='display:block; white-space:pre;color:#808080;'>index b5982c4..e609029 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/upt_macports/upt_macports.py
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/upt_macports/upt_macports.py
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,6 +1,8 @@
</span> import upt
import logging
import jinja2
<span style='display:block; white-space:pre;background:#e0ffe0;'>+import pkg_resources
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+import json
</span>
class MacPortsPackage(object):
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -24,6 +26,16 @@ class MacPortsPackage(object):
</span> template = env.get_template(self.template)
return template.render(pkg=self)
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ @property
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def licenses(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ relpath = 'spdx2macports.json'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ filepath = pkg_resources.resource_filename(__name__, relpath)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ with open(filepath) as f:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ spdx2macports = json.loads(f.read())
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return ' '.join([spdx2macports.get(license.spdx_identifier, 'unknown')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for license in self.upt_pkg.licenses])
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> def _depends(self, phase):
return self.upt_pkg.requirements.get(phase, [])
</pre><pre style='margin:0'>
</pre>