TNLData už umí vyrábět dummy vrcholy i jen ze seznamu TNLDat
This commit is contained in:
parent
9ba5c65326
commit
6e79237cef
1 changed files with 8 additions and 4 deletions
|
@ -106,16 +106,20 @@ class TNLData(object):
|
||||||
return out
|
return out
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def filter_treenode(cls, treenode, predicate):
|
def from_tnldata_list(cls, tnllist):
|
||||||
tnll = cls._filter_treenode_recursive(treenode, predicate) # TreeNodeList List :-)
|
"""Vyrobíme virtuální TNL, který nemá obsah, ale má za potomky všechna zadaná TNLData"""
|
||||||
# Teď vyrobíme virtuální TNL, který nemá obsah, ale má za potomky všecny nalezené TNLData
|
|
||||||
result = cls(None)
|
result = cls(None)
|
||||||
for idx, tnl in enumerate(tnll):
|
for idx, tnl in enumerate(tnllist):
|
||||||
result.children.append(tnl)
|
result.children.append(tnl)
|
||||||
tnl.parent = result
|
tnl.parent = result
|
||||||
tnl.index = idx
|
tnl.index = idx
|
||||||
return result
|
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
|
@classmethod
|
||||||
def _filter_treenode_recursive(cls, treenode, predicate):
|
def _filter_treenode_recursive(cls, treenode, predicate):
|
||||||
if predicate(treenode):
|
if predicate(treenode):
|
||||||
|
|
Loading…
Reference in a new issue