ae-base 0.3.63__py3-none-any.whl → 0.3.65__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
@@ -32,6 +32,10 @@ sortable and compact string from a timestamp.
32
32
  base helper functions
33
33
  ---------------------
34
34
 
35
+ the function :func:`evaluate_literal` can be used as an replacement of :func:`ast.literal_eval` to retrieve
36
+ basic data structure values from config, ini and .env files, while also accepting unquoted strings as a `str` type
37
+ instance.
38
+
35
39
  most programming languages providing a function to determine the sign of a number. the :func:`sign` functino,
36
40
  provided by this module/portion is filling this gap in Python.
37
41
 
@@ -148,6 +152,7 @@ os.path shortcuts
148
152
  the following data items are pointers to shortcut at runtime the lookup to their related functions in the
149
153
  Python module :mod:`os.path`:
150
154
  """
155
+ # pylint: disable=too-many-lines
151
156
  import datetime
152
157
  import getpass
153
158
  import importlib.abc
@@ -171,7 +176,7 @@ from types import ModuleType
171
176
  from typing import Any, Callable, Generator, Iterable, MutableMapping, Optional, Union, cast
172
177
 
173
178
 
174
- __version__ = '0.3.63'
179
+ __version__ = '0.3.65'
175
180
 
176
181
 
177
182
  os_path_abspath = os.path.abspath
@@ -494,6 +499,20 @@ def env_str(name: str, convert_name: bool = False) -> Optional[str]:
494
499
  return os.environ.get(name)
495
500
 
496
501
 
502
+ def evaluate_literal(literal_string: str) -> Any:
503
+ """ evaluates a Python expression while accepting unquoted strings as str type.
504
+
505
+ :param literal_string: any literal of the base types (like dict, list, set, tuple) which are recognized
506
+ by :func:`ast.literal_eval`.
507
+ :return: an instance of the data type or the specified string, even if it is not quoted with
508
+ high comma characters.
509
+ """
510
+ try:
511
+ return literal_eval(literal_string)
512
+ except (IndentationError, SyntaxError, TypeError, ValueError):
513
+ return literal_string
514
+
515
+
497
516
  def force_encoding(text: Union[str, bytes], encoding: str = DEF_ENCODING, errors: str = DEF_ENCODE_ERRORS) -> str:
498
517
  """ force/ensure the encoding of text (str or bytes) without any UnicodeDecodeError/UnicodeEncodeError.
499
518
 
@@ -1249,30 +1268,25 @@ def write_file(file_path: str, content: Union[str, bytes],
1249
1268
  class ErrorMsgMixin: # pylint: disable=too-few-public-methods
1250
1269
  """ mixin class providing sophisticated error message handling. """
1251
1270
  _err_msg: str = ""
1252
-
1253
- cae = None
1254
- po = print
1255
- dpo = print
1256
- vpo = print
1271
+ main_app = None
1272
+ po = dpo = vpo = print
1257
1273
 
1258
1274
  def __init__(self):
1259
1275
  try:
1260
1276
  from ae.core import main_app_instance # type: ignore # pylint: disable=import-outside-toplevel
1261
1277
 
1262
- self.cae = cae = main_app_instance()
1263
- assert cae is not None, f"{self.__class__.__name__}.__init__() called too early; main app instance not"
1278
+ self.main_app = main_app = main_app_instance()
1279
+ assert main_app is not None, f"{self.__class__.__name__}.__init__() called too early; main app instance not"
1264
1280
 
1265
- self.po = cae.po
1266
- self.dpo = cae.dpo
1267
- self.vpo = cae.vpo
1281
+ self.po = main_app.po
1282
+ self.dpo = main_app.dpo
1283
+ self.vpo = main_app.vpo
1268
1284
 
1269
1285
  except (ImportError, AssertionError, Exception) as exc: # pylint: disable=broad-except
1270
1286
  print(f"{self.__class__.__name__}.__init__() raised {exc}; using print() instead of main app error loggers")
1271
1287
 
1272
- # self.cae = None
1273
- # self.po = print
1274
- # self.dpo = print
1275
- # self.vpo = print
1288
+ # self.main_app = None
1289
+ # self.po = self.dpo = self.vpo = print
1276
1290
 
1277
1291
  @property
1278
1292
  def error_message(self) -> str:
@@ -1,29 +1,29 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ae_base
3
- Version: 0.3.63
3
+ Version: 0.3.65
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
7
7
  Author-email: aecker2@gmail.com
8
- License: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
8
+ License: GPL-3.0-or-later
9
9
  Project-URL: Bug Tracker, https://gitlab.com/ae-group/ae_base/-/issues
10
10
  Project-URL: Documentation, https://ae.readthedocs.io/en/latest/_autosummary/ae.base.html
11
11
  Project-URL: Repository, https://gitlab.com/ae-group/ae_base
12
12
  Project-URL: Source, https://ae.readthedocs.io/en/latest/_modules/ae/base.html
13
13
  Keywords: configuration,development,environment,productivity
14
14
  Classifier: Development Status :: 3 - Alpha
15
- Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
16
15
  Classifier: Natural Language :: English
17
16
  Classifier: Operating System :: OS Independent
18
17
  Classifier: Programming Language :: Python
19
18
  Classifier: Programming Language :: Python :: 3
20
19
  Classifier: Programming Language :: Python :: 3.9
21
20
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
22
  Requires-Python: >=3.9
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE.md
25
25
  Provides-Extra: dev
26
- Requires-Dist: aedev_tpl_project; extra == "dev"
26
+ Requires-Dist: aedev_project_tpls; extra == "dev"
27
27
  Requires-Dist: ae_ae; extra == "dev"
28
28
  Requires-Dist: anybadge; extra == "dev"
29
29
  Requires-Dist: coverage-badge; extra == "dev"
@@ -69,13 +69,13 @@ Dynamic: summary
69
69
 
70
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.63
72
+ # base 0.3.65
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.61?logo=python)](
78
- https://gitlab.com/ae-group/ae_base/-/tree/release0.3.61)
77
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.64?logo=python)](
78
+ https://gitlab.com/ae-group/ae_base/-/tree/release0.3.64)
79
79
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_base)](
80
80
  https://pypi.org/project/ae-base/#history)
81
81
 
@@ -0,0 +1,7 @@
1
+ ae/base.py,sha256=dMNP9veLav-IvUULLmNPs1PXpHQ2xAn5WMva9qIVRKk,68719
2
+ ae_base-0.3.65.dist-info/licenses/LICENSE.md,sha256=-UEWsJNTHESFg25my1bZ5yx9aZzHD04wbguYc6ZfgEY,35003
3
+ ae_base-0.3.65.dist-info/METADATA,sha256=s82tpQCZKNjEzSNvz-9KEWY5AkXzRDHIzUJChWcg-vk,5619
4
+ ae_base-0.3.65.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ ae_base-0.3.65.dist-info/top_level.txt,sha256=vUdgAslSmhZLXWU48fm8AG2BjVnkOWLco8rzuW-5zY0,3
6
+ ae_base-0.3.65.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
7
+ ae_base-0.3.65.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_project V0.3.36 -->
1
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls V0.3.45 -->
2
2
  ### GNU GENERAL PUBLIC LICENSE
3
3
 
4
4
  Version 3, 29 June 2007
@@ -1,7 +0,0 @@
1
- ae/base.py,sha256=8sCPZbEHi_XZEZYmHaekTQRlz7T2_EVBWnu_4MfXUAk,67833
2
- ae_base-0.3.63.dist-info/licenses/LICENSE.md,sha256=vn9XT8MDUxNAWsP60HLwHJp8ZLOI0OJBRe-1N2xXh08,35002
3
- ae_base-0.3.63.dist-info/METADATA,sha256=Wy4QjjplmPR9IpU2VoXe4eF-bxBS0DMjN1WeX6hbLEA,5724
4
- ae_base-0.3.63.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
- ae_base-0.3.63.dist-info/top_level.txt,sha256=vUdgAslSmhZLXWU48fm8AG2BjVnkOWLco8rzuW-5zY0,3
6
- ae_base-0.3.63.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
7
- ae_base-0.3.63.dist-info/RECORD,,