SEESenv/scripts/myrst2xml.py
author amit@thunder
Sat, 27 Feb 2010 00:10:28 +0530
changeset 32 de7ac08f237b
parent 31 06a02dd3966f
child 34 18b34db550ec
permissions -rw-r--r--
Commiting a simple hook to do the auto build job
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
     1
#!/usr/bin/python
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
     2
"""
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
     3
Just a hack to convert rst to xml and then docbook . 
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
     4
May not containt all the required elements of a docbook .
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
     5
Just done to make it run for the specific rst for our 
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
     6
sees documentation.
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
     7
"""
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
     8
import xml.etree.ElementTree as ET
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
     9
import os 
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    10
import re
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    11
import subprocess
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    12
import os
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    13
import pkg_resources
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    14
import time
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    15
from docutils.core import publish_file 
27
cb14131583c6 Started on final changes to the build scripts so that we can start with totally automatic builds
amit@thunder
parents: 2
diff changeset
    16
import os
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    17
chapterno=0
30
f66b0a5ebf40 Changes in Path
amit@thunder
parents: 27
diff changeset
    18
tmp_folder="/home/hg/repos/SEES-hacks/temp/"
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    19
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    20
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    21
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    22
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    23
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    24
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    25
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    26
27
cb14131583c6 Started on final changes to the build scripts so that we can start with totally automatic builds
amit@thunder
parents: 2
diff changeset
    27
def convert2xml(file_name):
cb14131583c6 Started on final changes to the build scripts so that we can start with totally automatic builds
amit@thunder
parents: 2
diff changeset
    28
    """ convert to xml using rst2xml internally """
cb14131583c6 Started on final changes to the build scripts so that we can start with totally automatic builds
amit@thunder
parents: 2
diff changeset
    29
    global chapterno    
31
amit@thunder
parents: 30
diff changeset
    30
    file_name=file_name.split()[0]
amit@thunder
parents: 30
diff changeset
    31
    name=file_name.split('/')[-1]
amit@thunder
parents: 30
diff changeset
    32
   
amit@thunder
parents: 30
diff changeset
    33
    xml_file_temp='/'.join(file_name.split('/')[:-2])
amit@thunder
parents: 30
diff changeset
    34
     
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    35
    name='ch'+str(chapterno)+name.split('.')[0]
32
de7ac08f237b Commiting a simple hook to do the auto build job
amit@thunder
parents: 31
diff changeset
    36
    xml_file=tmp_folder+'/'+name+'.xml'
31
amit@thunder
parents: 30
diff changeset
    37
    print xml_file   
amit@thunder
parents: 30
diff changeset
    38
#    a=open(xml_file,'w')
amit@thunder
parents: 30
diff changeset
    39
    publish_file(source_path=file_name, destination_path=xml_file,parser_name='restructuredtext', writer_name='xml') 
amit@thunder
parents: 30
diff changeset
    40
    
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    41
def walk(repo):
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    42
    global chapterno
30
f66b0a5ebf40 Changes in Path
amit@thunder
parents: 27
diff changeset
    43
#    mainfolder='/home/hg/repos/sttp/'    
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    44
    for readline in open('index.config','r').readlines():
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    45
        chapterno+=1		
30
f66b0a5ebf40 Changes in Path
amit@thunder
parents: 27
diff changeset
    46
        filename=repo+readline
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    47
        convert2xml(filename)
31
amit@thunder
parents: 30
diff changeset
    48
       
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    49
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    50
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    51
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    52
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    53
if __name__=='__main__':
30
f66b0a5ebf40 Changes in Path
amit@thunder
parents: 27
diff changeset
    54
    repo='/home/hg/repos/sttp/'
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    55
    walk(repo)
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    56
#    convert(1,2,3)
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    57
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    58
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    59
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    60
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    61
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    62
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    63
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    64
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    65
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    66
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    67
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    68
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    69
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    70
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    71
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    72
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    73
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    74
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    75
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    76
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    77
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    78
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    79
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    80
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    81
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    82
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    83
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    84