Repository: macports/upt-macports

Issue:
Update port
The `py-upt-macports` port is currently generating defunct packages, including #11 and printing empty licence name (https://github.com/macports/macports-ports/pull/4489).

Can you please update the `Portfile`?

@rajdeepbharati 

Discussion:
reneeotten: @Korusuke this seems to work as intended, but the return-statement becomes a bit hard to decipher... not sure if that's a real issue but readability does count to a certain point. @Steap what do you think?
Steap: It is not super elegant, but having an "if/else" may not be that much better. I think it is down to personal preference here.
reneeotten: okay, let's merge this then

Patch:
diff --git a/upt_macports/upt_macports.py b/upt_macports/upt_macports.py
index a8bf18f..59e1fe4 100644
--- a/upt_macports/upt_macports.py
+++ b/upt_macports/upt_macports.py
@@ -32,7 +32,7 @@ class MacPortsPackage(object):
             spdx2macports = json.loads(f.read())
 
         return ' '.join([spdx2macports.get(license.spdx_identifier, 'unknown')
-                        for license in self.upt_pkg.licenses])
+                        for license in self.upt_pkg.licenses]) or 'unknown'
 
     def _depends(self, phase):
         return self.upt_pkg.requirements.get(phase, [])


Test patch:
diff --git a/upt_macports/tests/test_macports_package.py b/upt_macports/tests/test_macports_package.py
index b876f67..2b78a14 100644
--- a/upt_macports/tests/test_macports_package.py
+++ b/upt_macports/tests/test_macports_package.py
@@ -10,7 +10,7 @@ class TestMacPortsPackageLicenses(unittest.TestCase):
 
     def test_no_licenses(self):
         self.package.upt_pkg.licenses = []
-        expected = ''
+        expected = 'unknown'
         self.assertEqual(self.package.licenses, expected)
 
     def test_one_license(self):