pyang
pyang copied to clipboard
tree is not generated for YANG structures
pyang -f tree [email protected]
generates nothing. It should generate the tree representation. It produces no output.
Earlier the branch feature/yang-structure generated the tree. However now neither master nor structure branch generated anything.
this is being done in a separate branch. checkout feature/yang-structure to try it out. you need to do -f tree --tree-print-structure as well. it lacks some documentation, test cases and support for augment-structure currently
When there are augmented structures pyang throws a TypeError.
module foo {
namespace "urn:ietf:params:xml:ns:yang:foo";
prefix foo;
import ietf-yang-structure-ext { prefix sx; }
sx:structure foo-data {
container foo-con { }
}
}
module bar {
namespace "urn:ietf:params:xml:ns:yang:bar";
prefix bar;
import ietf-yang-structure-ext { prefix sx; }
import foo { prefix foo; }
sx:augment-structure /foo:foo-data/foo:foo-con {
leaf add-leaf1 { type int32; }
leaf add-leaf2 { type string; }
}
}
$ pyang foo.yang bar.yang -f tree --tree-print-structure
bar.yang:5: warning: imported module "foo" not used
module: foo
structure foo-data:
+-- foo-con
Traceback (most recent call last):
File "/Users/ahuangfeng/.pyenv/versions/3.9.5/bin/pyang", line 580, in <module>
run()
File "/Users/ahuangfeng/.pyenv/versions/3.9.5/bin/pyang", line 549, in run
emit_obj.emit(ctx, modules, fd)
File "/Users/ahuangfeng/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pyang/plugins/tree.py", line 92, in emit
emit_tree(ctx, modules, fd, ctx.opts.tree_depth,
File "/Users/ahuangfeng/.pyenv/versions/3.9.5/lib/python3.9/site-packages/pyang/plugins/tree.py", line 155, in emit_tree
del printed_header[:]
TypeError: 'bool' object does not support item deletion
@ahuangfeng Hi, I submitted a PR #849 to fix this crash, Please look at it, if OK, I'll merge it.
@ahuangfeng Hi, I submitted a PR #849 to fix this crash, Please look at it, if OK, I'll merge it.
Thanks a lot for the fixes (and sorry for the delay). I tested, it does not crash anymore:
$ pyang foo.yang bar.yang --tree-print-structure -f tree ─╯
bar.yang:5: warning: imported module "foo" not used
module: foo
structure foo-data:
+-- foo-con
module: bar
augment-structure /foo:foo-data/foo:foo-con:
+-- add-leaf1? int32
+-- add-leaf2? string
I have a warning saying that my parent yang module is not used, but it is used for the augmentation. Apart from this, all good.