SEESenv/scripts/myrst2xml.py
author amit@thunder
Wed, 10 Mar 2010 00:04:25 +0530
changeset 44 d0e9b52bda73
parent 41 e54725be4df6
permissions -rw-r--r--
Changed the algorithm for getting the titles ... Also added the ability to navigate to the next chapters
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
41
e54725be4df6 Changed paths dependent on repo location to be taken from the script also changed how the soup is printed
amit@thunder
parents: 39
diff changeset
    17
import sys
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    18
chapterno=0
30
f66b0a5ebf40 Changes in Path
amit@thunder
parents: 27
diff changeset
    19
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
    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
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    27
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
    28
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
    29
    """ 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
    30
    global chapterno    
31
amit@thunder
parents: 30
diff changeset
    31
    file_name=file_name.split()[0]
amit@thunder
parents: 30
diff changeset
    32
    name=file_name.split('/')[-1]
amit@thunder
parents: 30
diff changeset
    33
   
amit@thunder
parents: 30
diff changeset
    34
    xml_file_temp='/'.join(file_name.split('/')[:-2])
amit@thunder
parents: 30
diff changeset
    35
     
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    36
    name='ch'+str(chapterno)+name.split('.')[0]
34
18b34db550ec some really stupid mistakes corrected
amit@thunder
parents: 32
diff changeset
    37
    xml_file=tmp_folder+name+'.xml'
31
amit@thunder
parents: 30
diff changeset
    38
    print xml_file   
39
bc65d8802897 Bug fix in myrst .. so that it does not fail at not finding a file
amit@thunder
parents: 38
diff changeset
    39
38
194e1bdfd1cb Some bug fixing
amit@thunder
parents: 36
diff changeset
    40
    try:    
194e1bdfd1cb Some bug fixing
amit@thunder
parents: 36
diff changeset
    41
        publish_file(source_path=file_name, destination_path=xml_file,parser_name='restructuredtext', writer_name='xml') 
194e1bdfd1cb Some bug fixing
amit@thunder
parents: 36
diff changeset
    42
    except :
194e1bdfd1cb Some bug fixing
amit@thunder
parents: 36
diff changeset
    43
        pass
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    44
def walk(repo):
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    45
    global chapterno
30
f66b0a5ebf40 Changes in Path
amit@thunder
parents: 27
diff changeset
    46
#    mainfolder='/home/hg/repos/sttp/'    
38
194e1bdfd1cb Some bug fixing
amit@thunder
parents: 36
diff changeset
    47
    for readline in open('/home/hg/repos/SEES-hacks/index.config','r').readlines():
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    48
        chapterno+=1		
30
f66b0a5ebf40 Changes in Path
amit@thunder
parents: 27
diff changeset
    49
        filename=repo+readline
44
d0e9b52bda73 Changed the algorithm for getting the titles ... Also added the ability to navigate to the next chapters
amit@thunder
parents: 41
diff changeset
    50
        print filename        
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    51
        convert2xml(filename)
31
amit@thunder
parents: 30
diff changeset
    52
       
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    53
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    54
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    55
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    56
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    57
if __name__=='__main__':
41
e54725be4df6 Changed paths dependent on repo location to be taken from the script also changed how the soup is printed
amit@thunder
parents: 39
diff changeset
    58
    repo=sys.argv[1]
0
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    59
    walk(repo)
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    60
#    convert(1,2,3)
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
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    85
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    86
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    87
8083d21c0020 The first commit of all the required files for the review app
amit@thunder
parents:
diff changeset
    88