Remove the NoMimetype match exception. Not needed now that this is
a separate app from the OCR app. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -6,10 +6,3 @@ class ParserError(Exception):
|
|||||||
Base exception for file parsers
|
Base exception for file parsers
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NoMIMETypeMatch(ParserError):
|
|
||||||
"""
|
|
||||||
There is no parser registered for the specified MIME type
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
|
|
||||||
from common.utils import copyfile, fs_cleanup, mkstemp
|
from common.utils import copyfile, fs_cleanup, mkstemp
|
||||||
|
|
||||||
from .exceptions import ParserError, NoMIMETypeMatch
|
from .exceptions import ParserError
|
||||||
from .settings import setting_pdftotext_path
|
from .settings import setting_pdftotext_path
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -32,8 +32,7 @@ class Parser(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_document_version(cls, document_version):
|
def parse_document_version(cls, document_version):
|
||||||
try:
|
for parser_class in cls._registry.get(document_version.mimetype, ()):
|
||||||
for parser_class in cls._registry[document_version.mimetype]:
|
|
||||||
try:
|
try:
|
||||||
parser = parser_class()
|
parser = parser_class()
|
||||||
parser.process_document_version(document_version)
|
parser.process_document_version(document_version)
|
||||||
@@ -45,14 +44,9 @@ class Parser(object):
|
|||||||
# others in the list for this mimetype
|
# others in the list for this mimetype
|
||||||
return
|
return
|
||||||
|
|
||||||
raise NoMIMETypeMatch('Parser MIME type list exhausted')
|
|
||||||
except KeyError:
|
|
||||||
raise NoMIMETypeMatch
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_document_page(cls, document_page):
|
def parse_document_page(cls, document_page):
|
||||||
try:
|
for parser_class in cls._registry.get(document_page.document_version.mimetype, ()):
|
||||||
for parser_class in cls._registry[document_page.document_version.mimetype]:
|
|
||||||
try:
|
try:
|
||||||
parser = parser_class()
|
parser = parser_class()
|
||||||
parser.process_document_page(document_page)
|
parser.process_document_page(document_page)
|
||||||
@@ -63,9 +57,6 @@ class Parser(object):
|
|||||||
# If parser was successfull there is no need to try
|
# If parser was successfull there is no need to try
|
||||||
# others in the list for this mimetype
|
# others in the list for this mimetype
|
||||||
return
|
return
|
||||||
raise NoMIMETypeMatch('Parser MIME type list exhausted')
|
|
||||||
except KeyError:
|
|
||||||
raise NoMIMETypeMatch
|
|
||||||
|
|
||||||
def process_document_version(self, document_version):
|
def process_document_version(self, document_version):
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|||||||
Reference in New Issue
Block a user