handle filters returning unicode objects
This commit is contained in:
parent
c92cf26316
commit
e3664ca88b
@ -36,6 +36,7 @@ class RclExecM:
|
|||||||
txt = txt.replace("&", "&")
|
txt = txt.replace("&", "&")
|
||||||
|
|
||||||
txt = txt.replace("<", "<")
|
txt = txt.replace("<", "<")
|
||||||
|
txt = txt.replace(">", ">")
|
||||||
txt = txt.replace('"', "&dquot;")
|
txt = txt.replace('"', "&dquot;")
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
@ -77,6 +78,10 @@ class RclExecM:
|
|||||||
def answer(self, docdata, ipath, iseof = noteof, iserror = noerror):
|
def answer(self, docdata, ipath, iseof = noteof, iserror = noerror):
|
||||||
|
|
||||||
if iserror != RclExecM.fileerror and iseof != RclExecM.eofnow:
|
if iserror != RclExecM.fileerror and iseof != RclExecM.eofnow:
|
||||||
|
if isinstance(docdata, unicode):
|
||||||
|
self.rclog("GOT UNICODE for ipath [%s]" % (ipath,))
|
||||||
|
docdata = docdata.encode("UTF-8")
|
||||||
|
|
||||||
print "Document:", len(docdata)
|
print "Document:", len(docdata)
|
||||||
sys.stdout.write(docdata)
|
sys.stdout.write(docdata)
|
||||||
|
|
||||||
@ -180,7 +185,11 @@ def main(proto, extract):
|
|||||||
if ok:
|
if ok:
|
||||||
print "== Found entry for ipath %s (mimetype [%s]):" % \
|
print "== Found entry for ipath %s (mimetype [%s]):" % \
|
||||||
(ipath, proto.mimetype)
|
(ipath, proto.mimetype)
|
||||||
print data
|
if isinstance(data, unicode):
|
||||||
|
bdata = data.encode("UTF-8")
|
||||||
|
else:
|
||||||
|
bdata = data
|
||||||
|
sys.stdout.write(bdata)
|
||||||
print
|
print
|
||||||
else:
|
else:
|
||||||
print "Got error, eof %d"%eof
|
print "Got error, eof %d"%eof
|
||||||
@ -193,7 +202,11 @@ def main(proto, extract):
|
|||||||
ecnt = ecnt + 1
|
ecnt = ecnt + 1
|
||||||
print "== Entry %d ipath %s (mimetype [%s]):" % \
|
print "== Entry %d ipath %s (mimetype [%s]):" % \
|
||||||
(ecnt, ipath, proto.mimetype)
|
(ecnt, ipath, proto.mimetype)
|
||||||
print data
|
if isinstance(data, unicode):
|
||||||
|
bdata = data.encode("UTF-8")
|
||||||
|
else:
|
||||||
|
bdata = data
|
||||||
|
sys.stdout.write(bdata)
|
||||||
print
|
print
|
||||||
if eof != RclExecM.noteof:
|
if eof != RclExecM.noteof:
|
||||||
break
|
break
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user