pdf: fix test on pdfocr config value
This commit is contained in:
parent
9f1d482564
commit
f66b5d1ef9
@ -48,6 +48,21 @@ def subprocfile(fn):
|
||||
else:
|
||||
return fn
|
||||
|
||||
def configparamtrue(value):
|
||||
if not value:
|
||||
return False
|
||||
try:
|
||||
ivalue = int(value)
|
||||
if ivalue:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except:
|
||||
pass
|
||||
if value[0] in 'tT':
|
||||
return True
|
||||
return False
|
||||
|
||||
my_config = rclconfig.RclConfig()
|
||||
|
||||
############################################
|
||||
|
||||
@ -138,6 +138,7 @@ class PDFExtractor:
|
||||
self.attextractdone = False
|
||||
self.attachlist = []
|
||||
cf_attach = self.config.getConfParam("pdfattach")
|
||||
cf_attach = rclexecm.configparamtrue(cf_attach)
|
||||
if cf_attach:
|
||||
self.pdftk = rclexecm.which("pdftk")
|
||||
if self.pdftk:
|
||||
@ -494,18 +495,22 @@ class PDFExtractor:
|
||||
|
||||
if isempty and self.ocrpossible:
|
||||
self.config.setKeyDir(os.path.dirname(self.filename))
|
||||
cf_doocr = self.config.getConfParam("pdfocr")
|
||||
if cf_doocr or os.path.isfile(os.path.join(self.confdir, "ocrpdf")):
|
||||
s = self.config.getConfParam("pdfocr")
|
||||
cf_doocr = rclexecm.configparamtrue(s)
|
||||
file_doocr = os.path.isfile(os.path.join(self.confdir, "ocrpdf"))
|
||||
if cf_doocr or file_doocr:
|
||||
html = self.ocrpdf()
|
||||
|
||||
if self.extrameta:
|
||||
try:
|
||||
html = self._setextrameta(html)
|
||||
except Exception as err:
|
||||
self.em.rclog("Metadata extraction failed: %s %s" % (err, traceback.format_exc()))
|
||||
self.em.rclog("Metadata extraction failed: %s %s" %
|
||||
(err, traceback.format_exc()))
|
||||
|
||||
return (True, html, "", eof)
|
||||
|
||||
|
||||
def maybemaketmpdir(self):
|
||||
global tmpdir
|
||||
if tmpdir:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user