<pre style='margin:0'>
Renee Otten (reneeotten) pushed a commit to branch master
in repository upt-macports.
</pre>
<p><a href="https://github.com/macports/upt-macports/commit/34e929493b09a8312d6bf2d21898be330108ca13">https://github.com/macports/upt-macports/commit/34e929493b09a8312d6bf2d21898be330108ca13</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new 34e9294 Add Archive type keyword and tests
</span>34e9294 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 34e929493b09a8312d6bf2d21898be330108ca13
</span>Author: Korusuke <karan.sheth@somaiya.edu>
AuthorDate: Thu May 23 05:18:44 2019 +0530
<span style='display:block; white-space:pre;color:#404040;'> Add Archive type keyword and tests
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Fixes: #3
</span>---
upt_macports/templates/base.Portfile | 8 +++++++-
upt_macports/tests/test_macports_package.py | 21 +++++++++++++++++++++
upt_macports/upt_macports.py | 20 ++++++++++++++++++++
3 files changed, 48 insertions(+), 1 deletion(-)
<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 7daf552..b3aa0e7 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;'>@@ -16,7 +16,13 @@ platforms darwin
</span> # supported_archs noarch
{% block dist_info %}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-{% endblock %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{% endblock -%}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{% if pkg.archive_type == 'unknown' -%}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Detection of archive type failed
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{% elif pkg.archive_type != 'gz' %}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{{ "use_%-15s yes"|format(pkg.archive_type) }}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{% endif %}
</span>
licenses {{ pkg.licenses }}
<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><span style='display:block; white-space:pre;color:#808080;'>index ca9807b..b876f67 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/upt_macports/tests/test_macports_package.py
</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;'>@@ -32,5 +32,26 @@ class TestMacPortsPackageLicenses(unittest.TestCase):
</span> self.assertEqual(self.package.licenses, expected)
<span style='display:block; white-space:pre;background:#e0ffe0;'>+class TestMacPortsPackageArchiveType(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_archive(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg.archives = []
</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.archive_type, expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_known_archive(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg.archives = [upt.Archive("url.co/dir/file.tar.gz")]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ expected = 'gz'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.assertEqual(self.package.archive_type, expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def test_unknown_archive(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.package.upt_pkg.archives = [upt.Archive("url.co/dir/file.rar")]
</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.archive_type, expected)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> if __name__ == '__main__':
unittest.main()
<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 e609029..f5676db 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;'>@@ -51,6 +51,26 @@ class MacPortsPackage(object):
</span> def test_depends(self):
return self._depends('test')
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ @property
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ def archive_type(self):
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ archive_keyword = {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'gz': 'gz',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ '7z': '7z',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'bz2': 'bzip2',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'lzma': 'lzma',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'tar': 'tar',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'zip': 'zip',
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 'xz': 'xz'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ try:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ archive_name = self.upt_pkg.get_archive().filename
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ archive_type = archive_name.split('.')[-1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return archive_keyword.get(archive_type, 'unknown')
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ except upt.ArchiveUnavailable:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ self.logger.error('Could not determine the type of the source archive') # noqa
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 'unknown'
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span>
class MacPortsPythonPackage(MacPortsPackage):
template = 'python.Portfile'
</pre><pre style='margin:0'>
</pre>