1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
# compat.py - backwards compatible optional imports
IMPL_HAS_CRYPTO = True
try:
import cryptography
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
except:
IMPL_HAS_CRYPTO = False
cryptography = None
default_backend = None
ec = None
serialization = None
IMPL_HAS_ECE = True
try:
import http_ece # type: ignore
except:
IMPL_HAS_ECE = False
http_ece = None
IMPL_HAS_BLURHASH = True
try:
import blurhash
except:
IMPL_HAS_BLURHASH = False
blurhash = None
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse # type: ignore
try:
import magic
except ImportError:
magic = None
try:
from pathlib import PurePath, Path
except:
class PurePath:
pass
class Path:
pass
IMPL_HAS_GRAPHEME = True
try:
import grapheme
except:
IMPL_HAS_GRAPHEME = False
grapheme = None
|