1
0
mirror of synced 2024-11-26 03:04:22 +01:00

Ensure Poppler's minimal version

We're using methods that aren't available in Poppler
below 0.46, so we're checking for this upon import.

This commit is based on ideas from @LogicalDash ♥
This commit is contained in:
jvoisin 2018-06-24 22:40:57 +02:00
parent 1e9906de29
commit f44769df41
2 changed files with 11 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import re
import logging import logging
import tempfile import tempfile
import io import io
from distutils.version import LooseVersion
import cairo import cairo
import gi import gi
@ -17,6 +18,11 @@ from . import abstract
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
poppler_version = Poppler.get_version()
if LooseVersion(poppler_version) < LooseVersion('0.46'):
raise ValueError("MAT2 needs at least Poppler version 0.46 to work. \
The installed version is %s." % poppler_version)
class PDFParser(abstract.AbstractParser): class PDFParser(abstract.AbstractParser):
mimetypes = {'application/pdf', } mimetypes = {'application/pdf', }

4
mat2
View File

@ -8,7 +8,11 @@ import mimetypes
import argparse import argparse
import multiprocessing import multiprocessing
try:
from libmat2 import parser_factory, unsupported_extensions from libmat2 import parser_factory, unsupported_extensions
except ValueError as e:
print(e)
sys.exit(1)
__version__ = '0.1.2' __version__ = '0.1.2'