Contributed by Joshua R English, adapted by Oliver Schoenborn to be consistent with pubsub API.
An extension for pubsub (http://pubsub.sourceforge.net) so topic tree specification can be encoded in XML format rather than pubsub’s default Python nested class format.
To use:
- xml = ‘’‘
<topicdefntree> <description>Test showing topic hierarchy and inheritance</description> <topic id=”parent”>
<description>Parent with a parameter and subtopics</description> <listenerspec>
<arg id=”name” optional=”true”>given name</arg> <arg id=”lastname”>surname</arg></listenerspec>
- <topic id=”child”>
<description>This is the first child</description> <listenerspec>
<arg id=”nick”>A nickname</arg></listenerspec>
</topic>
</topic> </topicdefntree>
‘’‘
These topic definitions are loaded through an XmlTopicDefnProvider:
pub.addTopicDefnProvider( XmlTopicDefnProvider(xml) )
The XmlTopicDefnProvider also accepts a filename instead of XML string:
provider = XmlTopicDefnProvider(“path/to/XMLfile.xml”, TOPIC_TREE_FROM_FILE) pub.addTopicDefnProvider( provider )
Topics can be exported to an XML file using the exportTopicTreeSpecXml function. This will create a text file for the XML and return the string representation of the XML tree.
copyright: | Copyright since 2013 by Oliver Schoenborn, all rights reserved. |
---|---|
license: | BSD, see LICENSE_BSD_Simple.txt for details. |
exportTopicTreeSpecXml |
If rootTopic is None, then pub.getDefaultTopicTreeRoot() is assumed. |
indent |