ae-base 0.3.56__py3-none-any.whl → 0.3.59__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 CHANGED
@@ -168,10 +168,10 @@ from contextlib import contextmanager
168
168
  from importlib.machinery import ModuleSpec
169
169
  from inspect import getinnerframes, getouterframes, getsourcefile
170
170
  from types import ModuleType
171
- from typing import Any, Callable, Generator, Iterable, Optional, Union, cast
171
+ from typing import Any, Callable, Generator, Iterable, MutableMapping, Optional, Union, cast
172
172
 
173
173
 
174
- __version__ = '0.3.56'
174
+ __version__ = '0.3.59'
175
175
 
176
176
 
177
177
  os_path_abspath = os.path.abspath
@@ -633,33 +633,34 @@ def load_dotenvs():
633
633
 
634
634
  .. hint:: call from the main module of project/app in order to also load ``.env`` files in/above the project folder.
635
635
  """
636
- load_env_var_defaults(os.getcwd())
636
+ env_vars = os.environ
637
+ load_env_var_defaults(os.getcwd(), env_vars)
637
638
  if file_name := stack_var('__file__'):
638
- 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)
639
640
 
640
641
 
641
- def load_env_var_defaults(start_dir: str):
642
- """ detect and load a chain of ``.env`` files starting in the specified folder or one above.
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.
643
644
 
644
- :param start_dir: folder to start search of an ``.env`` file, if not found, then checks the parent folder.
645
- if the first ``.env `` file got found, then load their shell environment variables
646
- into Python's :data:`os.environ`. after loading the first one, it repeats to check for
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
647
649
  further ``.env`` files in the parent folder to load them too, until either detecting
648
650
  a folder without an ``.env`` file or until an ``.env`` got loaded from the root folder.
649
-
650
- .. note::
651
- only variables that are not declared in :data:`os.environ` will be added (with the
652
- value specified in the ``.env`` file to be loaded). the variable values declared in the subfolders
653
- 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.
654
654
  """
655
- file_path = os_path_abspath(os_path_join(start_dir, DOTENV_FILE_NAME))
655
+ start_dir = norm_path(start_dir)
656
+ file_path = os_path_join(start_dir, DOTENV_FILE_NAME)
656
657
  if not os_path_isfile(file_path):
657
658
  file_path = os_path_join(os_path_dirname(start_dir), DOTENV_FILE_NAME)
658
659
 
659
660
  while os_path_isfile(file_path):
660
661
  for var_nam, var_val in parse_dotenv(file_path).items():
661
- if var_nam not in os.environ:
662
- os.environ[var_nam] = var_val
662
+ if var_nam not in env_vars:
663
+ env_vars[var_nam] = var_val
663
664
 
664
665
  if os.sep not in file_path:
665
666
  break # pragma: no cover # prevent endless-loop for ``.env`` file in root dir (os.sep == '/')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ae_base
3
- Version: 0.3.56
3
+ Version: 0.3.59
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.95 -->
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.56
72
+ # base 0.3.59
73
73
 
74
74
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_base/develop?logo=python)](
75
75
  https://gitlab.com/ae-group/ae_base)
76
76
  [![LatestPyPIrelease](
77
- https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.55?logo=python)](
78
- https://gitlab.com/ae-group/ae_base/-/tree/release0.3.55)
77
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.57?logo=python)](
78
+ https://gitlab.com/ae-group/ae_base/-/tree/release0.3.57)
79
79
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_base)](
80
80
  https://pypi.org/project/ae-base/#history)
81
81
 
82
- >ae_base module 0.3.56.
82
+ >ae namespace module portion base: basic constants, helper functions and context manager.
83
83
 
84
84
  [![Coverage](https://ae-group.gitlab.io/ae_base/coverage.svg)](
85
85
  https://ae-group.gitlab.io/ae_base/coverage/index.html)
@@ -0,0 +1,7 @@
1
+ ae/base.py,sha256=Ki2ROdjP0ZRbi96s_Im1wwFMzE0ou3a92Nzkubhd-rM,67374
2
+ ae_base-0.3.59.dist-info/licenses/LICENSE.md,sha256=k61Ar-RjA09gAZejD19C5g-mItE0OuhIC4zU0gbYpXE,35002
3
+ ae_base-0.3.59.dist-info/METADATA,sha256=pZr_N86DQFM5QpxSEx8b6VKqOX2NWn4NxGSfXpyiGnI,5724
4
+ ae_base-0.3.59.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ ae_base-0.3.59.dist-info/top_level.txt,sha256=vUdgAslSmhZLXWU48fm8AG2BjVnkOWLco8rzuW-5zY0,3
6
+ ae_base-0.3.59.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
7
+ ae_base-0.3.59.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,4 +1,4 @@
1
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_project V0.3.32 -->
1
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_project V0.3.35 -->
2
2
  ### GNU GENERAL PUBLIC LICENSE
3
3
 
4
4
  Version 3, 29 June 2007
@@ -1,7 +0,0 @@
1
- ae/base.py,sha256=HiiR5KcrcvJZ8gE_ngjYdqfd9gF5YrBP02uHUkTT954,67095
2
- ae_base-0.3.56.dist-info/licenses/LICENSE.md,sha256=uoIIfORuk4V8ZeNh6SN0EUhiU79RC-indIMFqePKVhY,35002
3
- ae_base-0.3.56.dist-info/METADATA,sha256=KvkrPODF2OUIAIhmGwPciNfAv1WkJQWmWxFLWgvpxQ4,5658
4
- ae_base-0.3.56.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
5
- ae_base-0.3.56.dist-info/top_level.txt,sha256=vUdgAslSmhZLXWU48fm8AG2BjVnkOWLco8rzuW-5zY0,3
6
- ae_base-0.3.56.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
7
- ae_base-0.3.56.dist-info/RECORD,,