replace "trying *codepage*" message to console with an error message only if none of our specified codepages is successful
This commit is contained in:
parent
715b14f81a
commit
7283d09b4d
|
@ -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?
|
log.debug("Reading stdin with %s" % self.codepage) # is this necessary? or possible? or what?
|
||||||
in_fh = codecs.getreader('cp1252')(sys.stdin)
|
in_fh = codecs.getreader('cp1252')(sys.stdin)
|
||||||
else:
|
else:
|
||||||
success = False
|
|
||||||
for kodec in self.__listof(self.codepage):
|
for kodec in self.__listof(self.codepage):
|
||||||
if success: break
|
#print "trying", kodec
|
||||||
print "trying", kodec
|
|
||||||
try:
|
try:
|
||||||
in_fh = codecs.open(self.in_path, 'r', kodec)
|
in_fh = codecs.open(self.in_path, 'r', kodec)
|
||||||
in_fh.seek(self.index)
|
in_fh.seek(self.index)
|
||||||
|
@ -437,9 +435,11 @@ or None if we fail to get the info """
|
||||||
self.obs = in_fh.read()
|
self.obs = in_fh.read()
|
||||||
self.index = in_fh.tell()
|
self.index = in_fh.tell()
|
||||||
in_fh.close()
|
in_fh.close()
|
||||||
success = True
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
print "unable to read file with any codec in list!", self.in_path
|
||||||
elif(self.filetype == "xml"):
|
elif(self.filetype == "xml"):
|
||||||
doc = xml.dom.minidom.parse(filename)
|
doc = xml.dom.minidom.parse(filename)
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
|
|
Loading…
Reference in New Issue
Block a user