1
0
mirror of synced 2024-11-22 01:04:23 +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 tempfile
import io
from distutils.version import LooseVersion
import cairo
import gi
@ -17,6 +18,11 @@ from . import abstract
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):
mimetypes = {'application/pdf', }

6
mat2
View File

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