SEESenv/scripts/myrst2xml.py
changeset 2 52d12eb31c30
parent 0 8083d21c0020
child 27 cb14131583c6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SEESenv/scripts/myrst2xml.py	Fri Feb 12 01:11:21 2010 +0530
@@ -0,0 +1,88 @@
+#!/usr/bin/python
+"""
+Just a hack to convert rst to xml and then docbook . 
+May not containt all the required elements of a docbook .
+Just done to make it run for the specific rst for our 
+sees documentation.
+"""
+import xml.etree.ElementTree as ET
+import os 
+import re
+import subprocess
+import os
+import pkg_resources
+import time
+from docutils.core import publish_file 
+chapterno=0
+
+
+
+
+
+
+
+
+
+def convert2xml(file):
+#    print folder,subfolder,file
+    file=file.split("\n")[0]
+    file= file.split("\t")[0]  
+    global chapterno
+    name=file.split('/')[-1]
+    name='ch'+str(chapterno)+name.split('.')[0]
+#    full_file=os.path.join(folder,file)    
+#    if file.endswith('.rst'):    
+    print file	    
+    xml_file=name+'.xml'        
+    a=open(xml_file,'w')
+#    a.close()
+#    command="rst2xml.py %s > %s" %(file , xml_file)
+          
+#    a=subprocess.Popen(command , shell=True)
+#    time.sleep(10) 	   	
+#    a.kill()
+    publish_file(source_path=file, destination_path=xml_file,parser_name='restructuredtext', writer_name='xml') 
+def walk(repo):
+    global chapterno
+    mainfolder='/home/amit/sttp_latest/'    
+    for readline in open('index.config','r').readlines():
+        chapterno+=1		
+        filename=mainfolder+readline
+        convert2xml(filename)
+
+
+
+
+
+if __name__=='__main__':
+    repo='/home/amit/sphinxvirt/review/'
+    walk(repo)
+#    convert(1,2,3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+