1
0
mirror of synced 2024-11-26 03:04:22 +01:00
mat2/libmat2/__init__.py

71 lines
1.4 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
import collections
2018-09-06 11:13:11 +02:00
import enum
import importlib
2018-09-01 15:07:01 +02:00
from typing import Dict, Optional
from . import exiftool, video
# make pyflakes happy
assert Dict
2018-10-12 11:58:01 +02:00
assert Optional
# A set of extension that aren't supported, despite matching a supported mimetype
UNSUPPORTED_EXTENSIONS = {
'.asc',
'.bat',
'.brf',
'.c',
'.h',
'.ksh',
'.pl',
'.pot',
'.rdf',
'.srt',
'.wsdl',
'.xpdl',
'.xsd',
'.xsl',
}
DEPENDENCIES = {
'Cairo': 'cairo',
'PyGobject': 'gi',
'GdkPixbuf from PyGobject': 'gi.repository.GdkPixbuf',
'Poppler from PyGobject': 'gi.repository.Poppler',
'GLib from PyGobject': 'gi.repository.GLib',
'Mutagen': 'mutagen',
}
CMD_DEPENDENCIES = {
'Exiftool': exiftool._get_exiftool_path,
'Ffmpeg': video._get_ffmpeg_path,
}
2018-09-01 15:07:01 +02:00
2018-10-23 16:32:28 +02:00
def check_dependencies() -> Dict[str, bool]:
ret = collections.defaultdict(bool) # type: Dict[str, bool]
for key, value in DEPENDENCIES.items():
ret[key] = True
try:
importlib.import_module(value)
except ImportError: # pragma: no cover
ret[key] = False # pragma: no cover
for k, v in CMD_DEPENDENCIES.items():
ret[k] = True
try:
v()
except RuntimeError: # pragma: no cover
ret[k] = False
return ret
2018-09-06 11:13:11 +02:00
@enum.unique
class UnknownMemberPolicy(enum.Enum):
ABORT = 'abort'
OMIT = 'omit'
KEEP = 'keep'