SEESenv/scripts/myrst2xml.py
changeset 27 cb14131583c6
parent 2 52d12eb31c30
child 30 f66b0a5ebf40
equal deleted inserted replaced
26:1846ab4ebdda 27:cb14131583c6
    11 import subprocess
    11 import subprocess
    12 import os
    12 import os
    13 import pkg_resources
    13 import pkg_resources
    14 import time
    14 import time
    15 from docutils.core import publish_file 
    15 from docutils.core import publish_file 
       
    16 import os
    16 chapterno=0
    17 chapterno=0
       
    18 tmp_folder="/home/hg/repos/SEES-hacks/"
    17 
    19 
    18 
    20 
    19 
    21 
    20 
    22 
    21 
    23 
    22 
    24 
    23 
    25 
    24 
    26 
    25 
    27 def convert2xml(file_name):
    26 def convert2xml(file):
    28     """ convert to xml using rst2xml internally """
    27 #    print folder,subfolder,file
    29     global chapterno    
    28     file=file.split("\n")[0]
    30     file=file.split()[0]
    29     file= file.split("\t")[0]  
       
    30     global chapterno
       
    31     name=file.split('/')[-1]
    31     name=file.split('/')[-1]
    32     name='ch'+str(chapterno)+name.split('.')[0]
    32     name='ch'+str(chapterno)+name.split('.')[0]
    33 #    full_file=os.path.join(folder,file)    
    33   
    34 #    if file.endswith('.rst'):    
       
    35     print file	    
    34     print file	    
    36     xml_file=name+'.xml'        
    35     xml_file=name+'.xml'        
    37     a=open(xml_file,'w')
    36     a=open(xml_file,'w')
    38 #    a.close()
       
    39 #    command="rst2xml.py %s > %s" %(file , xml_file)
       
    40           
       
    41 #    a=subprocess.Popen(command , shell=True)
       
    42 #    time.sleep(10) 	   	
       
    43 #    a.kill()
       
    44     publish_file(source_path=file, destination_path=xml_file,parser_name='restructuredtext', writer_name='xml') 
    37     publish_file(source_path=file, destination_path=xml_file,parser_name='restructuredtext', writer_name='xml') 
    45 def walk(repo):
    38 def walk(repo):
    46     global chapterno
    39     global chapterno
    47     mainfolder='/home/amit/sttp_latest/'    
    40     mainfolder='/home/hg/repos/sttp/'    
    48     for readline in open('index.config','r').readlines():
    41     for readline in open('index.config','r').readlines():
    49         chapterno+=1		
    42         chapterno+=1		
    50         filename=mainfolder+readline
    43         filename=mainfolder+readline
    51         convert2xml(filename)
    44         convert2xml(filename)
    52 
    45