From 131cb1ea920bee110caffc146701a5376951b735 Mon Sep 17 00:00:00 2001 From: Alex Zagorodniuk Date: Mon, 22 Jun 2015 19:08:35 -0400 Subject: [PATCH] change STRICT to be a settings attribute --- pdfminer/psparser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pdfminer/psparser.py b/pdfminer/psparser.py index dbc7861..b1fc6ac 100644 --- a/pdfminer/psparser.py +++ b/pdfminer/psparser.py @@ -5,6 +5,12 @@ import re import logging import six # Python 2+3 compatibility +try: + from django.conf import settings +except ImportError: + # in case it's not a django project + settings = None + def bytesindex(s,i,j=None): """implements s[i], s[i:], s[i:j] for Python2 and Python3""" @@ -15,7 +21,7 @@ def bytesindex(s,i,j=None): from .utils import choplist -STRICT = True +STRICT = getattr(settings, 'PDF_MINER_IS_STRICT', True) ## PS Exceptions ## @@ -265,7 +271,7 @@ class PSBaseParser(object): linebuf += bytesindex(self.buf,self.charpos,-1) self.charpos = len(self.buf) logging.debug('nextline: %r, %r', linepos, linebuf) - + return (linepos, linebuf) def revreadlines(self):