Browse Source

Merge "Fix user profile display"

tags/2.8.1
Zuul 9 months ago
parent
commit
632d57449b
2 changed files with 13 additions and 2 deletions
  1. 8
    2
      bindep/depends.py
  2. 5
    0
      bindep/tests/test_depends.py

+ 8
- 2
bindep/depends.py View File

@@ -273,8 +273,14 @@ class Depends(object):
273 273
     def profiles(self):
274 274
         profiles = set()
275 275
         for rule in self._rules:
276
-            for _, selector in rule[1]:
277
-                profiles.add(selector)
276
+            # Partition rules, but keep only the user ones
277
+            _, user_profiles = self._partition(rule)
278
+            for profile in user_profiles:
279
+                # Flatten a series of AND conditionals in a user rule
280
+                if isinstance(profile, list):
281
+                    profiles.update([rule[1] for rule in profile])
282
+                elif isinstance(profile, tuple):
283
+                    profiles.add(profile[1])
278 284
         return sorted(profiles)
279 285
 
280 286
     def codenamebits(self, distro_id, codename):

+ 5
- 0
bindep/tests/test_depends.py View File

@@ -67,6 +67,11 @@ class TestDepends(TestCase):
67 67
         depends = Depends("")
68 68
         self.assertEqual([], depends.profiles())
69 69
 
70
+    def test_3tuple(self):
71
+        depends = Depends(u"erlang [(infra rabbitmq hipe)]\n")
72
+        self.assertEqual(sorted([u'infra', u'rabbitmq', u'hipe']),
73
+                         depends.profiles())
74
+
70 75
     def test_platform_profiles_succeeds(self):
71 76
         with DistroFixture('Ubuntu'):
72 77
             depends = Depends("")

Loading…
Cancel
Save