ae-base 0.3.55__py3-none-any.whl → 0.3.57__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.
- ae/base.py +28 -16
- {ae_base-0.3.55.dist-info → ae_base-0.3.57.dist-info}/METADATA +6 -6
- ae_base-0.3.57.dist-info/RECORD +7 -0
- {ae_base-0.3.55.dist-info → ae_base-0.3.57.dist-info}/WHEEL +1 -1
- {ae_base-0.3.55.dist-info → ae_base-0.3.57.dist-info}/licenses/LICENSE.md +1 -1
- ae_base-0.3.55.dist-info/RECORD +0 -7
- {ae_base-0.3.55.dist-info → ae_base-0.3.57.dist-info}/top_level.txt +0 -0
- {ae_base-0.3.55.dist-info → ae_base-0.3.57.dist-info}/zip-safe +0 -0
ae/base.py
CHANGED
|
@@ -32,6 +32,9 @@ sortable and compact string from a timestamp.
|
|
|
32
32
|
base helper functions
|
|
33
33
|
---------------------
|
|
34
34
|
|
|
35
|
+
most programming languages providing a function to determine the sign of a number. the :func:`sign` functino,
|
|
36
|
+
provided by this module/portion is filling this gap in Python.
|
|
37
|
+
|
|
35
38
|
in order to convert and transfer Unicode character outside the 7-bit ASCII range via internet transport protocols,
|
|
36
39
|
like http, use the helper functions :func:`ascii_str` and :func:`str_ascii`.
|
|
37
40
|
|
|
@@ -165,10 +168,10 @@ from contextlib import contextmanager
|
|
|
165
168
|
from importlib.machinery import ModuleSpec
|
|
166
169
|
from inspect import getinnerframes, getouterframes, getsourcefile
|
|
167
170
|
from types import ModuleType
|
|
168
|
-
from typing import Any, Callable, Generator, Iterable, Optional, Union, cast
|
|
171
|
+
from typing import Any, Callable, Generator, Iterable, MutableMapping, Optional, Union, cast
|
|
169
172
|
|
|
170
173
|
|
|
171
|
-
__version__ = '0.3.
|
|
174
|
+
__version__ = '0.3.57'
|
|
172
175
|
|
|
173
176
|
|
|
174
177
|
os_path_abspath = os.path.abspath
|
|
@@ -630,24 +633,24 @@ def load_dotenvs():
|
|
|
630
633
|
|
|
631
634
|
.. hint:: call from the main module of project/app in order to also load ``.env`` files in/above the project folder.
|
|
632
635
|
"""
|
|
633
|
-
|
|
636
|
+
env_vars = os.environ
|
|
637
|
+
load_env_var_defaults(os.getcwd(), env_vars)
|
|
634
638
|
if file_name := stack_var('__file__'):
|
|
635
|
-
load_env_var_defaults(os_path_dirname(os_path_abspath(file_name)))
|
|
639
|
+
load_env_var_defaults(os_path_dirname(os_path_abspath(file_name)), env_vars)
|
|
636
640
|
|
|
637
641
|
|
|
638
|
-
def load_env_var_defaults(start_dir: str):
|
|
639
|
-
"""
|
|
642
|
+
def load_env_var_defaults(start_dir: str, env_vars: MutableMapping[str, str]):
|
|
643
|
+
""" load undeclared env var defaults from a chain of ``.env`` files starting in the specified folder or its parent.
|
|
640
644
|
|
|
641
|
-
:param start_dir: folder to start search of an ``.env`` file, if not found, then checks the parent
|
|
642
|
-
if
|
|
643
|
-
into
|
|
645
|
+
:param start_dir: folder to start search of an ``.env`` file, if not found, then also checks the parent
|
|
646
|
+
folder. if an ``.env `` file got found, then put their shell environment variable values
|
|
647
|
+
into the specified :paramref:`~load_env_var_defaults.env_vars` mapping if they are not
|
|
648
|
+
already there. after processing the first ``.env`` file, it repeats to check for
|
|
644
649
|
further ``.env`` files in the parent folder to load them too, until either detecting
|
|
645
650
|
a folder without an ``.env`` file or until an ``.env`` got loaded from the root folder.
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
value specified in the ``.env`` file to be loaded). the variable values declared in the subfolders
|
|
650
|
-
are having preference over the values declared in the parent folders.
|
|
651
|
+
:param env_vars: environment variables mapping to be amended with env variable values from any
|
|
652
|
+
found ``.env`` file. pass Python's :data:`os.environ` to amend this mapping directly
|
|
653
|
+
with all the already not declared environment variables.
|
|
651
654
|
"""
|
|
652
655
|
file_path = os_path_abspath(os_path_join(start_dir, DOTENV_FILE_NAME))
|
|
653
656
|
if not os_path_isfile(file_path):
|
|
@@ -655,8 +658,8 @@ def load_env_var_defaults(start_dir: str):
|
|
|
655
658
|
|
|
656
659
|
while os_path_isfile(file_path):
|
|
657
660
|
for var_nam, var_val in parse_dotenv(file_path).items():
|
|
658
|
-
if var_nam not in
|
|
659
|
-
|
|
661
|
+
if var_nam not in env_vars:
|
|
662
|
+
env_vars[var_nam] = var_val
|
|
660
663
|
|
|
661
664
|
if os.sep not in file_path:
|
|
662
665
|
break # pragma: no cover # prevent endless-loop for ``.env`` file in root dir (os.sep == '/')
|
|
@@ -1018,6 +1021,15 @@ def round_traditional(num_value: float, num_digits: int = 0) -> float:
|
|
|
1018
1021
|
return round(num_value + 10 ** (-len(str(num_value)) - 1), num_digits)
|
|
1019
1022
|
|
|
1020
1023
|
|
|
1024
|
+
def sign(number: float) -> int:
|
|
1025
|
+
""" return ths sign (-1, 0, 1) of a number.
|
|
1026
|
+
|
|
1027
|
+
:param number: any number of type float or int.
|
|
1028
|
+
:return: -1 if the number is negative, 0 if it is zero, or 1 if it is positive.
|
|
1029
|
+
"""
|
|
1030
|
+
return (number > 0) - (number < 0)
|
|
1031
|
+
|
|
1032
|
+
|
|
1021
1033
|
def snake_to_camel(name: str, back_convertible: bool = False) -> str:
|
|
1022
1034
|
""" convert name from snake_case to CamelCase.
|
|
1023
1035
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ae_base
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.57
|
|
4
4
|
Summary: ae namespace module portion base: basic constants, helper functions and context manager
|
|
5
5
|
Home-page: https://gitlab.com/ae-group/ae_base
|
|
6
6
|
Author: AndiEcker
|
|
@@ -67,19 +67,19 @@ Dynamic: provides-extra
|
|
|
67
67
|
Dynamic: requires-python
|
|
68
68
|
Dynamic: summary
|
|
69
69
|
|
|
70
|
-
<!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae V0.3.
|
|
70
|
+
<!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae V0.3.96 -->
|
|
71
71
|
<!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_namespace_root V0.3.14 -->
|
|
72
|
-
# base 0.3.
|
|
72
|
+
# base 0.3.57
|
|
73
73
|
|
|
74
74
|
[](
|
|
75
75
|
https://gitlab.com/ae-group/ae_base)
|
|
76
76
|
[](
|
|
78
|
+
https://gitlab.com/ae-group/ae_base/-/tree/release0.3.56)
|
|
79
79
|
[](
|
|
80
80
|
https://pypi.org/project/ae-base/#history)
|
|
81
81
|
|
|
82
|
-
>
|
|
82
|
+
>ae namespace module portion base: basic constants, helper functions and context manager.
|
|
83
83
|
|
|
84
84
|
[](
|
|
85
85
|
https://ae-group.gitlab.io/ae_base/coverage/index.html)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ae/base.py,sha256=qeqUQx1aByTZ4TphLHMqHFb-DQ3mjjjAQHk07_7J4Ts,67354
|
|
2
|
+
ae_base-0.3.57.dist-info/licenses/LICENSE.md,sha256=k61Ar-RjA09gAZejD19C5g-mItE0OuhIC4zU0gbYpXE,35002
|
|
3
|
+
ae_base-0.3.57.dist-info/METADATA,sha256=CNz-UlnyEAwK4y139Wo1hJWqdzEhH28n1J_jULM4nmc,5724
|
|
4
|
+
ae_base-0.3.57.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
5
|
+
ae_base-0.3.57.dist-info/top_level.txt,sha256=vUdgAslSmhZLXWU48fm8AG2BjVnkOWLco8rzuW-5zY0,3
|
|
6
|
+
ae_base-0.3.57.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
7
|
+
ae_base-0.3.57.dist-info/RECORD,,
|
ae_base-0.3.55.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
ae/base.py,sha256=6ZmvIe_n1v7aLwClLsTUYgEzA38iyZ3azQrqg5x_qPg,66623
|
|
2
|
-
ae_base-0.3.55.dist-info/licenses/LICENSE.md,sha256=uoIIfORuk4V8ZeNh6SN0EUhiU79RC-indIMFqePKVhY,35002
|
|
3
|
-
ae_base-0.3.55.dist-info/METADATA,sha256=6XHzLSdO79byeul7zjCJiP5EP7A5Obbd1rUCsjLyFnc,5658
|
|
4
|
-
ae_base-0.3.55.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
|
5
|
-
ae_base-0.3.55.dist-info/top_level.txt,sha256=vUdgAslSmhZLXWU48fm8AG2BjVnkOWLco8rzuW-5zY0,3
|
|
6
|
-
ae_base-0.3.55.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
7
|
-
ae_base-0.3.55.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|