ae-base 0.3.67__tar.gz → 0.3.68__tar.gz

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.
@@ -1,4 +1,4 @@
1
- <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.53 -->
1
+ <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.55 -->
2
2
  ### GNU GENERAL PUBLIC LICENSE
3
3
 
4
4
  Version 3, 29 June 2007
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ae_base
3
- Version: 0.3.67
3
+ Version: 0.3.68
4
4
  Summary: ae namespace module portion base: basic constants, helper functions and context managers
5
5
  Home-page: https://gitlab.com/ae-group/ae_base
6
6
  Author: AndiEcker
@@ -65,13 +65,13 @@ Dynamic: summary
65
65
 
66
66
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.96 -->
67
67
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_namespace_root V0.3.14 -->
68
- # base 0.3.67
68
+ # base 0.3.68
69
69
 
70
70
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_base/develop?logo=python)](
71
71
  https://gitlab.com/ae-group/ae_base)
72
72
  [![LatestPyPIrelease](
73
- https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.66?logo=python)](
74
- https://gitlab.com/ae-group/ae_base/-/tree/release0.3.66)
73
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.67?logo=python)](
74
+ https://gitlab.com/ae-group/ae_base/-/tree/release0.3.67)
75
75
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_base)](
76
76
  https://pypi.org/project/ae-base/#history)
77
77
 
@@ -1,12 +1,12 @@
1
1
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.96 -->
2
2
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_namespace_root V0.3.14 -->
3
- # base 0.3.67
3
+ # base 0.3.68
4
4
 
5
5
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_base/develop?logo=python)](
6
6
  https://gitlab.com/ae-group/ae_base)
7
7
  [![LatestPyPIrelease](
8
- https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.66?logo=python)](
9
- https://gitlab.com/ae-group/ae_base/-/tree/release0.3.66)
8
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.67?logo=python)](
9
+ https://gitlab.com/ae-group/ae_base/-/tree/release0.3.67)
10
10
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_base)](
11
11
  https://pypi.org/project/ae-base/#history)
12
12
 
@@ -245,7 +245,7 @@ from types import ModuleType
245
245
  from typing import Any, Callable, Generator, Iterable, MutableMapping, Optional, Union, cast
246
246
 
247
247
 
248
- __version__ = '0.3.67'
248
+ __version__ = '0.3.68'
249
249
 
250
250
 
251
251
  os_path_abspath = os.path.abspath
@@ -428,7 +428,6 @@ def deep_dict_update(data: dict, update: dict, overwrite: bool = True):
428
428
  data[upd_key] = upd_val
429
429
 
430
430
 
431
- URI_SEP_CHAR = '⫻' # U+2AFB: TRIPLE SOLIDUS BINARY RELATION
432
431
  # noinspection GrazieInspection
433
432
  ASCII_UNICODE = (
434
433
  ('/', '⁄'), # U+2044: Fraction Slash; '∕' U+2215: Division Slash; '⧸' U+29F8: Big Solidus;
@@ -466,13 +465,19 @@ ASCII_UNICODE = (
466
465
  # ' ' U+202F: Narrow No-Break Space (NNBSP); ' ' U+205F Medium Mathematical Space;
467
466
  # '␠' U+2420 symbol for space; '␣' U+2423 Open Box; ' ' U+3000: Ideographic Space
468
467
  (chr(127), '␡'), # U+2421: DELETE SYMBOL
469
- # ('_', '𛲖'), # U+1BC96: Duployan Affix Low Line; '_' U+FF3F Fullwidth Low Line
470
- )
471
- """ transformation table of special ASCII to Unicode alternative character,
468
+ # ('_', '𛲖'), # U+1BC96: Duployan Affix Low Line; '_' U+FF3F Fullwidth Low Line
469
+ ) + tuple((chr(low_asc_ord), chr(0x2400 + low_asc_ord)) for low_asc_ord in range(32))
470
+ """ transformation table of special ASCII characters to a similar/alternative non-functional/-escaping Unicode char,
472
471
  see https://www.compart.com/en/unicode/category/Po and https://xahlee.info/comp/unicode_naming_slash.html (http!) """
473
472
 
474
- ASCII_TO_UNICODE = dict(ASCII_UNICODE) #: map to convert ASCII to an alternative defused Unicode character
475
- UNICODE_TO_ASCII = {unicode_char: ascii_char for ascii_char, unicode_char in ASCII_UNICODE} #: Unicode to ASCII map
473
+ URI_SEP_STR = '://' #: separator between service and address(host/path) in URIs
474
+ URI_SEP_UNICODE_CHAR = '⫻' #: single Unicode char for :data:`URI_SEP_STR` U+2AFB: TRIPLE SOLIDUS BINARY RELATION
475
+
476
+ ASCII_TO_UNICODE = str.maketrans(dict(ASCII_UNICODE))
477
+ """ :func:`str.translate` map to convert ASCII to an alternative defused Unicode character - used by :func:`defuse` """
478
+ UNICODE_TO_ASCII = str.maketrans({unicode_char: ascii_char for ascii_char, unicode_char in
479
+ ASCII_UNICODE + ((URI_SEP_STR, URI_SEP_UNICODE_CHAR), )})
480
+ """ :func:`str.translate` Unicode to ASCII map - used by :func:`dedefuse` """
476
481
 
477
482
 
478
483
  def dedefuse(value: str) -> str:
@@ -481,15 +486,7 @@ def dedefuse(value: str) -> str:
481
486
  :param value: string defused with the function :func:`defuse`.
482
487
  :return: re-activated form of the string (with all ASCII special characters recovered).
483
488
  """
484
- original = ""
485
- for char in value:
486
- if char in UNICODE_TO_ASCII:
487
- char = UNICODE_TO_ASCII[char]
488
- elif 0x2400 <= (code := ord(char)) <= 0x241F:
489
- char = chr(code - 0x2400)
490
- original += char
491
-
492
- return original.replace(URI_SEP_CHAR, '://')
489
+ return value.translate(UNICODE_TO_ASCII)
493
490
 
494
491
 
495
492
  def defuse(value: str) -> str:
@@ -515,15 +512,7 @@ def defuse(value: str) -> str:
515
512
  .. hint:: use the :func:`dedefuse` function to convert the defused string back to the corresponding URI/file-path.
516
513
 
517
514
  """
518
- defused = ""
519
- value = value.replace('://', URI_SEP_CHAR) # make URIs shorter
520
- for char in value:
521
- if char in ASCII_TO_UNICODE:
522
- char = ASCII_TO_UNICODE[char]
523
- elif (code := ord(char)) <= 31:
524
- char = chr(0x2400 + code)
525
- defused += char
526
- return defused
515
+ return value.replace(URI_SEP_STR, URI_SEP_UNICODE_CHAR).translate(ASCII_TO_UNICODE) # replace makes URIs shorter
527
516
 
528
517
 
529
518
  def dummy_function(*_args, **_kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ae_base
3
- Version: 0.3.67
3
+ Version: 0.3.68
4
4
  Summary: ae namespace module portion base: basic constants, helper functions and context managers
5
5
  Home-page: https://gitlab.com/ae-group/ae_base
6
6
  Author: AndiEcker
@@ -65,13 +65,13 @@ Dynamic: summary
65
65
 
66
66
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.96 -->
67
67
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_namespace_root V0.3.14 -->
68
- # base 0.3.67
68
+ # base 0.3.68
69
69
 
70
70
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_base/develop?logo=python)](
71
71
  https://gitlab.com/ae-group/ae_base)
72
72
  [![LatestPyPIrelease](
73
- https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.66?logo=python)](
74
- https://gitlab.com/ae-group/ae_base/-/tree/release0.3.66)
73
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.67?logo=python)](
74
+ https://gitlab.com/ae-group/ae_base/-/tree/release0.3.67)
75
75
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_base)](
76
76
  https://pypi.org/project/ae-base/#history)
77
77
 
@@ -1,4 +1,4 @@
1
- # THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.53
1
+ # THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.55
2
2
  [build-system]
3
3
  requires = ["setuptools>=42", "wheel"]
4
4
  build-backend = "setuptools.build_meta"
@@ -1,4 +1,4 @@
1
- # THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.53
1
+ # THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.project_tpls v0.3.55
2
2
  """ setup of ae namespace module portion base: basic constants, helper functions and context managers. """
3
3
  # noinspection PyUnresolvedReferences
4
4
  import sys
@@ -25,13 +25,13 @@ setup_kwargs = {
25
25
  'license': 'GPL-3.0-or-later',
26
26
  'long_description': ('<!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.96 -->\n'
27
27
  '<!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_namespace_root V0.3.14 -->\n'
28
- '# base 0.3.67\n'
28
+ '# base 0.3.68\n'
29
29
  '\n'
30
30
  '[![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_base/develop?logo=python)](\n'
31
31
  ' https://gitlab.com/ae-group/ae_base)\n'
32
32
  '[![LatestPyPIrelease](\n'
33
- ' https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.66?logo=python)](\n'
34
- ' https://gitlab.com/ae-group/ae_base/-/tree/release0.3.66)\n'
33
+ ' https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.67?logo=python)](\n'
34
+ ' https://gitlab.com/ae-group/ae_base/-/tree/release0.3.67)\n'
35
35
  '[![PyPIVersions](https://img.shields.io/pypi/v/ae_base)](\n'
36
36
  ' https://pypi.org/project/ae-base/#history)\n'
37
37
  '\n'
@@ -108,7 +108,7 @@ setup_kwargs = {
108
108
  'Source': 'https://ae.readthedocs.io/en/latest/_modules/ae/base.html'},
109
109
  'python_requires': '>=3.9',
110
110
  'url': 'https://gitlab.com/ae-group/ae_base',
111
- 'version': '0.3.67',
111
+ 'version': '0.3.68',
112
112
  'zip_safe': True,
113
113
  }
114
114
 
@@ -21,8 +21,8 @@ from urllib.error import HTTPError, URLError
21
21
 
22
22
  # noinspection PyProtectedMember
23
23
  from ae.base import (
24
- ASCII_TO_UNICODE, BUILD_CONFIG_FILE, DOTENV_FILE_NAME, PY_EXT, PY_INIT, PY_MAIN, TESTS_FOLDER, UNICODE_TO_ASCII,
25
- UNSET, URI_SEP_CHAR,
24
+ ASCII_TO_UNICODE, ASCII_UNICODE, BUILD_CONFIG_FILE, DOTENV_FILE_NAME, PY_EXT, PY_INIT, PY_MAIN, TESTS_FOLDER,
25
+ UNICODE_TO_ASCII, UNSET, URI_SEP_STR, URI_SEP_UNICODE_CHAR,
26
26
  app_name_guess, ascii_str, build_config_variable_values, camel_to_snake,
27
27
  dedefuse, deep_dict_update, defuse, dummy_function, duplicates, env_str, evaluate_literal,
28
28
  force_encoding, format_given, full_stack_trace, import_module, instantiate_config_parser, in_wd,
@@ -157,11 +157,11 @@ class TestBaseHelpers:
157
157
  assert all(ord(_) >= 128 for _ in uni_str)
158
158
  assert all(ord(_) < 128 for _ in ascii_str(uni_str))
159
159
 
160
- uni_str = "".join(UNICODE_TO_ASCII.keys())
160
+ uni_str = "".join(_uco for _asc, _uco in ASCII_UNICODE)
161
161
  assert any(ord(_) >= 128 for _ in uni_str)
162
162
  assert all(ord(_) < 128 for _ in ascii_str(uni_str))
163
163
 
164
- asc_str = "".join(ASCII_TO_UNICODE.keys())
164
+ asc_str = "".join(_asc for _asc, _uco in ASCII_UNICODE)
165
165
  assert any(ord(_) < 128 for _ in asc_str)
166
166
  assert all(ord(_) < 128 for _ in ascii_str(asc_str))
167
167
 
@@ -172,10 +172,10 @@ class TestBaseHelpers:
172
172
  uni_str = "äÄßéÉíÍñÑòÒùÙ"
173
173
  assert str_ascii(ascii_str(uni_str)) == uni_str
174
174
 
175
- uni_str = "".join(UNICODE_TO_ASCII.keys())
175
+ uni_str = "".join(_uco for _asc, _uco in ASCII_UNICODE)
176
176
  assert str_ascii(ascii_str(uni_str)) == uni_str
177
177
 
178
- asc_str = "".join(ASCII_TO_UNICODE.keys())
178
+ asc_str = "".join(_asc for _asc, _uco in ASCII_UNICODE)
179
179
  assert str_ascii(ascii_str(asc_str)) == asc_str
180
180
 
181
181
  def test_str_ascii_errors(self):
@@ -320,16 +320,18 @@ class TestBaseHelpers:
320
320
  os.remove(tst_fna2)
321
321
 
322
322
  def test_defuse_maps_integrity(self):
323
- assert URI_SEP_CHAR not in UNICODE_TO_ASCII
324
- assert len(UNICODE_TO_ASCII) == len(ASCII_TO_UNICODE) # check for duplicates in the ASCII_UNICODE map
323
+ assert len(ASCII_TO_UNICODE) == len(ASCII_UNICODE) # duplicates check in ASCII_UNICODE map
324
+ assert len(UNICODE_TO_ASCII) == len(ASCII_UNICODE) + 1 # -"-, having also the ord(URI_SEP_UNICODE_CHAR) key
325
+ assert ord(URI_SEP_UNICODE_CHAR) in UNICODE_TO_ASCII
326
+ assert UNICODE_TO_ASCII[ord(URI_SEP_UNICODE_CHAR)] == URI_SEP_STR
325
327
 
326
328
  def test_defuse_maps_not_touching_chars_allowed_as_slug_and_filename(self):
327
- assert '-' not in ASCII_TO_UNICODE
328
- assert '_' not in ASCII_TO_UNICODE
329
- assert '.' not in ASCII_TO_UNICODE
330
- assert '~' not in ASCII_TO_UNICODE
329
+ assert ord('-') not in ASCII_TO_UNICODE
330
+ assert ord('_') not in ASCII_TO_UNICODE
331
+ assert ord('.') not in ASCII_TO_UNICODE
332
+ assert ord('~') not in ASCII_TO_UNICODE
331
333
  for char in string.ascii_letters + string.digits:
332
- assert char not in ASCII_TO_UNICODE
334
+ assert ord(char) not in ASCII_TO_UNICODE
333
335
 
334
336
  def test_dummy_function(self):
335
337
  assert dummy_function() is None
File without changes