ecodev-core 0.0.30__py3-none-any.whl → 0.0.32__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.
Potentially problematic release.
This version of ecodev-core might be problematic. Click here for more details.
- ecodev_core/__init__.py +5 -1
- ecodev_core/list_utils.py +39 -0
- {ecodev_core-0.0.30.dist-info → ecodev_core-0.0.32.dist-info}/METADATA +3 -1
- {ecodev_core-0.0.30.dist-info → ecodev_core-0.0.32.dist-info}/RECORD +6 -6
- {ecodev_core-0.0.30.dist-info → ecodev_core-0.0.32.dist-info}/LICENSE.md +0 -0
- {ecodev_core-0.0.30.dist-info → ecodev_core-0.0.32.dist-info}/WHEEL +0 -0
ecodev_core/__init__.py
CHANGED
|
@@ -42,12 +42,15 @@ from ecodev_core.db_retrieval import get_rows
|
|
|
42
42
|
from ecodev_core.db_retrieval import ServerSideField
|
|
43
43
|
from ecodev_core.email_sender import send_email
|
|
44
44
|
from ecodev_core.enum_utils import enum_converter
|
|
45
|
+
from ecodev_core.list_utils import first_func_or_default
|
|
45
46
|
from ecodev_core.list_utils import first_or_default
|
|
46
47
|
from ecodev_core.list_utils import first_transformed_or_default
|
|
47
48
|
from ecodev_core.list_utils import group_by
|
|
48
49
|
from ecodev_core.list_utils import group_by_value
|
|
49
50
|
from ecodev_core.list_utils import lselect
|
|
50
51
|
from ecodev_core.list_utils import lselectfirst
|
|
52
|
+
from ecodev_core.list_utils import sort_by_keys
|
|
53
|
+
from ecodev_core.list_utils import sort_by_values
|
|
51
54
|
from ecodev_core.logger import log_critical
|
|
52
55
|
from ecodev_core.logger import logger_get
|
|
53
56
|
from ecodev_core.pandas_utils import get_excelfile
|
|
@@ -85,4 +88,5 @@ __all__ = [
|
|
|
85
88
|
'generic_insertion', 'custom_equal', 'is_authorized_user', 'get_method', 'AppActivity',
|
|
86
89
|
'fastapi_monitor', 'dash_monitor', 'is_monitoring_user', 'get_recent_activities', 'select_user',
|
|
87
90
|
'get_access_token', 'safe_get_user', 'backup', 'group_by', 'get_excelfile', 'upsert_new_user',
|
|
88
|
-
'datify', 'safe_drop_columns', 'get_value', 'is_null', 'send_email'
|
|
91
|
+
'datify', 'safe_drop_columns', 'get_value', 'is_null', 'send_email', 'first_func_or_default',
|
|
92
|
+
'sort_by_keys', 'sort_by_values']
|
ecodev_core/list_utils.py
CHANGED
|
@@ -45,6 +45,45 @@ def first_or_default(sequence: Union[List[Any], None],
|
|
|
45
45
|
return next((elt for elt in sequence if condition(elt)), default)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
def sort_by_keys(unsorted_dict: dict, reverse: bool = False) -> dict:
|
|
49
|
+
"""
|
|
50
|
+
Returns a sorted dictionary out of the passed unsorted_dict.
|
|
51
|
+
Sorting is done on unsorted_dict keys.
|
|
52
|
+
If reverse is True, reverse sorting
|
|
53
|
+
"""
|
|
54
|
+
return dict(sorted(unsorted_dict.items(), reverse=reverse))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def sort_by_values(unsorted_dict: dict, reverse: bool = False) -> dict:
|
|
58
|
+
"""
|
|
59
|
+
Returns a sorted dictionary out of the passed unsorted_dict.
|
|
60
|
+
Sorting is done on unsorted_dict values.
|
|
61
|
+
If reverse is True, reverse sorting
|
|
62
|
+
"""
|
|
63
|
+
return dict(sorted(unsorted_dict.items(), key=lambda item: item[1], reverse=reverse))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def first_func_or_default(sequence: list[Callable] | None,
|
|
67
|
+
elt: Any,
|
|
68
|
+
condition: Callable | None = None,
|
|
69
|
+
default: Any | None = None
|
|
70
|
+
) -> Any | None:
|
|
71
|
+
"""
|
|
72
|
+
Returns the first element of a functional sequence if a certain criteria is met
|
|
73
|
+
or default value if the criteria is never met.
|
|
74
|
+
The criteria is like so:
|
|
75
|
+
- If no condition is provided, then
|
|
76
|
+
just check that func applied on elt is not None
|
|
77
|
+
- If a condition is provided, then
|
|
78
|
+
check that condition applied on func(elt) is not None
|
|
79
|
+
"""
|
|
80
|
+
if not sequence:
|
|
81
|
+
return default
|
|
82
|
+
|
|
83
|
+
return next((func(elt) for func in sequence if (condition or (lambda x: x))(func(elt))),
|
|
84
|
+
default)
|
|
85
|
+
|
|
86
|
+
|
|
48
87
|
def group_by(sequence: List[Any], key: Union[Callable, None]) -> Iterator[Tuple[Any, List[Any]]]:
|
|
49
88
|
"""
|
|
50
89
|
Extension of itertools groupby method.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ecodev-core
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.32
|
|
4
4
|
Summary: Low level sqlmodel/fastapi/pydantic building blocks
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Thomas Epelbaum
|
|
@@ -37,6 +37,7 @@ Requires-Dist: fastapi (>=0,<1)
|
|
|
37
37
|
Requires-Dist: httpx (>=0,<1)
|
|
38
38
|
Requires-Dist: numpy (>=1,<2)
|
|
39
39
|
Requires-Dist: openpyxl (>=3,<4)
|
|
40
|
+
Requires-Dist: orjson (>=3.10.5,<4.0.0)
|
|
40
41
|
Requires-Dist: pandas (>=2,<3)
|
|
41
42
|
Requires-Dist: passlib[bcyrypt] (>=1,<2)
|
|
42
43
|
Requires-Dist: psycopg2-binary (>=2,<3)
|
|
@@ -45,6 +46,7 @@ Requires-Dist: pydantic-settings (>=2,<3)
|
|
|
45
46
|
Requires-Dist: python-jose[cryptography] (>=3,<4)
|
|
46
47
|
Requires-Dist: sqladmin (==0.15.2)
|
|
47
48
|
Requires-Dist: sqlmodel (>=0,<1)
|
|
49
|
+
Requires-Dist: uvicorn (==0.28.1)
|
|
48
50
|
Requires-Dist: xlsxwriter (>=3,<4)
|
|
49
51
|
Description-Content-Type: text/markdown
|
|
50
52
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
ecodev_core/__init__.py,sha256=
|
|
1
|
+
ecodev_core/__init__.py,sha256=BcZLnkIVxOlVVXubWqKAAMRbUyFQt8v6JgfawC_6cPY,4970
|
|
2
2
|
ecodev_core/app_activity.py,sha256=_rU5uPfttHxXX5IaCuTA7K9We5w2qluJ3Xpf6i12HhY,3763
|
|
3
3
|
ecodev_core/app_rights.py,sha256=RZPdDtydFqc_nFj96huKAc56BS0qS6ScKv4Kghqd6lc,726
|
|
4
4
|
ecodev_core/app_user.py,sha256=r1bqA4H08x53XmxmjwyGKl_PFjYQazzBbVErdkztqeE,2947
|
|
@@ -13,14 +13,14 @@ ecodev_core/db_insertion.py,sha256=RSCyAlUObbBlWJuMRX-YFY4VgtWqYLdwRqMWw--x95Y,3
|
|
|
13
13
|
ecodev_core/db_retrieval.py,sha256=IxyF3ZtKgACLiNFggK7boKggvMRKYDRD2IimxU4dap4,7345
|
|
14
14
|
ecodev_core/email_sender.py,sha256=XD7jAVXhGzvbiHqMhK9_aTEIS70Lw_CmPeAxRZGji-Y,1610
|
|
15
15
|
ecodev_core/enum_utils.py,sha256=BkQ4YQ97tXBYmMcQiSIi0mbioD5CgVU79myg1BBAXuA,556
|
|
16
|
-
ecodev_core/list_utils.py,sha256=
|
|
16
|
+
ecodev_core/list_utils.py,sha256=s56vvhylMFzi6A76YvOIi4d5QYml73n_TmYNq1wM_P4,4427
|
|
17
17
|
ecodev_core/logger.py,sha256=AWGGNZz12Ql0JDq1wCJQxwxK2syiczEBftmuJkjbAPw,3149
|
|
18
18
|
ecodev_core/pandas_utils.py,sha256=Juc6gvPnoBiSVF2SR6_vfMi5W-QEkY3fnpo5ROB1L9s,2191
|
|
19
19
|
ecodev_core/permissions.py,sha256=WAx-ilMu8LlQp2sjJVdkhNQieytEaEm8577ZF1HWeTY,502
|
|
20
20
|
ecodev_core/pydantic_utils.py,sha256=e3GH50JmcpTmd2UgrB94QSwWOlOCW3WIlVdyX9C4T-U,741
|
|
21
21
|
ecodev_core/read_write.py,sha256=auJ5bBJTVGkLRkiP_vZxVCX64B0Y-9qpsaDhovHmbas,996
|
|
22
22
|
ecodev_core/safe_utils.py,sha256=JCfxo6fcznjsL-XHNJ1TKo1UvfJB83WT5jpTFmtJwsE,6160
|
|
23
|
-
ecodev_core-0.0.
|
|
24
|
-
ecodev_core-0.0.
|
|
25
|
-
ecodev_core-0.0.
|
|
26
|
-
ecodev_core-0.0.
|
|
23
|
+
ecodev_core-0.0.32.dist-info/LICENSE.md,sha256=jebQDe1ib9LAODuNvcSoo2CoqS6P0_q8--mMTICh_kI,1074
|
|
24
|
+
ecodev_core-0.0.32.dist-info/METADATA,sha256=Uy4lhKuQ_euDjiVQEmpBNAItotolBTm8iFrYLqeJGfk,3385
|
|
25
|
+
ecodev_core-0.0.32.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
26
|
+
ecodev_core-0.0.32.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|