SEESenv/scripts/myrst2xml.py
author amit@thunder
Thu, 25 Feb 2010 00:04:27 +0530
changeset 27 cb14131583c6
parent 2 52d12eb31c30
child 30 f66b0a5ebf40
permissions -rw-r--r--
Started on final changes to the build scripts so that we can start with totally automatic builds

#!/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 
import os
chapterno=0
tmp_folder="/home/hg/repos/SEES-hacks/"








def convert2xml(file_name):
    """ convert to xml using rst2xml internally """
    global chapterno    
    file=file.split()[0]
    name=file.split('/')[-1]
    name='ch'+str(chapterno)+name.split('.')[0]
  
    print file	    
    xml_file=name+'.xml'        
    a=open(xml_file,'w')
    publish_file(source_path=file, destination_path=xml_file,parser_name='restructuredtext', writer_name='xml') 
def walk(repo):
    global chapterno
    mainfolder='/home/hg/repos/sttp/'    
    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)