Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
0b21f870
Commit
0b21f870
authored
May 13, 2018
by
eckhart
Browse files
- syntaxtree.Node.select: Bugfix!!!
parent
b2bc5810
Changes
2
Hide whitespace changes
Inline
Side-by-side
DHParser/syntaxtree.py
View file @
0b21f870
...
...
@@ -616,10 +616,9 @@ class Node(collections.abc.Sized):
"""
if
include_root
and
match_function
(
self
):
yield
self
else
:
for
child
in
self
.
children
:
for
node
in
child
.
select
(
match_function
,
True
):
yield
node
for
child
in
self
.
children
:
for
node
in
child
.
select
(
match_function
,
True
):
yield
node
def
select_by_tag
(
self
,
tag_names
:
Union
[
str
,
AbstractSet
[
str
]],
...
...
test/test_syntaxtree.py
View file @
0b21f870
...
...
@@ -75,6 +75,11 @@ class TestNode:
assert
str
(
self
.
unique_tree
)
==
"ceh"
assert
str
(
self
.
recurr_tree
)
==
"xey"
def
test_select_subnodes
(
self
):
tags
=
[
node
.
tag_name
for
node
in
self
.
unique_tree
.
select
(
lambda
nd
:
True
,
include_root
=
True
)]
assert
''
.
join
(
tags
)
==
"abdfg"
,
''
.
join
(
tags
)
def
test_find
(
self
):
found
=
list
(
self
.
unique_tree
.
select
(
lambda
nd
:
not
nd
.
children
and
nd
.
result
==
"e"
))
assert
len
(
found
)
==
1
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment