ka-uts-com 4.0.0.250510__py3-none-any.whl → 4.0.4.250522__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.
ka_uts_com/__version__.py CHANGED
@@ -1,10 +1,10 @@
1
1
  __title__ = 'ka_uts_com'
2
- __description__ = 'Communication Utilities.'
2
+ __description__ = 'Communication and CLI Utilities.'
3
3
  __url__ = 'https://ka-ut-com.readthedocs.io/en/latest'
4
- __version__ = '4.0.0.250510'
4
+ __version__ = '4.0.4.250522'
5
5
  __build__ = 0x022200
6
6
  __author__ = 'Bernd Stroehle'
7
7
  __author_email__ = 'bernd.stroehle@gmail.com'
8
- __license__ = 'Apache-2.0'
8
+ __license__ = 'GPL-3.0-only WITH Classpath-Exception-2.0 OR BSD-3-Clause'
9
9
  __copyright__ = 'Copyright 2025 Bernd Stroehle'
10
10
  __cake__ = u'\u2728 \U0001f370 \u2728'
ka_uts_com/com.py CHANGED
@@ -6,12 +6,6 @@ import calendar
6
6
  from datetime import datetime
7
7
 
8
8
  from ka_uts_arr.aoeq import AoEq
9
- from ka_uts_uts.utils.pacmod import PacMod
10
-
11
- from ka_uts_com.app import App
12
- from ka_uts_com.cfg import Cfg
13
- from ka_uts_com.exit import Exit
14
-
15
9
  from ka_uts_log.log import Log
16
10
 
17
11
  TyAny = Any
@@ -33,22 +27,22 @@ class Com:
33
27
  """
34
28
  Communication Class
35
29
  """
30
+ cmd: TnStr = None
36
31
  sw_init: bool = False
32
+
33
+ com_a_mod = None
34
+ com_pac = None
35
+ app_a_mod = None
36
+ app_pac = None
37
37
  tenant: TnStr = None
38
- cmd: TnStr = None
39
- d_com_pacmod: TyDic = {}
40
- d_app_pacmod: TyDic = {}
41
38
 
42
39
  ts: TnTimeStamp
43
- # ts_start: TnDateTime = None
44
- # ts_end: TnDateTime = None
45
- # ts_etime: TnDateTime = None
46
40
  d_timer: TyDic = {}
47
41
 
48
- Cfg: TnDic = None
49
42
  Log: Any = None
50
- App: Any = None
51
- Exit: Any = None
43
+ # Cfg: TnDic = None
44
+ # App: Any = None
45
+ # Exit: Any = None
52
46
 
53
47
  @classmethod
54
48
  def init(cls, kwargs: TyDic):
@@ -59,17 +53,19 @@ class Com:
59
53
  if cls.sw_init:
60
54
  return
61
55
  cls.sw_init = True
62
- cls.tenant = kwargs.get('tenant')
63
56
  cls.cmd = kwargs.get('cmd')
64
- cls_app = kwargs.get('cls_app')
65
- cls.d_com_pacmod = PacMod.sh_d_pacmod(cls)
66
- cls.d_app_pacmod = PacMod.sh_d_pacmod(cls_app)
57
+ cls.com_a_mod = cls.__module__.split(".")
58
+ cls.com_pac = cls.com_a_mod[0]
59
+ _cls_app = kwargs.get('cls_app')
60
+ cls.app_a_mod = _cls_app.__module__.split(".")
61
+ cls.app_pac = cls.app_a_mod[0]
62
+ cls.tenant = kwargs.get('tenant')
67
63
  cls.ts = calendar.timegm(time.gmtime())
68
64
 
69
65
  cls.Log = Log.sh(**kwargs)
70
- cls.Cfg = Cfg.sh(cls, **kwargs)
71
- cls.App = App.sh(cls, **kwargs)
72
- cls.Exit = Exit.sh(**kwargs)
66
+ # cls.Cfg = Cfg.sh(cls, **kwargs)
67
+ # cls.App = App.sh(cls, **kwargs)
68
+ # cls.Exit = Exit.sh(**kwargs)
73
69
 
74
70
  @classmethod
75
71
  def sh_kwargs(cls, cls_app, d_parms, *args) -> TyDic:
ka_uts_com/dec.py ADDED
@@ -0,0 +1,47 @@
1
+ """
2
+ Decorators Module
3
+ """
4
+ import os
5
+ import sys
6
+ import numpy as np
7
+ from datetime import datetime
8
+ from ka_uts_uts.utils.fnc import Fnc
9
+ from ka_uts_log.log import Log
10
+
11
+
12
+ def timer(fnc):
13
+ """
14
+ Timer Decorator
15
+ """
16
+ def __wrapper(*args, **kwargs):
17
+ start = datetime.now()
18
+ fnc(*args, **kwargs)
19
+ _fnc_name = Fnc.sh_fnc_name(fnc)
20
+ end = datetime.now()
21
+ elapse_time = end.timestamp() - start.timestamp()
22
+ np_elapse_time = np.format_float_positional(elapse_time, trim='k')
23
+ msg = f"{_fnc_name} elapse time [sec] = {np_elapse_time}"
24
+ Log.info(msg, stacklevel=2)
25
+ return __wrapper
26
+
27
+
28
+ def handle_exception(exc_type, exc_value, exc_traceback):
29
+ if issubclass(exc_type, KeyboardInterrupt):
30
+ sys.__excepthook__(exc_type, exc_value, exc_traceback)
31
+ return
32
+ Log.critical(exc_value.message, exc_info=(exc_type, exc_value, exc_traceback))
33
+
34
+
35
+ def handle_error(fnc):
36
+ """
37
+ Error Decorator
38
+ """
39
+ def __wrapper(*args, **kwargs):
40
+ try:
41
+ fnc(*args, **kwargs)
42
+ os._exit(0)
43
+ except Exception:
44
+ exc_type, exc_value, exc_traceback = sys.exc_info()
45
+ handle_exception(exc_type, exc_value, exc_traceback)
46
+ os._exit(1)
47
+ return __wrapper
@@ -1,9 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ka_uts_com
3
- Version: 4.0.0.250510
4
- Summary: Utilities for Communication and CLI Processing
5
- Author-email: Bernd Stroehle <bernd.stroehle@gmail.com>
6
- Maintainer-email: Bernd Stroehle <bernd.stroehle@gmail.com>
3
+ Version: 4.0.4.250522
4
+ Summary: Communication and CLI Utilities
5
+ Author: Bernd Stroehle
6
+ Author-email: bernd.stroehle@gmail.com
7
+ Maintainer: Bernd Stroehle
8
+ Maintainer-email: bernd.stroehle@gmail.com
9
+ License-Expression: GPL-3.0-only WITH Classpath-exception-2.0 OR BSD-3-Clause
7
10
  Project-URL: Source Code, https://github.com/bs29/ka_uts_com/tree/master
8
11
  Project-URL: Homepage, https://kosakya.de/
9
12
  Project-URL: Documentation, https://ka-com.readthedocs.io/en/latest
@@ -18,10 +21,10 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
21
  Requires-Python: >=3.10
19
22
  Description-Content-Type: text/x-rst
20
23
  License-File: LICENSE.txt
21
- Requires-Dist: ka_uts_arr>=4.0.0.250510
22
- Requires-Dist: ka_uts_log>=4.0.0.250510
23
- Requires-Dist: ka_uts_uts>=4.0.0.250510
24
- Requires-Dist: numpy>=2.2.5
24
+ Requires-Dist: ka_uts_arr>=4.0.2.250519
25
+ Requires-Dist: ka_uts_log>=4.0.6.250522
26
+ Requires-Dist: ka_uts_uts>=4.0.3.250519
27
+ Requires-Dist: numpy>=2.2.6
25
28
  Dynamic: license-file
26
29
 
27
30
  ##########
@@ -33,7 +36,7 @@ Overview
33
36
 
34
37
  .. start short_desc
35
38
 
36
- **Utilities for Communication and CLI Processing**
39
+ **Communication and CLI Utilities**
37
40
 
38
41
  .. end short_desc
39
42
 
@@ -75,15 +78,18 @@ The Package ``ka_uts_com`` consist of the following file types (c.f.: **Appendix
75
78
 
76
79
  #. **Dunder modules:** (c.f.: **Appendix:** *Special python package modules*)
77
80
 
78
- #. **Decorator modules**
81
+ #. **Modules**
79
82
 
80
- a. *dec.py*
83
+ #. **Decorator Modules**
81
84
 
82
- #. **Modules**
85
+ a. *dec.py*
83
86
 
84
87
  #. **Communication Modules**
85
88
 
86
89
  a. *com.py*
90
+
91
+ #. **Timer Modules**
92
+
87
93
  #. *timer.py*
88
94
 
89
95
  #. **Base Modules**
@@ -92,37 +98,55 @@ The Package ``ka_uts_com`` consist of the following file types (c.f.: **Appendix
92
98
  #. *cfg.py*
93
99
  #. *exit.py*
94
100
 
95
- Decorator Modules
96
- *****************
101
+ Decorator Module
102
+ ****************
97
103
 
98
104
  Overview
99
105
  ========
100
106
 
101
- .. Decorator Modules-label:
102
- .. table:: *Decorator Modules*
107
+ .. Decorator Module-label:
108
+ .. table:: *Decorator Module*
109
+
110
+ +------+----------------+
111
+ |Name |Decription |
112
+ +======+================+
113
+ |dec.py|Decorator module|
114
+ +------+----------------+
115
+
116
+ Decorstor module: dec.py
117
+ ========================
118
+
119
+ The Decorator Module ``dec.py`` contains the single decorator function ``timer``.
120
+
121
+ dec.py Method: timer
122
+ --------------------
123
+
124
+ Parameter
125
+ ^^^^^^^^^
126
+
127
+ ..dec.py-Method-timer-Parameter-label:
128
+ .. table:: *dec.py Method timer: Parameter*
103
129
 
104
- +------+-----------------+
105
- |Name |Decription |
106
- +======+=================+
107
- |dec.py|Decorators module|
108
- +------+-----------------+
130
+ +----+----------+-----------+
131
+ |Name|Type |Description|
132
+ +====+==========+===========+
133
+ |fnc |TyCallable|function |
134
+ +----+----------+-----------+
109
135
 
110
- Communication Modules
111
- *********************
136
+ Communication Module
137
+ ********************
112
138
 
113
139
  Overview
114
140
  ========
115
141
 
116
- .. Communication Modules-label:
117
- .. table:: *Communication Modules*
142
+ .. Communication Module-label:
143
+ .. table:: *Communication Module*
118
144
 
119
- +--------+-----------------------------+
120
- |Name |Decription |
121
- +========+=============================+
122
- |com.py |Communication handling module|
123
- +--------+-----------------------------+
124
- |timer.py|Timer management module |
125
- +--------+-----------------------------+
145
+ +------+-----------------------------+
146
+ |Name |Decription |
147
+ +======+=============================+
148
+ |com.py|Communication handling module|
149
+ +------+-----------------------------+
126
150
 
127
151
  Communication module: com.py
128
152
  ============================
@@ -143,33 +167,31 @@ Com: Variables
143
167
  +------------+-----------+-------+---------------------------------------+
144
168
  |Name |Type |Default|Description |
145
169
  +============+===========+=======+=======================================+
146
- |sw_init |TyBool |None |Initialisation switch |
170
+ |cmd |TyStr |None |Command |
147
171
  +------------+-----------+-------+---------------------------------------+
148
172
  |d_com_pacmod|TyDic |{} |Communication package module dictionary|
149
173
  +------------+-----------+-------+---------------------------------------+
150
174
  |d_app_pacmod|TyDic |{} |Application package module dictionary |
151
175
  +------------+-----------+-------+---------------------------------------+
152
- |**Timestamp fields** |
153
- +------------+-----------+-------+---------------------------------------+
154
- |ts |TnTimeStamp|None |Timestamp |
176
+ |sw_init |TyBool |None |Initialisation switch |
155
177
  +------------+-----------+-------+---------------------------------------+
156
- |ts_start |TnDateTime |None |start timestamp in date time format |
178
+ |tenant |TyStr |None |Tenant name |
157
179
  +------------+-----------+-------+---------------------------------------+
158
- |ts_end |TnDateTime |None |end timestamp in date time format |
180
+ |**Timestamp fields** |
159
181
  +------------+-----------+-------+---------------------------------------+
160
- |ts_etime |TnDateTime |None |elapse Time |
182
+ |ts |TnTimeStamp|None |Timestamp |
161
183
  +------------+-----------+-------+---------------------------------------+
162
184
  |d_timer |TyDic |False |Timer dictionary |
163
185
  +------------+-----------+-------+---------------------------------------+
164
186
  |**Links to other Classes** |
165
187
  +------------+-----------+-------+---------------------------------------+
166
- |App |TyAny |False |Application class |
188
+ |App |TyAny |None |Application class |
167
189
  +------------+-----------+-------+---------------------------------------+
168
190
  |cfg |TyDic |None |Configuration dictionary |
169
191
  +------------+-----------+-------+---------------------------------------+
170
- |Log |TyLogger |False |Log class |
192
+ |Log |TyLogger |None |Log class |
171
193
  +------------+-----------+-------+---------------------------------------+
172
- |Exit |TyAny |False |Exit class |
194
+ |Exit |TyAny |None |Exit class |
173
195
  +------------+-----------+-------+---------------------------------------+
174
196
 
175
197
  Com: Methods
@@ -224,8 +246,23 @@ Parameter
224
246
  |\*args |list |arguments array |
225
247
  +--------+-----+--------------------+
226
248
 
227
- Communication module: timer.py
228
- ==============================
249
+ Timer Module
250
+ ************
251
+
252
+ Overview
253
+ ========
254
+
255
+ .. Timer Modules-label:
256
+ .. table:: *Timer Modules*
257
+
258
+ +--------+-----------------------------+
259
+ |Name |Decription |
260
+ +========+=============================+
261
+ |timer.py|Timer management module |
262
+ +--------+-----------------------------+
263
+
264
+ Timer module: timer.py
265
+ ======================
229
266
 
230
267
  timer.py: Classes
231
268
  -----------------
@@ -369,7 +406,7 @@ Overview
369
406
  Base module: app\_.py
370
407
  =====================
371
408
 
372
- The Module ``app.py`` contains a single static class ``App_``.
409
+ The Module ``app\_.py`` contains a single static class ``App_``.
373
410
 
374
411
  Class: App\_
375
412
  ------------
@@ -0,0 +1,11 @@
1
+ ka_uts_com/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ ka_uts_com/__version__.py,sha256=dA4tv1GGQrBxxQUCbrAy6C-PZyqPqTs10nl7kenTYzA,420
3
+ ka_uts_com/com.py,sha256=zTyWPFuxopUEfrhwn9736hzln6NDas0J3YuCV6YA64c,1816
4
+ ka_uts_com/dec.py,sha256=JCKNNVPISJtXJfScX3rFcS9CjD0Ck2IUyK_53Gbov8Q,1276
5
+ ka_uts_com/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ ka_uts_com/timer.py,sha256=qVKanfNBnsU3B6C-Y5mjHWnS056GiYlRmFwEnX6BAU0,2546
7
+ ka_uts_com-4.0.4.250522.dist-info/licenses/LICENSE.txt,sha256=BiT3QGI_2iRbdvgS3HDig57lnXJVk60Pj4xM9eeCczI,814
8
+ ka_uts_com-4.0.4.250522.dist-info/METADATA,sha256=CnWw7YIGzK9Y54kq7pGCLhtTJzjNoteA53U_p07BXLo,32599
9
+ ka_uts_com-4.0.4.250522.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
10
+ ka_uts_com-4.0.4.250522.dist-info/top_level.txt,sha256=cWCIrm1g6Jn-FbCQuB3wBrrNH1YwqVlc6mE0jV6vg74,21
11
+ ka_uts_com-4.0.4.250522.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.4.0)
2
+ Generator: setuptools (80.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
ka_uts_com/app.py DELETED
@@ -1,48 +0,0 @@
1
- # coding=utf-8
2
- from typing import Any
3
-
4
- from ka_uts_log.log import Log
5
- from ka_uts_uts.utils.pacmod import PacMod
6
- from ka_uts_uts.ioc.yaml_ import Yaml_
7
-
8
- TyAny = Any
9
- TyArr = list[Any]
10
- TyBool = bool
11
- TyDic = dict[Any, Any]
12
-
13
- TnAny = None | Any
14
- TnArr = None | TyArr
15
- TnBool = None | bool
16
- TnDic = None | TyDic
17
-
18
-
19
- class App:
20
- """Aplication Class
21
- """
22
- sw_init: TyBool = False
23
- sw_replace_keys: TnBool = None
24
- keys: TnArr = None
25
- httpmod: TyAny = None
26
- reqs: TyDic = {}
27
- app: TyDic = {}
28
-
29
- @classmethod
30
- def init(cls, cls_com, **kwargs) -> None:
31
- if cls.sw_init:
32
- return
33
- cls.sw_init = True
34
- cls.httpmod = kwargs.get('httpmod')
35
- cls.sw_replace_keys = kwargs.get('sw_replace_keys', False)
36
- if cls.sw_replace_keys:
37
- try:
38
- cls.keys = Yaml_.read_with_safeloader(PacMod.sh_path_keys_yml(cls_com))
39
- except Exception as exc:
40
- Log.error(exc, exc_info=True)
41
- raise
42
-
43
- @classmethod
44
- def sh(cls, cls_com, **kwargs) -> Any:
45
- if cls.sw_init:
46
- return cls
47
- cls.init(cls_com, **kwargs)
48
- return cls
ka_uts_com/cfg.py DELETED
@@ -1,35 +0,0 @@
1
- # coding=utf-8
2
- from typing import Any
3
-
4
- from ka_uts_uts.ioc.yaml_ import Yaml_
5
- from ka_uts_uts.utils.pacmod import PacMod
6
-
7
- TyAny = Any
8
- TyTimeStamp = int
9
- TyArr = list[Any]
10
- TyBool = bool
11
- TyDic = dict[Any, Any]
12
-
13
-
14
- class Cfg:
15
- """Configuration Class
16
- """
17
- sw_init: TyBool = False
18
- cfg: Any = None
19
-
20
- @classmethod
21
- def init(cls, cls_com, **kwargs) -> None:
22
- if cls.sw_init:
23
- return
24
- cls.sw_init = True
25
- _cls_app = kwargs.get('cls_app')
26
- _path = PacMod.sh_path_cfg_yml(_cls_app)
27
- if _path:
28
- cls.cfg = Yaml_.read_with_safeloader(_path)
29
-
30
- @classmethod
31
- def sh(cls, cls_com, **kwargs) -> Any:
32
- if cls.sw_init:
33
- return cls
34
- cls.init(cls_com, **kwargs)
35
- return cls.cfg
@@ -1,26 +0,0 @@
1
- """
2
- Decorators
3
- """
4
- # coding=utf-8
5
- # from ka_uts_com.timer import Timer
6
- import numpy as np
7
- from datetime import datetime
8
- from ka_uts_uts.utils.fnc import Fnc
9
- from ka_uts_log.log import Log
10
-
11
-
12
- def timer(fnc):
13
- def wrapper(*args, **kwargs):
14
- # Timer.start(fnc, *args, **kwargs)
15
- start = datetime.now()
16
- fnc(*args, **kwargs)
17
- _fnc_name = Fnc.sh_fnc_name(fnc)
18
- end = datetime.now()
19
- # elapse_time = (end - start).total_seconds()
20
- elapse_time = end.timestamp() - start.timestamp()
21
- # np_elapse_time = np.format_float_positional(elapse_time, trim='-')
22
- np_elapse_time = np.format_float_positional(elapse_time, trim='k')
23
- msg = f"{_fnc_name} elapse time [sec] = {np_elapse_time}"
24
- Log.info(msg, stacklevel=2)
25
- # Timer.end(fnc, *args, **kwargs)
26
- return wrapper
ka_uts_com/exit.py DELETED
@@ -1,37 +0,0 @@
1
- # coding=utf-8
2
- from typing import Any
3
-
4
- TyAny = Any
5
- TyArr = list[Any]
6
- TyBool = bool
7
- TyDic = dict[Any, Any]
8
-
9
- TnAny = None | Any
10
- TnArr = None | TyArr
11
- TnBool = None | bool
12
- TnDic = None | TyDic
13
-
14
-
15
- class Exit:
16
- """Exit Class
17
- """
18
- sw_init: TyBool = False
19
- sw_critical: bool = False
20
- sw_stop: bool = False
21
- sw_interactive: bool = False
22
-
23
- @classmethod
24
- def init(cls, **kwargs) -> None:
25
- if cls.sw_init:
26
- return
27
- cls.sw_init = True
28
- cls.sw_critical = kwargs.get('sw_critical', False)
29
- cls.sw_stop = kwargs.get('sw_stop', False)
30
- cls.sw_interactive = kwargs.get('sw_interactive', False)
31
-
32
- @classmethod
33
- def sh(cls, **kwargs) -> Any:
34
- if cls.sw_init:
35
- return cls
36
- cls.init(**kwargs)
37
- return cls
@@ -1,14 +0,0 @@
1
- ka_uts_com/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- ka_uts_com/__version__.py,sha256=cDeKJoJXH0P7QinCjk6rgnqE1iSbzwkcXPtGuFPor-g,365
3
- ka_uts_com/app.py,sha256=XrMhqQI9YHzw1XmC8zGgCJwrwxzkHtHDEQIo9gP07DI,1151
4
- ka_uts_com/cfg.py,sha256=RNWxOz3XtP0HgH0z1e6tAQA_L0alEh82_EOPOoyv3R4,768
5
- ka_uts_com/com.py,sha256=DdL9754luzZqmHq_r6YKG4gxSSsxOGoVMohF5jaJZ8Q,1943
6
- ka_uts_com/exit.py,sha256=RIpFKwEGeBCBBPPQXIcLsrYeNY2dTF8BDlESe6UhdMo,791
7
- ka_uts_com/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- ka_uts_com/timer.py,sha256=qVKanfNBnsU3B6C-Y5mjHWnS056GiYlRmFwEnX6BAU0,2546
9
- ka_uts_com/decorators/dec.py,sha256=8oKf3yvJSEakjr0HuQKcc3F0qgRmDskxr6hnQaw4r_I,841
10
- ka_uts_com-4.0.0.250510.dist-info/licenses/LICENSE.txt,sha256=BiT3QGI_2iRbdvgS3HDig57lnXJVk60Pj4xM9eeCczI,814
11
- ka_uts_com-4.0.0.250510.dist-info/METADATA,sha256=Z8KlB7LZ_ali-3r6BaJtudD4nKansscm0MISiGBl4k8,32001
12
- ka_uts_com-4.0.0.250510.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
13
- ka_uts_com-4.0.0.250510.dist-info/top_level.txt,sha256=cWCIrm1g6Jn-FbCQuB3wBrrNH1YwqVlc6mE0jV6vg74,21
14
- ka_uts_com-4.0.0.250510.dist-info/RECORD,,