From 6e79237cefaf91619c346965a40c485956d5aa69 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Thu, 23 Apr 2020 00:40:15 +0200 Subject: [PATCH] =?UTF-8?q?TNLData=20u=C5=BE=20um=C3=AD=20vyr=C3=A1b=C4=9B?= =?UTF-8?q?t=20dummy=20vrcholy=20i=20jen=20ze=20seznamu=20TNLDat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/views/views_all.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index 9bb5276e..2e9bd864 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -106,16 +106,20 @@ class TNLData(object): return out @classmethod - def filter_treenode(cls, treenode, predicate): - tnll = cls._filter_treenode_recursive(treenode, predicate) # TreeNodeList List :-) - # Teď vyrobíme virtuální TNL, který nemá obsah, ale má za potomky všecny nalezené TNLData + def from_tnldata_list(cls, tnllist): + """Vyrobíme virtuální TNL, který nemá obsah, ale má za potomky všechna zadaná TNLData""" result = cls(None) - for idx, tnl in enumerate(tnll): + for idx, tnl in enumerate(tnllist): result.children.append(tnl) tnl.parent = result tnl.index = idx return result + @classmethod + def filter_treenode(cls, treenode, predicate): + tnll = cls._filter_treenode_recursive(treenode, predicate) # TreeNodeList List :-) + return TNLData.from_tnldata_list(tnll) + @classmethod def _filter_treenode_recursive(cls, treenode, predicate): if predicate(treenode):