diff options
author | halcy <halcy@ARARAGI-KUN> | 2022-11-30 22:31:54 +0200 |
---|---|---|
committer | halcy <halcy@ARARAGI-KUN> | 2022-11-30 22:31:54 +0200 |
commit | 262d150c05b328324ae5becc5da0d5b55dd74b89 (patch) | |
tree | 0370d2943f61facc0a743258a420e05bb12de06e /mastodon/compat.py | |
parent | 53cb42117bd99653f6f86280011cd25299356889 (diff) | |
download | mastodon.py-262d150c05b328324ae5becc5da0d5b55dd74b89.tar.gz |
Start moving functions out of main module
Diffstat (limited to 'mastodon/compat.py')
-rw-r--r-- | mastodon/compat.py | 45 |
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 | |||
3 | IMPL_HAS_CRYPTO = True | ||
4 | try: | ||
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 | ||
9 | except: | ||
10 | IMPL_HAS_CRYPTO = False | ||
11 | cryptography = None | ||
12 | default_backend = None | ||
13 | ec = None | ||
14 | serialization = None | ||
15 | |||
16 | IMPL_HAS_ECE = True | ||
17 | try: | ||
18 | import http_ece | ||
19 | except: | ||
20 | IMPL_HAS_ECE = False | ||
21 | http_ece = None | ||
22 | |||
23 | IMPL_HAS_BLURHASH = True | ||
24 | try: | ||
25 | import blurhash | ||
26 | except: | ||
27 | IMPL_HAS_BLURHASH = False | ||
28 | blurhash = None | ||
29 | |||
30 | try: | ||
31 | from urllib.parse import urlparse | ||
32 | except ImportError: | ||
33 | from urlparse import urlparse | ||
34 | |||
35 | try: | ||
36 | import magic | ||
37 | except ImportError: | ||
38 | magic = None | ||
39 | |||
40 | try: | ||
41 | from pathlib import PurePath | ||
42 | except: | ||
43 | class PurePath: | ||
44 | pass | ||
45 | |||