Explains the use of loadyaml() to create new Table/View widgets.
Tables and Views are generally defined using the YAML syntax, as described in other topic pages. YAML files are typically loaded as part of a Python module so that they can be natively imported.
An example of this is the EthPortTable. The EthPortTable widget is defined by the YAML file "ethport.yml". The definition is imported using a short Python module, "ethport.py", that looks like this:
Pythonifier for EthPort Table/View
The above "pythonifier" uses the Junos PyEZ loadyaml() routine to load the YAML file and then import it into the global namespace of the module (line 7). In doing this, the user simply has do to the following to include the EthPortTable:
You can manually load Table/View definitions using loadyaml() as well, with or without the use of the "pythonifier" wrappers.
Let's say that you have a YAML file called "myfoo.yml" that defines a table called "MyFooTable" and a view called "MyFooView". Here is the process to load (factory) the widgets:
The mydefs variable acts like as a container or namespace for the widgets. You could import the widgets directly into the global namespace by doing the following:
Alternatively, you could use the widget definitions from the mydefs container, and avoid cluttering your global namespace: