ka-uts-com 2.1.0.250408__py3-none-any.whl → 2.2.0.250427__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.
Files changed (54) hide show
  1. ka_uts_com/__version__.py +2 -2
  2. build/lib/ka_uts_com/base/app_.py → ka_uts_com/app.py +9 -11
  3. ka_uts_com/{base/cfg_.py → cfg.py} +7 -10
  4. ka_uts_com/com.py +47 -39
  5. build/lib/ka_uts_com/base/exit_.py → ka_uts_com/exit.py +1 -1
  6. ka_uts_com/timer.py +1 -1
  7. ka_uts_com-2.2.0.250427.dist-info/METADATA +929 -0
  8. ka_uts_com-2.2.0.250427.dist-info/RECORD +14 -0
  9. {ka_uts_com-2.1.0.250408.dist-info → ka_uts_com-2.2.0.250427.dist-info}/WHEEL +1 -1
  10. {ka_uts_com-2.1.0.250408.dist-info → ka_uts_com-2.2.0.250427.dist-info}/top_level.txt +0 -1
  11. build/lib/dist/ka_uts_com-2.0.0.250407-py3-none-any.whl +0 -0
  12. build/lib/dist/ka_uts_com-2.0.0.250407.tar.gz +0 -0
  13. build/lib/ka_uts_com/__init__.py +0 -0
  14. build/lib/ka_uts_com/__version__.py +0 -10
  15. build/lib/ka_uts_com/base/cfg_.py +0 -36
  16. build/lib/ka_uts_com/base/log_.py +0 -131
  17. build/lib/ka_uts_com/com.py +0 -115
  18. build/lib/ka_uts_com/data/__init__.py +0 -0
  19. build/lib/ka_uts_com/data/log.std.yml +0 -107
  20. build/lib/ka_uts_com/data/log.usr.yml +0 -106
  21. build/lib/ka_uts_com/decorators/dec.py +0 -13
  22. build/lib/ka_uts_com/fnc.py +0 -42
  23. build/lib/ka_uts_com/ioc/jinja2_.py +0 -42
  24. build/lib/ka_uts_com/ioc/yaml_.py +0 -31
  25. build/lib/ka_uts_com/log.py +0 -86
  26. build/lib/ka_uts_com/py.typed +0 -0
  27. build/lib/ka_uts_com/timer.py +0 -69
  28. build/lib/ka_uts_com/utils/aoeqstmt.py +0 -37
  29. build/lib/ka_uts_com/utils/date.py +0 -15
  30. build/lib/ka_uts_com/utils/doeq.py +0 -99
  31. build/lib/ka_uts_com/utils/pac.py +0 -35
  32. build/lib/ka_uts_com/utils/pacmod.py +0 -109
  33. build/lib/ka_uts_com/utils/str.py +0 -265
  34. dist/ka_uts_com-2.0.0.250407-py3-none-any.whl +0 -0
  35. dist/ka_uts_com-2.0.0.250407.tar.gz +0 -0
  36. ka_uts_com/base/app_.py +0 -50
  37. ka_uts_com/base/exit_.py +0 -37
  38. ka_uts_com/base/log_.py +0 -131
  39. ka_uts_com/data/__init__.py +0 -0
  40. ka_uts_com/data/log.std.yml +0 -107
  41. ka_uts_com/data/log.usr.yml +0 -106
  42. ka_uts_com/fnc.py +0 -42
  43. ka_uts_com/ioc/jinja2_.py +0 -42
  44. ka_uts_com/ioc/yaml_.py +0 -31
  45. ka_uts_com/log.py +0 -86
  46. ka_uts_com/utils/aoeqstmt.py +0 -37
  47. ka_uts_com/utils/date.py +0 -15
  48. ka_uts_com/utils/doeq.py +0 -99
  49. ka_uts_com/utils/pac.py +0 -35
  50. ka_uts_com/utils/pacmod.py +0 -109
  51. ka_uts_com/utils/str.py +0 -265
  52. ka_uts_com-2.1.0.250408.dist-info/METADATA +0 -1611
  53. ka_uts_com-2.1.0.250408.dist-info/RECORD +0 -55
  54. {ka_uts_com-2.1.0.250408.dist-info → ka_uts_com-2.2.0.250427.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,86 +0,0 @@
1
- from ka_uts_com.com import Com
2
- from typing import Any
3
- TyDic = dict[Any, Any]
4
-
5
-
6
- class Log:
7
- """Logging Class
8
- """
9
- class Eq:
10
-
11
- @classmethod
12
- def error(cls, key: Any, value: Any) -> None:
13
- Log.error(f"{key} = {value}", stacklevel=3)
14
-
15
- @classmethod
16
- def warning(cls, key: Any, value: Any) -> None:
17
- Log.warning(f"{key} = {value}", stacklevel=3)
18
-
19
- @classmethod
20
- def info(cls, key: Any, value: Any) -> None:
21
- Log.info(f"{key} = {value}", stacklevel=3)
22
-
23
- @classmethod
24
- def log(cls, key: Any, value: Any) -> None:
25
- Log.log(f"{key} = {value}", stacklevel=3)
26
-
27
- @classmethod
28
- def debug(cls, key: Any, value: Any) -> None:
29
- Log.debug(f"{key} = {value}", stacklevel=3)
30
-
31
- class Dic:
32
-
33
- @classmethod
34
- def debug(cls, dic: TyDic) -> None:
35
- for key, value in dic.items():
36
- Log.debug(f"{key} = {value}", stacklevel=3)
37
-
38
- @classmethod
39
- def error(cls, dic: TyDic) -> None:
40
- for key, value in dic.items():
41
- Log.error(f"{key} = {value}", stacklevel=3)
42
-
43
- @classmethod
44
- def info(cls, dic: TyDic) -> None:
45
- for key, value in dic.items():
46
- Log.info(f"{key} = {value}", stacklevel=3)
47
-
48
- @classmethod
49
- def warning(cls, dic: TyDic) -> None:
50
- for key, value in dic.items():
51
- Log.warning(f"{key} = {value}", stacklevel=3)
52
-
53
- @staticmethod
54
- def error(*args, **kwargs) -> None:
55
- if kwargs is None:
56
- kwargs = {}
57
- kwargs['stacklevel'] = kwargs.get('stacklevel', 2)
58
- Com.Log.error(*args, **kwargs)
59
-
60
- @staticmethod
61
- def warning(*args, **kwargs) -> None:
62
- if kwargs is None:
63
- kwargs = {}
64
- kwargs['stacklevel'] = kwargs.get('stacklevel', 2)
65
- Com.Log.warning(*args, **kwargs)
66
-
67
- @staticmethod
68
- def info(*args, **kwargs) -> None:
69
- if kwargs is None:
70
- kwargs = {}
71
- kwargs['stacklevel'] = kwargs.get('stacklevel', 2)
72
- Com.Log.info(*args, **kwargs)
73
-
74
- @staticmethod
75
- def log(*args, **kwargs) -> None:
76
- if kwargs is None:
77
- kwargs = {}
78
- kwargs['stacklevel'] = kwargs.get('stacklevel', 2)
79
- Com.Log.log(*args, **kwargs)
80
-
81
- @staticmethod
82
- def debug(*args, **kwargs) -> None:
83
- if kwargs is None:
84
- kwargs = {}
85
- kwargs['stacklevel'] = kwargs.get('stacklevel', 2)
86
- Com.Log.debug(*args, **kwargs)
File without changes
@@ -1,69 +0,0 @@
1
- # coding=utf-8
2
- from datetime import datetime
3
-
4
- from ka_uts_com.com import Com
5
- from ka_uts_com.log import Log
6
-
7
- from typing import Any
8
- TyAny = Any
9
- TyArr = list[Any]
10
- TyDic = dict[Any, Any]
11
- TyStr = str
12
- TnAny = None | TyAny
13
- TnStr = None | TyStr
14
-
15
-
16
- class Timestamp:
17
-
18
- @staticmethod
19
- def sh_elapse_time_sec(end: Any, start: TnAny) -> TnAny:
20
- if start is None:
21
- return None
22
- return end.timestamp()-start.timestamp()
23
-
24
-
25
- class Timer:
26
- """ Timer Management
27
- """
28
- @staticmethod
29
- def sh_task_id(d_pacmod: TyDic, class_id: TyAny, parms: TnAny, sep: TyStr) -> TyStr:
30
- """
31
- Show task id, which is created by the concationation of the following items:
32
- package, module, class_name and parms if they are defined; the items package
33
- and module are get from the package-module directory; the item class_name is
34
- the class_id if its a string, otherwise the attribute __qualname__ is used.
35
- """
36
- package = d_pacmod.get('package')
37
- module = d_pacmod.get('module')
38
- if isinstance(class_id, str):
39
- class_name = class_id
40
- else:
41
- class_name = class_id.__qualname__
42
- if not parms:
43
- parms = ""
44
- else:
45
- parms = f" {parms}"
46
- arr: TyArr = []
47
- for item in [package, module, class_name, parms]:
48
- if not item:
49
- continue
50
- arr.append(item)
51
- return sep.join(arr)
52
-
53
- @classmethod
54
- def start(cls, class_id: TyAny, parms: TnAny = None, sep: TyStr = ".") -> None:
55
- """ Start Timer
56
- """
57
- task_id = cls.sh_task_id(Com.d_app_pacmod, class_id, parms, sep)
58
- Com.d_timer[task_id] = datetime.now()
59
-
60
- @classmethod
61
- def end(cls, class_id: TyAny, parms: TnAny = None, sep: TyStr = ".") -> None:
62
- """ End Timer
63
- """
64
- task_id = cls.sh_task_id(Com.d_app_pacmod, class_id, parms, sep)
65
- start = Com.d_timer.get(task_id)
66
- end = datetime.now()
67
- elapse_time_sec = Timestamp.sh_elapse_time_sec(end, start)
68
- msg = f"{task_id} elapse time [sec] = {elapse_time_sec}"
69
- Log.info(msg, stacklevel=2)
@@ -1,37 +0,0 @@
1
- # coding=utf-8
2
- from ka_uts_com.utils.doeq import DoEq
3
-
4
- from typing import Any
5
- TyArr = list[Any]
6
- TyDic = dict[Any, Any]
7
-
8
- TnArr = None | TyArr
9
- TnDic = None | TyDic
10
- TnStr = None | str
11
-
12
-
13
- class AoEqStmt:
14
- """ Dictionary of Equates
15
- """
16
- @staticmethod
17
- def init_d_eq(a_eqstmt: TyArr) -> TyDic:
18
- d_eq = {}
19
- for s_eq in a_eqstmt[1:]:
20
- a_eq = s_eq.split('=')
21
- if len(a_eq) == 1:
22
- d_eq['cmd'] = a_eq[0]
23
- else:
24
- d_eq[a_eq[0]] = a_eq[1]
25
- d_eq[a_eq[0]] = a_eq[1]
26
- return d_eq
27
-
28
- @classmethod
29
- def sh_d_eq(cls, a_eqstmt: TyArr, **kwargs) -> TyDic:
30
- """ show equates dictionary
31
- """
32
- d_parms: TnDic = kwargs.get('d_parms')
33
- _sh_prof = kwargs.get('sh_prof')
34
- d_eq: TyDic = cls.init_d_eq(a_eqstmt)
35
- d_eq_new: TyDic = DoEq.verify(d_eq, d_parms)
36
- DoEq._set_sh_prof(d_eq_new, _sh_prof)
37
- return d_eq_new
@@ -1,15 +0,0 @@
1
- from datetime import datetime
2
- from datetime import date
3
-
4
- TyDate = date
5
- TnDate = None | TyDate
6
- TnStr = None | str
7
-
8
-
9
- class Date:
10
-
11
- @staticmethod
12
- def sh(datestring: TnStr, fmt: str) -> TnDate:
13
- if not datestring:
14
- return None
15
- return datetime.strptime(datestring, fmt).date()
@@ -1,99 +0,0 @@
1
- # coding=utf-8
2
- from collections.abc import Callable
3
- from typing import Any
4
-
5
- # from ka_uts_com.utils.pacmod import PacMod
6
- from ka_uts_com.utils.str import Str
7
- from ka_uts_com.utils.date import Date
8
-
9
-
10
- TyArr = list[Any]
11
- TyCall = Callable[..., Any]
12
- TyDic = dict[Any, Any]
13
- TyStr = str
14
-
15
- TnArr = None | TyArr
16
- TnDic = None | TyDic
17
- TnStr = None | TyStr
18
-
19
-
20
- class DoEq:
21
- """ Manage Commandline Arguments
22
- """
23
- @classmethod
24
- def sh_value(cls, key: str, value: Any, d_valid_parms: TnDic) -> Any:
25
-
26
- # print(f"key = {key}, type(key) = {type(key)}")
27
- # print(f"value = {value}, type(value) = {type(value)}")
28
- if not d_valid_parms:
29
- return value
30
- _type: TnStr = d_valid_parms.get(key)
31
- # print(f"_type = {_type}")
32
- if not _type:
33
- return value
34
- if isinstance(_type, str):
35
- match _type:
36
- case 'int':
37
- value = int(value)
38
- case 'bool':
39
- value = Str.sh_boolean(value)
40
- case 'dict':
41
- value = Str.sh_dic(value)
42
- case 'list':
43
- value = Str.sh_arr(value)
44
- case '%Y-%m-%d':
45
- value = Date.sh(value, _type)
46
- case '_':
47
- match _type[0]:
48
- case '[', '{':
49
- _obj = Str.sh_dic(_type)
50
- if value not in _obj:
51
- msg = (f"parameter={key} value={value} is invalid; "
52
- f"valid values are={_obj}")
53
- raise Exception(msg)
54
-
55
- # print(f"value = {value}, type(value) = {type(value)}")
56
- return value
57
-
58
- # @staticmethod
59
- # def _set_d_pacmod(d_eq: TyDic, root_cls) -> None:
60
- # """ set current pacmod dictionary
61
- # """
62
- # tenant = d_eq.get('tenant')
63
- # d_eq['d_pacmod'] = PacMod.sh_d_pacmod(root_cls, tenant)
64
-
65
- @staticmethod
66
- def _set_sh_prof(d_eq: TyDic, sh_prof: TyCall | Any) -> None:
67
- """ set current pacmod dictionary
68
- """
69
- if callable(sh_prof):
70
- d_eq['sh_prof'] = sh_prof()
71
- else:
72
- d_eq['sh_prof'] = sh_prof
73
-
74
- @classmethod
75
- def verify(cls, d_eq: TyDic, d_parms: TnDic) -> TyDic:
76
- if d_parms is None:
77
- return d_eq
78
- if 'cmd' in d_eq:
79
- _d_valid_parms = d_parms
80
- _cmd = d_eq['cmd']
81
- _valid_commands = list(d_parms.keys())
82
- if _cmd not in _valid_commands:
83
- msg = (f"Wrong command: {_cmd}; "
84
- f"valid commands are: {_valid_commands}")
85
- raise Exception(msg)
86
- _d_valid_parms = d_parms[_cmd]
87
- else:
88
- _d_valid_parms = d_parms
89
- if _d_valid_parms is None:
90
- return d_eq
91
-
92
- d_eq_new = {}
93
- for key, value in d_eq.items():
94
- if key not in _d_valid_parms:
95
- msg = (f"Wrong parameter: {key}; "
96
- f"valid parameters are: {_d_valid_parms}")
97
- raise Exception(msg)
98
- d_eq_new[key] = cls.sh_value(key, value, _d_valid_parms)
99
- return d_eq_new
@@ -1,35 +0,0 @@
1
- # coding=utf-8
2
- from typing import Any
3
-
4
- import os
5
- import importlib.resources as resources
6
-
7
- TyArr = list[Any]
8
- TyDic = dict[Any, Any]
9
- TyPackage = str
10
- TyPackages = list[str]
11
- TyPath = str
12
-
13
-
14
- class Pac:
15
-
16
- @staticmethod
17
- def sh_path_by_package(package: TyPackage, path: TyPath) -> Any:
18
- """ show directory
19
- """
20
- _path = str(resources.files(package).joinpath(path))
21
- # if _path.is_file():
22
- if _path is not None and _path != '':
23
- if os.path.exists(_path):
24
- return _path
25
- return ''
26
-
27
- @classmethod
28
- def sh_path_by_packages(cls, packages: TyPackages, path: TyPath) -> Any:
29
- """ show directory
30
- """
31
- for _package in packages:
32
- _path = cls.sh_path_by_package(_package, path)
33
- if _path:
34
- return _path
35
- return ''
@@ -1,109 +0,0 @@
1
- # coding=utf-8
2
- from typing import Any
3
-
4
- from os import path as os_path
5
-
6
- from ka_uts_com.utils.pac import Pac
7
-
8
- TyArr = list[Any]
9
- TyDic = dict[Any, Any]
10
- TyPath = str
11
-
12
-
13
- class PacMod:
14
- """ Package Module Management
15
- """
16
- @staticmethod
17
- def sh_d_pacmod(cls) -> TyDic:
18
- """ Show Pacmod Dictionary
19
- """
20
- a_pacmod: TyArr = cls.__module__.split(".")
21
- return {'package': a_pacmod[0], 'module': a_pacmod[1]}
22
-
23
- @staticmethod
24
- def sh_path_module_yaml(d_pacmod: TyDic) -> Any:
25
- """ show directory
26
- """
27
- package = d_pacmod['package']
28
- module = d_pacmod['module']
29
- path = f"{module}/data/{module}.yml"
30
- return Pac.sh_path_by_package(package, path)
31
-
32
- @staticmethod
33
- def sh_path_keys(d_pacmod: TyDic) -> Any:
34
- """ show directory
35
- """
36
- package = d_pacmod['package']
37
- path = 'data/keys.yml'
38
- return Pac.sh_path_by_package(package, path)
39
-
40
- # @staticmethod
41
- # def sh_path_log_cfg(com) -> TyPath:
42
- # """ show directory
43
- # """
44
- # package = com.d_app_pacmod['package']
45
- # path = resources.files(package).joinpath(f"data/log.{com.log_type}.yml")
46
- # if path.is_file():
47
- # return path
48
- # package = com.d_com_pacmod['package']
49
- # path = resources.files(package).joinpath(f"data/log.{com.log_type}.yml")
50
- # if path.is_file():
51
- # return path
52
- # raise ModuleNotFoundError
53
-
54
- # @staticmethod
55
- # def sh_path_cfg(d_pacmod: TyDic) -> Any:
56
- # """ show directory
57
- # """
58
- # package = com.d_app_pacmod['package']
59
- # path = 'dat/cfg.yml'
60
- # return Pac.sh_path(package, path)
61
-
62
- # @staticmethod
63
- # def sh_path_type(d_pacmod: TyDic, type_: str) -> str:
64
- # """ show Data File Path
65
- # """
66
- # # def sh_pacmod_type(d_pacmod: TyDic, type_: str) -> str:
67
- # package = d_pacmod['package']
68
- # module = d_pacmod['module']
69
- # return f"/data/{package}/{module}/{type_}"
70
-
71
- # @classmethod
72
- # def sh_file_path(
73
- # cls, d_pacmod: TyDic, type_: str, suffix: str,
74
- # pid: Any, ts: Any, **kwargs) -> str:
75
- # """ show type specific path
76
- # """
77
- # filename_ = kwargs.get('filename', type_)
78
- # sw_run_pid_ts = kwargs.get('sw_run_pid_ts', True)
79
- # if sw_run_pid_ts is None:
80
- # sw_run_pid_ts = True
81
- #
82
- # _dir: str = cls.sh_pacmod_type(d_pacmod, type_)
83
- # if sw_run_pid_ts:
84
- # file_path = os_path.join(
85
- # _dir, f"{filename_}_{pid}_{ts}.{suffix}")
86
- # else:
87
- # file_path = os_path.join(_dir, f"{filename_}.{suffix}")
88
- # return file_path
89
-
90
- @staticmethod
91
- def sh_dir_type(com, type_: str) -> TyPath:
92
- """Show run_dir
93
- """
94
- dir_dat: str = com.dir_dat
95
- tenant: str = com.tenant
96
- package: str = com.d_app_pacmod['package']
97
- module: str = com.d_app_pacmod['module']
98
- if not tenant:
99
- return f"{dir_dat}/{tenant}/{package}/{module}/{type_}"
100
- else:
101
- return f"{dir_dat}/{package}/{module}/{type_}"
102
-
103
- @classmethod
104
- def sh_path_pattern(
105
- cls, com, filename, type_: str, suffix: str) -> TyPath:
106
- """ show type specific path
107
- """
108
- _dir: str = cls.sh_dir_type(com, type_)
109
- return os_path.join(_dir, f"{filename}*.{suffix}")