lauromoura pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=abaa90cfc20529f1507864e7b2d38ef69a16ded4

commit abaa90cfc20529f1507864e7b2d38ef69a16ded4
Author: Lauro Moura <[email protected]>
Date:   Tue Nov 26 11:56:31 2019 -0300

    pyolian: Add a method to get the hierarchy of extensions
    
    Summary:
    To be used by the test generator
    
    Depends on D10420
    
    Test Plan: test in the diff
    
    Reviewers: DaveMDS, herb, segfaultxavi, felipealmeida
    
    Reviewed By: felipealmeida
    
    Subscribers: cedric, brunobelo, #reviewers, felipealmeida, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D10421
---
 src/scripts/pyolian/eolian.py      | 17 +++++++++++++++++
 src/scripts/pyolian/test_eolian.py |  8 ++++++++
 2 files changed, 25 insertions(+)

diff --git a/src/scripts/pyolian/eolian.py b/src/scripts/pyolian/eolian.py
index 31f4f06f44..eababfadba 100644
--- a/src/scripts/pyolian/eolian.py
+++ b/src/scripts/pyolian/eolian.py
@@ -732,6 +732,23 @@ class Class(Object):
     def extensions(self):
         return Iterator(Class, lib.eolian_class_extensions_get(self))
 
+    @cached_property
+    def extensions_hierarchy(self):
+        visited = set()
+        queue = [ext for ext in self.extensions]
+
+        while queue:
+            current = queue.pop()
+
+            if current in visited:
+                continue
+
+            visited.add(current)
+
+            queue.extend(current.extensions)
+
+        return visited
+
     @cached_property
     def inherits_full(self):
         li = []
diff --git a/src/scripts/pyolian/test_eolian.py 
b/src/scripts/pyolian/test_eolian.py
index b6090c661e..133b279084 100755
--- a/src/scripts/pyolian/test_eolian.py
+++ b/src/scripts/pyolian/test_eolian.py
@@ -704,3 +704,11 @@ class TestEolianInherits(object):
     def test_inherits_full(self, eolian_db):
         cls = eolian_db.class_by_name_get('Efl.Ui.Widget')
         assert 'Efl.Object' in cls.inherits_full
+
+    def test_extensions_hierarchy(self, eolian_db):
+        cls = eolian_db.class_by_name_get('Efl.Ui.Widget')
+
+        # inherited extension
+        assert any(x.name == 'Efl.Gfx.Stack' for x in cls.extensions_hierarchy)
+        # direct extension
+        assert any(x.name == 'Efl.Access.Object' for x in 
cls.extensions_hierarchy)

-- 


Reply via email to