replace "trying *codepage*" message to console with an error message only if none of our specified codepages is successful

This commit is contained in:
Eric Blade 2009-09-11 00:38:20 -05:00
parent 715b14f81a
commit 7283d09b4d

View File

@ -426,10 +426,8 @@ or None if we fail to get the info """
log.debug("Reading stdin with %s" % self.codepage) # is this necessary? or possible? or what?
in_fh = codecs.getreader('cp1252')(sys.stdin)
else:
success = False
for kodec in self.__listof(self.codepage):
if success: break
print "trying", kodec
#print "trying", kodec
try:
in_fh = codecs.open(self.in_path, 'r', kodec)
in_fh.seek(self.index)
@ -437,9 +435,11 @@ or None if we fail to get the info """
self.obs = in_fh.read()
self.index = in_fh.tell()
in_fh.close()
success = True
break
except:
pass
else:
print "unable to read file with any codec in list!", self.in_path
elif(self.filetype == "xml"):
doc = xml.dom.minidom.parse(filename)
self.doc = doc