Also sprach John J. Lee :
(I have removed most of the logic of the code here, so I am not sure
it's going to be helpful)
[...]
Post a short snippet of code that runs and demonstrates the problem.
Ok, I have reduced it, but I am afraid problem comes from PyXML...
You must have some file called "test.xml "
(file is empty in my test) in the same directory as the script:
def getFileName():
from os.path import abspath,join
from sys import path
cdir = abspath(path[0])
cfile = join(cdir,'test.xml')
return cfile
from xml.sax.saxutils import DefaultHandler
class TestReader(object):
def __init__(self):
pass
def read(self,filename):
from _xmlplus.sax.sax2exts import XMLValParserFactory
parser = XMLValParserFactory.make_parser()
#from xml.sax.handler import feature_namespaces,feature_validation
#parser.setFeature(feature_namespaces, 0)
dh = DefaultHandler()
parser.setContentHandler(dh)
parser.setErrorHandler(dh)
f = file(filename,'r')
try:
parser.parse(f)
finally:
parser.close()
parser.reset()
f.close()
return 1
def ViewFile():
from xml.sax._exceptions import SAXParseException
infile = getFileName()
a = TestReader()
try:
print 'A0'
pls = a.read(infile)
except SAXParseException,e:
print 'B1'
pls = {}
from shutil import move
from os import rename
bakname = infile + '.bak'
move(infile,bakname)
#rename(infile,bakname)
def main():
ViewFile()
main()