aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon/compat.py')
-rw-r--r--mastodon/compat.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/mastodon/compat.py b/mastodon/compat.py
new file mode 100644
index 0000000..905bfa7
--- /dev/null
+++ b/mastodon/compat.py
@@ -0,0 +1,45 @@
1# compat.py - backwards compatible optional imports
2
3IMPL_HAS_CRYPTO = True
4try:
5 import cryptography
6 from cryptography.hazmat.backends import default_backend
7 from cryptography.hazmat.primitives.asymmetric import ec
8 from cryptography.hazmat.primitives import serialization
9except:
10 IMPL_HAS_CRYPTO = False
11 cryptography = None
12 default_backend = None
13 ec = None
14 serialization = None
15
16IMPL_HAS_ECE = True
17try:
18 import http_ece
19except:
20 IMPL_HAS_ECE = False
21 http_ece = None
22
23IMPL_HAS_BLURHASH = True
24try:
25 import blurhash
26except:
27 IMPL_HAS_BLURHASH = False
28 blurhash = None
29
30try:
31 from urllib.parse import urlparse
32except ImportError:
33 from urlparse import urlparse
34
35try:
36 import magic
37except ImportError:
38 magic = None
39
40try:
41 from pathlib import PurePath
42except:
43 class PurePath:
44 pass
45
Powered by cgit v1.2.3 (git 2.41.0)