2018-05-16 22:00:37 +02:00
|
|
|
#!/bin/env python3
|
|
|
|
|
2018-07-10 20:49:54 +02:00
|
|
|
import os
|
|
|
|
import collections
|
|
|
|
import importlib
|
|
|
|
from typing import Dict
|
|
|
|
|
|
|
|
# make pyflakes happy
|
|
|
|
assert Dict
|
|
|
|
|
2018-05-16 22:00:37 +02:00
|
|
|
# A set of extension that aren't supported, despite matching a supported mimetype
|
2018-07-08 22:40:36 +02:00
|
|
|
UNSUPPORTED_EXTENSIONS = {
|
2018-06-10 00:28:43 +02:00
|
|
|
'.asc',
|
|
|
|
'.bat',
|
|
|
|
'.brf',
|
|
|
|
'.c',
|
|
|
|
'.h',
|
|
|
|
'.ksh',
|
|
|
|
'.pl',
|
|
|
|
'.pot',
|
|
|
|
'.rdf',
|
|
|
|
'.srt',
|
|
|
|
'.wsdl',
|
|
|
|
'.xpdl',
|
|
|
|
'.xsd',
|
|
|
|
'.xsl',
|
|
|
|
}
|
2018-07-10 20:49:54 +02:00
|
|
|
|
|
|
|
DEPENDENCIES = {
|
|
|
|
'cairo': 'Cairo',
|
|
|
|
'gi': 'PyGobject',
|
|
|
|
'gi.repository.GdkPixbuf': 'GdkPixbuf from PyGobject',
|
|
|
|
'gi.repository.Poppler': 'Poppler from PyGobject',
|
|
|
|
'mutagen': 'Mutagen',
|
|
|
|
}
|
|
|
|
|
|
|
|
def check_dependencies() -> dict:
|
|
|
|
ret = collections.defaultdict(bool) # type: Dict[str, bool]
|
|
|
|
|
|
|
|
exiftool = '/usr/bin/exiftool'
|
|
|
|
ret['Exiftool'] = False
|
|
|
|
if os.path.isfile(exiftool) and os.access(exiftool, os.X_OK): # pragma: no cover
|
|
|
|
ret['Exiftool'] = True
|
|
|
|
|
|
|
|
for key, value in DEPENDENCIES.items():
|
|
|
|
ret[value] = True
|
|
|
|
try:
|
|
|
|
importlib.import_module(key)
|
|
|
|
except ImportError: # pragma: no cover
|
|
|
|
ret[value] = False # pragma: no cover
|
|
|
|
|
|
|
|
return ret
|