mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
537 stars 344 forks source link

dump modified object to YANG #695

Open sispehar opened 4 years ago

sispehar commented 4 years ago

Question: Is there a way to 'dump' the contents of a modified object (ModSubmodStatement) to YANG. E.g. I'd like to add/remove statements from the module object and then store the new one. The pprint seems to be used for debugging as it adds some extra debug lines to the output.

mbj4668 commented 4 years ago

The "yang" plugin formats a module statement (tree) as yang. This is invoked with "pyang -f yang" on the command line.

You can write your code that modifies some statements as a "transform", and then do "pyang -t -f yang".

There is one builtin transform "edit", which can be used to do some simple transformations of modules. See the man page for details (and test code for examples)