forked from gandrewstone/yadog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dt.py
53 lines (38 loc) · 1.09 KB
/
dt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""?
<desc>This module extracts documentation from text files</desc>
"""
from types import *
import pdb
import ast
import re
from PyHtmlGen.document import *
from common import *
import microdom
from constants import *
def extractXml(prjPfx, filename):
print "Parsing %s" % filename
try:
f = open(filename,"rb")
except IOError: # A broken symlink could cause this to be unopenable even though the directory entry exists
print "Cannot open %s" % filename
return ""
text = f.read()
if filename.startswith(prjPfx):
filename = filename[len(prjPfx):]
xmltxt = "<%s name='%s' language='text'>" % (TagFile,filename) + text + "</%s>" % TagFile
try:
xml = microdom.parseString(xmltxt)
except microdom.ExpatError,e:
print "File %s: XML ERROR '%s'" % (filename,str(e))
f = open("error.xml","wb")
f.write(xmltxt)
f.close()
print "Errored file written to 'error.xml'"
# print xmltxt
pdb.set_trace()
return xml
def Test():
xml = extractXml("readme.txt")
#- xml = extractXml("microdom.py")
if __name__ == "__main__":
Test()