Skip to content

Commit

Permalink
Fixed #884 - tree module header not printed
Browse files Browse the repository at this point in the history
  • Loading branch information
mbj4668 committed Mar 12, 2024
1 parent e3ff8ab commit 86df06f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pyang/plugins/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,23 @@ def print_help():
""")

def emit_tree(ctx, modules, fd, depth, llen, path):
printed_header = False

def print_header(module):
nonlocal printed_header
if not printed_header:
bstr = ""
b = module.search_one('belongs-to')
if b is not None:
bstr = " (belongs-to %s)" % b.arg
fd.write("%s: %s%s\n" % (module.keyword, module.arg, bstr))
printed_header = True
printed_header.append(None)

printed_header = []

for module in modules:
if printed_header:
fd.write("\n")
del printed_header[:]


chs = [ch for ch in module.i_children
if ch.keyword in statements.data_definition_keywords]
if path is not None and len(path) > 0:
Expand Down
2 changes: 2 additions & 0 deletions test/test_issues/test_i884/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
$(PYANG) -f tree a.yang b.yang | diff res.expect -
8 changes: 8 additions & 0 deletions test/test_issues/test_i884/a.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module a {
namespace urn:a;
prefix a;

leaf a {
type string;
}
}
9 changes: 9 additions & 0 deletions test/test_issues/test_i884/b.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module b {
namespace urn:b;
prefix b;

leaf b {
type string;
}

}
5 changes: 5 additions & 0 deletions test/test_issues/test_i884/res.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module: a
+--rw a? string

module: b
+--rw b? string

0 comments on commit 86df06f

Please sign in to comment.