<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=SEMToMediaWiki.py</id>
	<title>SEMToMediaWiki.py - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=SEMToMediaWiki.py"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=SEMToMediaWiki.py&amp;action=history"/>
	<updated>2026-04-11T22:19:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=SEMToMediaWiki.py&amp;diff=16572&amp;oldid=prev</id>
		<title>Hjmjohnson: Created page with '&lt;pre&gt;  #!python # \author Hans J. Johnson # # \description This python script is to help convert from # SEM xml documentation to a form suitable for posting on # a MediaWiki form…'</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=SEMToMediaWiki.py&amp;diff=16572&amp;oldid=prev"/>
		<updated>2010-06-07T14:12:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;&amp;lt;pre&amp;gt;  #!python # \author Hans J. Johnson # # \description This python script is to help convert from # SEM xml documentation to a form suitable for posting on # a MediaWiki form…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!python&lt;br /&gt;
# \author Hans J. Johnson&lt;br /&gt;
#&lt;br /&gt;
# \description This python script is to help convert from&lt;br /&gt;
# SEM xml documentation to a form suitable for posting on&lt;br /&gt;
# a MediaWiki format&lt;br /&gt;
#&lt;br /&gt;
# \usage python SEMToMediaWiki.py myProgramSEM.xml &amp;gt; MediaWikiFormattedText.txt&lt;br /&gt;
#&lt;br /&gt;
import sys&lt;br /&gt;
import pprint&lt;br /&gt;
&lt;br /&gt;
import xml.dom.minidom&lt;br /&gt;
from xml.dom.minidom import Node&lt;br /&gt;
&lt;br /&gt;
# Get this nodes text information.&lt;br /&gt;
def getTextValuesFromNode(nodelist):&lt;br /&gt;
    rc = []&lt;br /&gt;
    for node in nodelist:&lt;br /&gt;
        if node.nodeType == node.TEXT_NODE:&lt;br /&gt;
            rc.append(node.data)&lt;br /&gt;
    return ''.join(rc)&lt;br /&gt;
&lt;br /&gt;
# Create a formatted text string suitable for inclusion in a MediaWiki table&lt;br /&gt;
def getThisNodesInfoAsTextTableLine(executableNode,label):&lt;br /&gt;
    labelNodeList=executableNode.getElementsByTagName(label)&lt;br /&gt;
    if labelNodeList.length &amp;gt; 0 :&lt;br /&gt;
        labelNode=labelNodeList[0]  ## Only get the first one&lt;br /&gt;
        print &amp;quot;|Program %s || %s\n&amp;quot; % (label,getTextValuesFromNode(labelNode.childNodes) )&lt;br /&gt;
        print &amp;quot;|-&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Only get the text info for the matching label at this level of the tree&lt;br /&gt;
def getThisNodesInfoAsText(executableNode,label):&lt;br /&gt;
    labelNodeList=executableNode.getElementsByTagName(label)&lt;br /&gt;
    if labelNodeList.length &amp;gt; 0 :&lt;br /&gt;
        labelNode=labelNodeList[0]  ## Only get the first one&lt;br /&gt;
        return getTextValuesFromNode(labelNode.childNodes);&lt;br /&gt;
    return &amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Extract the long flag, and color the text string&lt;br /&gt;
def getLongFlagDefinition(executableNode):&lt;br /&gt;
    labelNodeList=executableNode.getElementsByTagName(&amp;quot;longflag&amp;quot;)&lt;br /&gt;
    if labelNodeList.length &amp;gt; 0 :&lt;br /&gt;
        labelNode=labelNodeList[0]  ## Only get the first one&lt;br /&gt;
        return &amp;quot;[&amp;lt;span style=\&amp;quot;color:orange\&amp;quot;&amp;gt;--&amp;quot;+getTextValuesFromNode(labelNode.childNodes)+&amp;quot;&amp;lt;/span&amp;gt;]&amp;quot;;&lt;br /&gt;
    return &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
# Extract the (short) flag, and color the text string&lt;br /&gt;
def getFlagDefinition(executableNode):&lt;br /&gt;
    labelNodeList=executableNode.getElementsByTagName(&amp;quot;flag&amp;quot;)&lt;br /&gt;
    if labelNodeList.length &amp;gt; 0 :&lt;br /&gt;
        labelNode=labelNodeList[0]  ## Only get the first one&lt;br /&gt;
        return &amp;quot;[&amp;lt;span style=\&amp;quot;color:pink\&amp;quot;&amp;gt;-&amp;quot;+getTextValuesFromNode(labelNode.childNodes)+&amp;quot;&amp;lt;/span&amp;gt;]&amp;quot;;&lt;br /&gt;
    return &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
# Extract the nodes label, and color the text string&lt;br /&gt;
def getLabelDefinition(executableNode):&lt;br /&gt;
    labelNodeList=executableNode.getElementsByTagName(&amp;quot;label&amp;quot;)&lt;br /&gt;
    if labelNodeList.length &amp;gt; 0 :&lt;br /&gt;
        labelNode=labelNodeList[0]  ## Only get the first one&lt;br /&gt;
        return &amp;quot;** &amp;lt;span style=\&amp;quot;color:green\&amp;quot;&amp;gt;'''&amp;quot;+getTextValuesFromNode(labelNode.childNodes)+&amp;quot;'''&amp;lt;/span&amp;gt;&amp;quot;;&lt;br /&gt;
    return &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
## Read the xml file from the first argument of command line&lt;br /&gt;
doc = xml.dom.minidom.parse(sys.argv[1]);&lt;br /&gt;
&lt;br /&gt;
# Get the primary heirarchial tree node.&lt;br /&gt;
executableNode=doc.getElementsByTagName(&amp;quot;executable&amp;quot;)[0]&lt;br /&gt;
&lt;br /&gt;
# Print information about the program in general&lt;br /&gt;
print &amp;quot;===Module Type &amp;amp; Category===\n&amp;quot;&lt;br /&gt;
print &amp;quot;Type: CLI\n&amp;quot;&lt;br /&gt;
print &amp;quot;Category: %s\n&amp;quot; % getThisNodesInfoAsText(executableNode,&amp;quot;category&amp;quot;)&lt;br /&gt;
print &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;===Authors, Collaborators &amp;amp; Contact===\n&amp;quot;&lt;br /&gt;
print &amp;quot;Author: %s\n&amp;quot; % getThisNodesInfoAsText(executableNode,&amp;quot;contributor&amp;quot;)&lt;br /&gt;
print &amp;quot;Contributors: %s\n&amp;quot; % getThisNodesInfoAsText(executableNode,&amp;quot;acknowledgements&amp;quot;)&lt;br /&gt;
print &amp;quot;\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;===Module Description===\n&amp;quot;&lt;br /&gt;
print &amp;quot;{| style=\&amp;quot;color:green\&amp;quot; border=\&amp;quot;1\&amp;quot;\n&amp;quot;&lt;br /&gt;
getThisNodesInfoAsTextTableLine(executableNode,&amp;quot;title&amp;quot;)&lt;br /&gt;
getThisNodesInfoAsTextTableLine(executableNode,&amp;quot;descripition&amp;quot;)&lt;br /&gt;
getThisNodesInfoAsTextTableLine(executableNode,&amp;quot;version&amp;quot;)&lt;br /&gt;
getThisNodesInfoAsTextTableLine(executableNode,&amp;quot;documentation-url&amp;quot;)&lt;br /&gt;
getThisNodesInfoAsTextTableLine(executableNode,&amp;quot;doesnotexiststest&amp;quot;)&lt;br /&gt;
print &amp;quot;|}\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Now print all the command line arguments and the labels that showup in the GUI interface&lt;br /&gt;
for parameterNode in executableNode.getElementsByTagName(&amp;quot;parameters&amp;quot;):&lt;br /&gt;
  print &amp;quot;* &amp;lt;span style=\&amp;quot;color:blue\&amp;quot;&amp;gt;'''''%s''''' &amp;lt;/span&amp;gt; %s&amp;quot; % (getThisNodesInfoAsText(parameterNode,&amp;quot;label&amp;quot;),getThisNodesInfoAsText(parameterNode,&amp;quot;description&amp;quot;))&lt;br /&gt;
  currentNode = parameterNode.firstChild&lt;br /&gt;
  while currentNode is not None :&lt;br /&gt;
      if currentNode.nodeType == currentNode.ELEMENT_NODE:&lt;br /&gt;
        if getThisNodesInfoAsText(currentNode,&amp;quot;label&amp;quot;) != &amp;quot;&amp;quot;: #If this node doe not have a &amp;quot;label&amp;quot; element, then just skip it.&lt;br /&gt;
          print &amp;quot;%s %s %s: %s&amp;quot; % (getLabelDefinition(currentNode), getLongFlagDefinition(currentNode),getFlagDefinition(currentNode),getThisNodesInfoAsText(currentNode,&amp;quot;description&amp;quot;))&lt;br /&gt;
      currentNode=currentNode.nextSibling&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hjmjohnson</name></author>
		
	</entry>
</feed>