kkpyutil 1.42.0__py3-none-any.whl → 1.44.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kkpyutil
3
- Version: 1.42.0
3
+ Version: 1.44.0
4
4
  Summary: Building blocks for sysadmin and DevOps
5
5
  Home-page: https://github.com/kakyoism/kkpyutil/
6
6
  License: MIT
@@ -0,0 +1,7 @@
1
+ kkpyutil.py,sha256=x2gL37fKHY0Eu2wmXEGX9d-5Dj_pBsTz9yax2K_6Qv0,113568
2
+ kkpyutil_helper/windows/kkttssave.ps1,sha256=xa3-WzqNh2rGYlOx_I4ewOuCE94gkTO5cEwYH0M67_0,446
3
+ kkpyutil_helper/windows/kkttsspeak.ps1,sha256=7WUUHMmjTQroUWA2Mvdt4JtSt475nZUHQx-qP-7rS6o,305
4
+ kkpyutil-1.44.0.dist-info/LICENSE,sha256=uISevGnCxB5QOU0ftbofN75_yUtd6E2h_MWE1zqagC8,1065
5
+ kkpyutil-1.44.0.dist-info/METADATA,sha256=_TbaSGmm2EeUCTTpAbqTDGdaoVBi522q2Kn60kgnB3I,1136
6
+ kkpyutil-1.44.0.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
7
+ kkpyutil-1.44.0.dist-info/RECORD,,
kkpyutil.py CHANGED
@@ -74,18 +74,6 @@ if PLATFORM == 'Windows':
74
74
 
75
75
  # region classes
76
76
 
77
- # class ClassicSingleton:
78
- # _instances = {}
79
- #
80
- # def __new__(cls, *args, **kwargs):
81
- # if cls not in cls._instances:
82
- # print(f"Creating new instance for {cls}")
83
- # cls._instances[cls] = super(ClassicSingleton, cls).__new__(cls, *args, **kwargs)
84
- # else:
85
- # print(f"Reusing instance for {cls}")
86
- # return cls._instances[cls]
87
-
88
-
89
77
  class ClassicSingleton:
90
78
  _instances = {}
91
79
 
@@ -105,6 +93,18 @@ class ClassicSingleton:
105
93
  raise RuntimeError("Use `cls.instance()` to access the singleton instance.")
106
94
 
107
95
 
96
+ class MetaSingleton(type):
97
+ """
98
+ - usage: class MyClass(metaclass=MetaSingleton)
99
+ """
100
+ _instances = {}
101
+
102
+ def __call__(cls, *args, **kwargs):
103
+ if cls not in cls._instances:
104
+ cls._instances[cls] = super(MetaSingleton, cls).__call__(*args, **kwargs)
105
+ return cls._instances[cls]
106
+
107
+
108
108
  class BorgSingleton:
109
109
  """
110
110
  - Borg pattern: all instances share the same state, but not the same identity
@@ -136,6 +136,24 @@ class SingletonDecorator:
136
136
  return self.instance
137
137
 
138
138
 
139
+ class ExceptableThread(threading.Thread):
140
+ def __init__(self, *args, **kwargs):
141
+ super().__init__(*args, **kwargs)
142
+ self.exception = None
143
+
144
+ def run(self):
145
+ try:
146
+ if self._target:
147
+ self._target(*self._args, **self._kwargs)
148
+ except Exception as e:
149
+ self.exception = e
150
+
151
+ def join(self, *args, **kwargs):
152
+ super().join(*args, **kwargs)
153
+ if self.exception:
154
+ raise self.exception
155
+
156
+
139
157
  class LowPassLogFilter(object):
140
158
  """
141
159
  Logging filter: Show log messages below input level.
@@ -1,7 +0,0 @@
1
- kkpyutil.py,sha256=W9idh6_OvxtfOMfLWKxj6iDIFHNilsBX03Zcm-A99ps,113164
2
- kkpyutil_helper/windows/kkttssave.ps1,sha256=xa3-WzqNh2rGYlOx_I4ewOuCE94gkTO5cEwYH0M67_0,446
3
- kkpyutil_helper/windows/kkttsspeak.ps1,sha256=7WUUHMmjTQroUWA2Mvdt4JtSt475nZUHQx-qP-7rS6o,305
4
- kkpyutil-1.42.0.dist-info/LICENSE,sha256=uISevGnCxB5QOU0ftbofN75_yUtd6E2h_MWE1zqagC8,1065
5
- kkpyutil-1.42.0.dist-info/METADATA,sha256=0ZKxCttVdGWjb4NrbZSPNFp0kjNfpIS9SxE-CUyTKp0,1136
6
- kkpyutil-1.42.0.dist-info/WHEEL,sha256=kLuE8m1WYU0Ig0_YEGrXyTtiJvKPpLpDEiChiNyei5Y,88
7
- kkpyutil-1.42.0.dist-info/RECORD,,