equal
deleted
inserted
replaced
|
1 #!/usr/bin/python |
|
2 """ |
|
3 Just a hack to convert rst to xml and then docbook . |
|
4 May not containt all the required elements of a docbook . |
|
5 Just done to make it run for the specific rst for our |
|
6 sees documentation. |
|
7 """ |
|
8 import xml.etree.ElementTree as ET |
|
9 import os |
|
10 import re |
|
11 import subprocess |
|
12 import os |
|
13 import pkg_resources |
|
14 import time |
|
15 from docutils.core import publish_file |
|
16 chapterno=0 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 def convert2xml(file): |
|
27 # print folder,subfolder,file |
|
28 file=file.split("\n")[0] |
|
29 file= file.split("\t")[0] |
|
30 global chapterno |
|
31 name=file.split('/')[-1] |
|
32 name='ch'+str(chapterno)+name.split('.')[0] |
|
33 # full_file=os.path.join(folder,file) |
|
34 # if file.endswith('.rst'): |
|
35 print file |
|
36 xml_file=name+'.xml' |
|
37 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') |
|
45 def walk(repo): |
|
46 global chapterno |
|
47 mainfolder='/home/amit/sttp_latest/' |
|
48 for readline in open('index.config','r').readlines(): |
|
49 chapterno+=1 |
|
50 filename=mainfolder+readline |
|
51 convert2xml(filename) |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 if __name__=='__main__': |
|
58 repo='/home/amit/sphinxvirt/review/' |
|
59 walk(repo) |
|
60 # convert(1,2,3) |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |