Dopsána a trochu otestována funkce get_upper_node_of_type
This commit is contained in:
parent
9e4491a64e
commit
09c1d21257
1 changed files with 11 additions and 0 deletions
|
@ -217,6 +217,17 @@ def get_prev_node_of_type(node, type):
|
|||
return current
|
||||
return None
|
||||
|
||||
def get_upper_node_of_type(node, type):
|
||||
# vrací první vyšší node daného typu (ignoruje sourozence)
|
||||
if node is None:
|
||||
return
|
||||
current = node
|
||||
while get_parent(current) is not None:
|
||||
current = get_parent(current)
|
||||
if isinstance(current, type):
|
||||
return current
|
||||
return None
|
||||
|
||||
|
||||
|
||||
# Exception, kterou některé metody při špatném použití mohou házet
|
||||
|
|
Loading…
Reference in a new issue