ae-base 0.3.46__tar.gz → 0.3.48__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,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: ae_base
3
- Version: 0.3.46
3
+ Version: 0.3.48
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
@@ -53,20 +53,32 @@ Requires-Dist: typing; extra == "tests"
53
53
  Requires-Dist: types-setuptools; extra == "tests"
54
54
  Requires-Dist: wheel; extra == "tests"
55
55
  Requires-Dist: twine; extra == "tests"
56
+ Dynamic: author
57
+ Dynamic: author-email
58
+ Dynamic: classifier
59
+ Dynamic: description
60
+ Dynamic: description-content-type
61
+ Dynamic: home-page
62
+ Dynamic: keywords
63
+ Dynamic: license
64
+ Dynamic: project-url
65
+ Dynamic: provides-extra
66
+ Dynamic: requires-python
67
+ Dynamic: summary
56
68
 
57
69
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae V0.3.95 -->
58
70
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_namespace_root V0.3.14 -->
59
- # base 0.3.46
71
+ # base 0.3.48
60
72
 
61
73
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_base/develop?logo=python)](
62
74
  https://gitlab.com/ae-group/ae_base)
63
75
  [![LatestPyPIrelease](
64
- https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.45?logo=python)](
65
- https://gitlab.com/ae-group/ae_base/-/tree/release0.3.45)
76
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.47?logo=python)](
77
+ https://gitlab.com/ae-group/ae_base/-/tree/release0.3.47)
66
78
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_base)](
67
79
  https://pypi.org/project/ae-base/#history)
68
80
 
69
- >ae_base module 0.3.46.
81
+ >ae_base module 0.3.48.
70
82
 
71
83
  [![Coverage](https://ae-group.gitlab.io/ae_base/coverage.svg)](
72
84
  https://ae-group.gitlab.io/ae_base/coverage/index.html)
@@ -1,16 +1,16 @@
1
1
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae V0.3.95 -->
2
2
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_namespace_root V0.3.14 -->
3
- # base 0.3.46
3
+ # base 0.3.48
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.45?logo=python)](
9
- https://gitlab.com/ae-group/ae_base/-/tree/release0.3.45)
8
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.47?logo=python)](
9
+ https://gitlab.com/ae-group/ae_base/-/tree/release0.3.47)
10
10
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_base)](
11
11
  https://pypi.org/project/ae-base/#history)
12
12
 
13
- >ae_base module 0.3.46.
13
+ >ae_base module 0.3.48.
14
14
 
15
15
  [![Coverage](https://ae-group.gitlab.io/ae_base/coverage.svg)](
16
16
  https://ae-group.gitlab.io/ae_base/coverage/index.html)
@@ -5,6 +5,11 @@ basic constants, helper functions and context manager
5
5
  this module is pure python, has no external dependencies, and is providing base constants, common helper
6
6
  functions, useful classes and context managers.
7
7
 
8
+ .. note::
9
+ on import of this module, while running on Android OS, it will monkey patch the :mod:`shutil` module
10
+ to allow to use them on Android devices. therefore the import of this module should be one of the first ones
11
+ in your app's main module.
12
+
8
13
 
9
14
  base constants
10
15
  --------------
@@ -20,10 +25,6 @@ default values to compile file and folder names for a package or an app project
20
25
  :data:`PACKAGE_INCLUDE_FILES_PREFIX`, :data:`PY_EXT`, :data:`PY_INIT`, :data:`PY_MAIN`, :data:`CFG_EXT`
21
26
  and :data:`INI_EXT`.
22
27
 
23
- the constants :data:`PACKAGE_NAME`, :data:`PACKAGE_DOMAIN` and :data:`PERMISSIONS` are mainly
24
- used for apps running on mobile devices. to avoid redundancies, these values get loaded from the
25
- :data:`build config file <BUILD_CONFIG_FILE>` - if it exists in the current working directory.
26
-
27
28
  with the help of the format string constant :data:`NOW_STR_FORMAT` and the function :func:`now_str` you can create a
28
29
  sortable and compact string from a timestamp.
29
30
 
@@ -82,31 +83,13 @@ variables for your application are :func:`sys_env_dict` and :func:`sys_env_text`
82
83
  to integrate system environment variables from ``.env`` files into :data:`os.environ` the helper functions
83
84
  :func:parse_dotenv`, :func:`load_env_var_defaults` and :func:`load_dotenvs` are provided.
84
85
 
86
+ the :mod:`ae.core` portion is providing more OS-specific constants and helper functions, like e.g.
87
+ :func:`start_app_service` and :func:`request_app_permissions`.
85
88
 
86
- android-specific constants and helper functions
87
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88
-
89
- some helper functions of this module are provided to be used for the Android OS.
90
-
91
- the helper function :func:`start_app_service` is starting a service in its own, separate thread.
92
- with the function :func:`request_app_permissions` you can ensure that all your Android permissions will be
93
- requested. the module :mod:`ae.kivy.apps` does this automatically on app startup. on other platforms than
94
- Android it will have no effect to call these functions.
95
-
96
- .. note:: importing this module on an Android OS, it is monkey patching the :mod:`shutil` module to prevent crashes.
97
-
98
- links to other android code and service examples and documentation:
99
-
100
- * `https://python-for-android.readthedocs.io/en/latest/`__
101
- * `https://github.com/kivy/python-for-android/tree/develop/pythonforandroid/recipes/android/src/android`__
102
- * `https://github.com/tshirtman/kivy_service_osc/blob/master/src/main.py`__
103
- * `https://blog.kivy.org/2014/01/building-a-background-application-on-android-with-kivy/`__
104
- * `https://github.com/Android-for-Python/Android-for-Python-Users`__
105
- * `https://github.com/Android-for-Python/INDEX-of-Examples`__
106
-
107
- big thanks to `Robert Flatt <https://github.com/RobertFlatt>`__ for his investigations, findings and documentations to
108
- code and build Kivy apps for the Android OS, and to `Gabriel Pettier <https://github.com/tshirtman>`__ for his service
109
- osc example.
89
+ .. note::
90
+ on import of this module, while running on Android OS, it will monkey patch the :mod:`shutil` module to allow to
91
+ use them on Android devices, and on first app start request the permissions of your app. therefore to prevent
92
+ permission errors, the import of this module should be the first statement in the main module of your app.
110
93
 
111
94
 
112
95
  types, classes and mixins
@@ -149,7 +132,7 @@ another useful helper function provided by this portion to inspect and debug you
149
132
  os.path shortcuts
150
133
  -----------------
151
134
 
152
- the following data items are pointers to shortcut the lookup to their related functions in the
135
+ the following data items are pointers to shortcut at runtime the lookup to their related functions in the
153
136
  Python module :mod:`os.path`:
154
137
  """
155
138
  import datetime
@@ -173,7 +156,7 @@ from types import ModuleType
173
156
  from typing import Any, Callable, Dict, Generator, Iterable, List, Optional, Tuple, Union, cast
174
157
 
175
158
 
176
- __version__ = '0.3.46'
159
+ __version__ = '0.3.48'
177
160
 
178
161
 
179
162
  os_path_abspath = os.path.abspath
@@ -248,8 +231,7 @@ NOW_STR_FORMAT = "{sep}%Y%m%d{sep}%H%M%S{sep}%f" #: timestamp format of :func
248
231
  SKIPPED_MODULES = ('ae.base', 'ae.paths', 'ae.dynamicod', 'ae.core', 'ae.console', 'ae.gui_app', 'ae.gui_help',
249
232
  'ae.kivy', 'ae.kivy.apps', 'ae.kivy.behaviors', 'ae.kivy.i18n', 'ae.kivy.tours', 'ae.kivy.widgets',
250
233
  'ae.enaml_app', 'ae.beeware_app', 'ae.pyglet_app', 'ae.pygobject_app', 'ae.dabo_app',
251
- 'ae.qpython_app', 'ae.appjar_app', # removed in V 0.1.4: 'ae.lisz_app_data',
252
- 'importlib._bootstrap', 'importlib._bootstrap_external')
234
+ 'ae.qpython_app', 'ae.appjar_app', 'importlib._bootstrap', 'importlib._bootstrap_external')
253
235
  """ skipped modules used as default by :func:`module_name`, :func:`stack_var` and :func:`stack_vars` """
254
236
 
255
237
 
@@ -283,7 +265,7 @@ def app_name_guess() -> str:
283
265
  app_name = os_path_basename(path)
284
266
  if app_name.lower() in unspecified_app_names:
285
267
  app_name = "unguessable"
286
- return app_name
268
+ return defuse(app_name)
287
269
 
288
270
 
289
271
  def build_config_variable_values(*names_defaults: Tuple[str, Any], section: str = 'app') -> Tuple[Any, ...]:
@@ -364,7 +346,7 @@ ASCII_UNICODE = (
364
346
  ('^', '^'), # U+FF3E: Fullwidth Circumflex Accent
365
347
  (',', '﹐'), # U+FE50: Small Comma
366
348
  (' ', '␣'), # U+2423: Open Box; more see underneath and https://unicode-explorer.com/articles/space-characters:
367
- # ' ' U+00A0: No-Break Space (NBSP); '?¿?' U+1680 Ogham Space Mark; ' ' U+2000 En Quad;
349
+ # ' ' U+00A0: No-Break Space (NBSP); '' U+1680 Ogham Space Mark; ' ' U+2000 En Quad;
368
350
  # ' ' U+2001 Em Quad; ' ' U+2002 En Space; ' ' U+2003 Em Space; ' ' U+2004 Three-Per-Em
369
351
  # ' ' U+2005 Four-Per-Em; ' ' U+2006 Six-Per-Em; ' ' U+2007 Figure Space;
370
352
  # ' ' U+2008 Punctuation Space; ' ' U+2009 Thin; ' ' U+200A Hair Space;
@@ -758,7 +740,7 @@ def os_host_name() -> str:
758
740
 
759
741
  :return: machine name string.
760
742
  """
761
- return platform.node()
743
+ return defuse(platform.node()) or "indeterminableHostName"
762
744
 
763
745
 
764
746
  def os_local_ip() -> str:
@@ -1190,23 +1172,6 @@ class ErrorMsgMixin:
1190
1172
  self._err_msg = ""
1191
1173
 
1192
1174
 
1193
- # package and permissions handling defaults for all other platforms and frameworks
1194
- PACKAGE_NAME = stack_var('__name__') or 'unspecified_package' #: package name default
1195
- PACKAGE_DOMAIN = 'org.test' #: package domain default
1196
- PERMISSIONS = "INTERNET, VIBRATE, READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE" #: permissions default
1197
- if os_path_isfile(BUILD_CONFIG_FILE): # pragma: no cover
1198
- PACKAGE_NAME, PACKAGE_DOMAIN, PERMISSIONS = build_config_variable_values(
1199
- ('package.name', PACKAGE_NAME),
1200
- ('package.domain', PACKAGE_DOMAIN),
1201
- ('android.permissions', PERMISSIONS))
1202
- elif os_platform == 'android': # pragma: no cover
1203
- _importing_package = norm_path(stack_var('__file__') or 'empty_package' + PY_EXT)
1204
- if os_path_basename(_importing_package) in (PY_INIT, PY_MAIN):
1205
- _importing_package = os_path_dirname(_importing_package)
1206
- _importing_package = os_path_splitext(os_path_basename(_importing_package))[0]
1207
- write_file(f'{_importing_package}_debug.log', f"{BUILD_CONFIG_FILE} not bundled - using defaults\n", extra_mode='a')
1208
-
1209
-
1210
1175
  if os_platform == 'android': # pragma: no cover
1211
1176
  # monkey patch the :func:`shutil.copystat` and :func:`shutil.copymode` helper functions, which are crashing on
1212
1177
  # 'android' (see # `<https://bugs.python.org/issue28141>`__ and `<https://bugs.python.org/issue32073>`__). these
@@ -1216,41 +1181,3 @@ if os_platform == 'android': # pragma: no cov
1216
1181
  # on the destination root directory.
1217
1182
  shutil.copymode = dummy_function
1218
1183
  shutil.copystat = dummy_function
1219
-
1220
- # import permissions module from python-for-android (recipes/android/src/android/permissions.py)
1221
- # noinspection PyUnresolvedReferences
1222
- from android.permissions import request_permissions, Permission # type: ignore # pylint: disable=import-error
1223
- from jnius import autoclass # type: ignore
1224
-
1225
- def request_app_permissions(callback: Optional[Callable[[List[Permission], List[bool]], None]] = None):
1226
- """ request app/service permissions on Android OS.
1227
-
1228
- :param callback: optional callback receiving two list arguments with identical length,
1229
- the 1st with the requested permissions and
1230
- the 2nd with booleans stating if the permission got granted (True) or rejected (False).
1231
- """
1232
- permissions = []
1233
- for permission_str in PERMISSIONS.split(','):
1234
- permission = getattr(Permission, permission_str.strip(), None)
1235
- if permission:
1236
- permissions.append(permission)
1237
- request_permissions(permissions, callback=callback)
1238
-
1239
- def start_app_service(service_arg: str = "") -> Any:
1240
- """ start service.
1241
-
1242
- :param service_arg: string value to be assigned to environment variable PYTHON_SERVICE_ARGUMENT on start.
1243
- :return: service instance.
1244
-
1245
- see `<https://github.com/tshirtman/kivy_service_osc/blob/master/src/main.py>`__
1246
- and `<https://python-for-android.readthedocs.io/en/latest/services/#arbitrary-scripts-services>`__
1247
- """
1248
- service_instance = autoclass(f"{PACKAGE_DOMAIN}.{PACKAGE_NAME}.Service{PACKAGE_NAME.capitalize()}")
1249
- activity = autoclass('org.kivy.android.PythonActivity').mActivity
1250
- service_instance.start(activity, service_arg) # service_arg will be in env var PYTHON_SERVICE_ARGUMENT
1251
-
1252
- return service_instance
1253
-
1254
- else:
1255
- request_app_permissions = dummy_function
1256
- start_app_service = dummy_function
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: ae_base
3
- Version: 0.3.46
3
+ Version: 0.3.48
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
@@ -53,20 +53,32 @@ Requires-Dist: typing; extra == "tests"
53
53
  Requires-Dist: types-setuptools; extra == "tests"
54
54
  Requires-Dist: wheel; extra == "tests"
55
55
  Requires-Dist: twine; extra == "tests"
56
+ Dynamic: author
57
+ Dynamic: author-email
58
+ Dynamic: classifier
59
+ Dynamic: description
60
+ Dynamic: description-content-type
61
+ Dynamic: home-page
62
+ Dynamic: keywords
63
+ Dynamic: license
64
+ Dynamic: project-url
65
+ Dynamic: provides-extra
66
+ Dynamic: requires-python
67
+ Dynamic: summary
56
68
 
57
69
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae V0.3.95 -->
58
70
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_namespace_root V0.3.14 -->
59
- # base 0.3.46
71
+ # base 0.3.48
60
72
 
61
73
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_base/develop?logo=python)](
62
74
  https://gitlab.com/ae-group/ae_base)
63
75
  [![LatestPyPIrelease](
64
- https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.45?logo=python)](
65
- https://gitlab.com/ae-group/ae_base/-/tree/release0.3.45)
76
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_base/release0.3.47?logo=python)](
77
+ https://gitlab.com/ae-group/ae_base/-/tree/release0.3.47)
66
78
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_base)](
67
79
  https://pypi.org/project/ae-base/#history)
68
80
 
69
- >ae_base module 0.3.46.
81
+ >ae_base module 0.3.48.
70
82
 
71
83
  [![Coverage](https://ae-group.gitlab.io/ae_base/coverage.svg)](
72
84
  https://ae-group.gitlab.io/ae_base/coverage/index.html)
@@ -86,15 +86,18 @@ class TestErrorMsgMixin:
86
86
  class _AppMock(ErrorMsgMixin):
87
87
  cae = None
88
88
 
89
- def po(self):
89
+ @staticmethod
90
+ def po():
90
91
  """ po() mock """
91
92
  return "po"
92
93
 
93
- def dpo(self):
94
+ @staticmethod
95
+ def dpo():
94
96
  """ dpo() mock """
95
97
  return "dpo"
96
98
 
97
- def vpo(self):
99
+ @staticmethod
100
+ def vpo():
98
101
  """ vpo() mock """
99
102
  return "vpo"
100
103
 
File without changes
File without changes
File without changes