dycw-utilities 0.116.2__py3-none-any.whl → 0.116.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dycw_utilities-0.116.2.dist-info → dycw_utilities-0.116.4.dist-info}/METADATA +1 -1
- {dycw_utilities-0.116.2.dist-info → dycw_utilities-0.116.4.dist-info}/RECORD +7 -6
- utilities/__init__.py +1 -1
- utilities/cryptography.py +13 -3
- utilities/importlib.py +16 -0
- {dycw_utilities-0.116.2.dist-info → dycw_utilities-0.116.4.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.116.2.dist-info → dycw_utilities-0.116.4.dist-info}/licenses/LICENSE +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=b6XtB99cyX4IZ76DFvF8Igz1IiLess5LdFIaswgC0Ko,60
|
2
2
|
utilities/altair.py,sha256=Gpja-flOo-Db0PIPJLJsgzAlXWoKUjPU1qY-DQ829ek,9156
|
3
3
|
utilities/astor.py,sha256=xuDUkjq0-b6fhtwjhbnebzbqQZAjMSHR1IIS5uOodVg,777
|
4
4
|
utilities/asyncio.py,sha256=7qisjTnEGEKcguy_STXN6qOXij_yzTvcQ5fIbrPeyZ8,23305
|
@@ -9,7 +9,7 @@ utilities/click.py,sha256=Jzm7DOI3rH-WLOTh1UHOfxkFhHU4_GJH60seLV0A-OI,14311
|
|
9
9
|
utilities/concurrent.py,sha256=s2scTEd2AhXVTW4hpASU2qxV_DiVLALfms55cCQzCvM,2886
|
10
10
|
utilities/contextlib.py,sha256=OOIIEa5lXKGzFAnauaul40nlQnQko6Na4ryiMJcHkIg,478
|
11
11
|
utilities/contextvars.py,sha256=RsSGGrbQqqZ67rOydnM7WWIsM2lIE31UHJLejnHJPWY,505
|
12
|
-
utilities/cryptography.py,sha256=
|
12
|
+
utilities/cryptography.py,sha256=_CiK_K6c_-uQuUhsUNjNjTL-nqxAh4_1zTfS11Xe120,972
|
13
13
|
utilities/cvxpy.py,sha256=Rv1-fD-XYerosCavRF8Pohop2DBkU3AlFaGTfD8AEAA,13776
|
14
14
|
utilities/dataclasses.py,sha256=iiC1wpGXWhaocIikzwBt8bbLWyImoUlOlcDZJGejaIg,33011
|
15
15
|
utilities/datetime.py,sha256=PcN-4_sSPX1zbpdzBQRdo08pubCuGHyigxkV6SUnvlo,38733
|
@@ -25,6 +25,7 @@ utilities/git.py,sha256=wpt5dZ5Oi5931pN24_VLZYaQOvmR0OcQuVtgHzFUN1k,2359
|
|
25
25
|
utilities/hashlib.py,sha256=SVTgtguur0P4elppvzOBbLEjVM3Pea0eWB61yg2ilxo,309
|
26
26
|
utilities/http.py,sha256=WcahTcKYRtZ04WXQoWt5EGCgFPcyHD3EJdlMfxvDt-0,946
|
27
27
|
utilities/hypothesis.py,sha256=OpZhPdPmsYWvqMytFDc-G196eODosUzxQSuo-LfMYmM,46262
|
28
|
+
utilities/importlib.py,sha256=ueY3R39hWrUtrVXs39utM2xDig-eyJfYn1FBVxWb3_w,368
|
28
29
|
utilities/ipython.py,sha256=V2oMYHvEKvlNBzxDXdLvKi48oUq2SclRg5xasjaXStw,763
|
29
30
|
utilities/iterables.py,sha256=prKXBdF5QfLTGC-q4567DwO8xzUng_Z-2a4wBkMqyDo,45360
|
30
31
|
utilities/jupyter.py,sha256=ft5JA7fBxXKzP-L9W8f2-wbF0QeYc_2uLQNFDVk4Z-M,2917
|
@@ -87,7 +88,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
|
|
87
88
|
utilities/whenever.py,sha256=iLRP_-8CZtBpHKbGZGu-kjSMg1ZubJ-VSmgSy7Eudxw,17787
|
88
89
|
utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
|
89
90
|
utilities/zoneinfo.py,sha256=-Xm57PMMwDTYpxJdkiJG13wnbwK--I7XItBh5WVhD-o,1874
|
90
|
-
dycw_utilities-0.116.
|
91
|
-
dycw_utilities-0.116.
|
92
|
-
dycw_utilities-0.116.
|
93
|
-
dycw_utilities-0.116.
|
91
|
+
dycw_utilities-0.116.4.dist-info/METADATA,sha256=P8hMpiUHgXKsNKT5dTwM4LbirjzE57NNYNB7KdmeZVQ,12943
|
92
|
+
dycw_utilities-0.116.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
93
|
+
dycw_utilities-0.116.4.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
94
|
+
dycw_utilities-0.116.4.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/cryptography.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
from dataclasses import dataclass
|
3
4
|
from os import getenv
|
5
|
+
from typing import override
|
4
6
|
|
5
7
|
from cryptography.fernet import Fernet
|
6
8
|
|
@@ -17,15 +19,23 @@ def decrypt(text: bytes, /, *, env_var: str = _ENV_VAR) -> str:
|
|
17
19
|
return get_fernet(env_var=env_var).decrypt(text).decode()
|
18
20
|
|
19
21
|
|
22
|
+
##
|
23
|
+
|
24
|
+
|
20
25
|
def get_fernet(*, env_var: str = _ENV_VAR) -> Fernet:
|
21
26
|
"""Get the Fernet key."""
|
22
27
|
if (key := getenv(env_var)) is None:
|
23
|
-
|
24
|
-
raise GetFernetError(msg)
|
28
|
+
raise GetFernetError(env_var=env_var)
|
25
29
|
return Fernet(key.encode())
|
26
30
|
|
27
31
|
|
28
|
-
|
32
|
+
@dataclass(kw_only=True, slots=True)
|
33
|
+
class GetFernetError(Exception):
|
34
|
+
env_var: str
|
35
|
+
|
36
|
+
@override
|
37
|
+
def __str__(self) -> str:
|
38
|
+
return f"Environment variable {self.env_var!r} is None"
|
29
39
|
|
30
40
|
|
31
41
|
__all__ = ["GetFernetError", "decrypt", "encrypt", "get_fernet"]
|
utilities/importlib.py
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from importlib import import_module
|
4
|
+
from importlib.util import find_spec
|
5
|
+
|
6
|
+
|
7
|
+
def is_valid_import(module: str, name: str) -> bool:
|
8
|
+
"""Check if an import is valid."""
|
9
|
+
spec = find_spec(module)
|
10
|
+
if spec is None:
|
11
|
+
return False
|
12
|
+
mod = import_module(module)
|
13
|
+
return hasattr(mod, name)
|
14
|
+
|
15
|
+
|
16
|
+
__all__ = ["is_valid_import"]
|
File without changes
|
File without changes
|