omdev 0.0.0.dev315__py3-none-any.whl → 0.0.0.dev317__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.
- omdev/scripts/ci.py +179 -19
- omdev/scripts/interp.py +178 -19
- omdev/scripts/pyproject.py +178 -19
- {omdev-0.0.0.dev315.dist-info → omdev-0.0.0.dev317.dist-info}/METADATA +2 -2
- {omdev-0.0.0.dev315.dist-info → omdev-0.0.0.dev317.dist-info}/RECORD +9 -9
- {omdev-0.0.0.dev315.dist-info → omdev-0.0.0.dev317.dist-info}/WHEEL +1 -1
- {omdev-0.0.0.dev315.dist-info → omdev-0.0.0.dev317.dist-info}/entry_points.txt +0 -0
- {omdev-0.0.0.dev315.dist-info → omdev-0.0.0.dev317.dist-info}/licenses/LICENSE +0 -0
- {omdev-0.0.0.dev315.dist-info → omdev-0.0.0.dev317.dist-info}/top_level.txt +0 -0
omdev/scripts/ci.py
CHANGED
@@ -41,6 +41,7 @@ import gzip
|
|
41
41
|
import hashlib
|
42
42
|
import heapq
|
43
43
|
import html
|
44
|
+
import http
|
44
45
|
import http.client
|
45
46
|
import http.server
|
46
47
|
import inspect
|
@@ -98,6 +99,9 @@ CheckOnRaiseFn = ta.Callable[[Exception], None] # ta.TypeAlias
|
|
98
99
|
CheckExceptionFactory = ta.Callable[..., Exception] # ta.TypeAlias
|
99
100
|
CheckArgsRenderer = ta.Callable[..., ta.Optional[str]] # ta.TypeAlias
|
100
101
|
|
102
|
+
# ../../omlish/lite/maybes.py
|
103
|
+
U = ta.TypeVar('U')
|
104
|
+
|
101
105
|
# ../../omlish/lite/timeouts.py
|
102
106
|
TimeoutLike = ta.Union['Timeout', ta.Type['Timeout.DEFAULT'], ta.Iterable['TimeoutLike'], float, None] # ta.TypeAlias
|
103
107
|
|
@@ -122,7 +126,6 @@ ExitStackedT = ta.TypeVar('ExitStackedT', bound='ExitStacked')
|
|
122
126
|
AsyncExitStackedT = ta.TypeVar('AsyncExitStackedT', bound='AsyncExitStacked')
|
123
127
|
|
124
128
|
# ../../omlish/lite/inject.py
|
125
|
-
U = ta.TypeVar('U')
|
126
129
|
InjectorKeyCls = ta.Union[type, ta.NewType]
|
127
130
|
InjectorProviderFn = ta.Callable[['Injector'], ta.Any]
|
128
131
|
InjectorProviderFnMap = ta.Mapping['InjectorKey', 'InjectorProviderFn']
|
@@ -1145,7 +1148,13 @@ log = logging.getLogger(__name__)
|
|
1145
1148
|
##
|
1146
1149
|
|
1147
1150
|
|
1151
|
+
@functools.total_ordering
|
1148
1152
|
class Maybe(ta.Generic[T]):
|
1153
|
+
class ValueNotPresentError(BaseException):
|
1154
|
+
pass
|
1155
|
+
|
1156
|
+
#
|
1157
|
+
|
1149
1158
|
@property
|
1150
1159
|
@abc.abstractmethod
|
1151
1160
|
def present(self) -> bool:
|
@@ -1155,9 +1164,102 @@ class Maybe(ta.Generic[T]):
|
|
1155
1164
|
def must(self) -> T:
|
1156
1165
|
raise NotImplementedError
|
1157
1166
|
|
1167
|
+
#
|
1168
|
+
|
1169
|
+
@abc.abstractmethod
|
1170
|
+
def __repr__(self) -> str:
|
1171
|
+
raise NotImplementedError
|
1172
|
+
|
1173
|
+
@abc.abstractmethod
|
1174
|
+
def __hash__(self) -> int:
|
1175
|
+
raise NotImplementedError
|
1176
|
+
|
1177
|
+
@abc.abstractmethod
|
1178
|
+
def __eq__(self, other) -> bool:
|
1179
|
+
raise NotImplementedError
|
1180
|
+
|
1181
|
+
@abc.abstractmethod
|
1182
|
+
def __lt__(self, other) -> bool:
|
1183
|
+
raise NotImplementedError
|
1184
|
+
|
1185
|
+
#
|
1186
|
+
|
1187
|
+
@ta.final
|
1188
|
+
def __ne__(self, other):
|
1189
|
+
return not (self == other)
|
1190
|
+
|
1191
|
+
@ta.final
|
1192
|
+
def __iter__(self) -> ta.Iterator[T]:
|
1193
|
+
if self.present:
|
1194
|
+
yield self.must()
|
1195
|
+
|
1196
|
+
@ta.final
|
1197
|
+
def __bool__(self) -> ta.NoReturn:
|
1198
|
+
raise TypeError
|
1199
|
+
|
1200
|
+
#
|
1201
|
+
|
1202
|
+
@ta.final
|
1203
|
+
def if_present(self, consumer: ta.Callable[[T], None]) -> None:
|
1204
|
+
if self.present:
|
1205
|
+
consumer(self.must())
|
1206
|
+
|
1207
|
+
@ta.final
|
1208
|
+
def filter(self, predicate: ta.Callable[[T], bool]) -> 'Maybe[T]':
|
1209
|
+
if self.present and predicate(self.must()):
|
1210
|
+
return self
|
1211
|
+
else:
|
1212
|
+
return Maybe.empty()
|
1213
|
+
|
1214
|
+
@ta.final
|
1215
|
+
def map(self, mapper: ta.Callable[[T], U]) -> 'Maybe[U]':
|
1216
|
+
if self.present:
|
1217
|
+
return Maybe.just(mapper(self.must()))
|
1218
|
+
else:
|
1219
|
+
return Maybe.empty()
|
1220
|
+
|
1221
|
+
@ta.final
|
1222
|
+
def flat_map(self, mapper: ta.Callable[[T], 'Maybe[U]']) -> 'Maybe[U]':
|
1223
|
+
if self.present:
|
1224
|
+
if not isinstance(v := mapper(self.must()), Maybe):
|
1225
|
+
raise TypeError(v)
|
1226
|
+
return v
|
1227
|
+
else:
|
1228
|
+
return Maybe.empty()
|
1229
|
+
|
1230
|
+
@ta.final
|
1231
|
+
def or_else(self, other: ta.Union[T, U]) -> ta.Union[T, U]:
|
1232
|
+
if self.present:
|
1233
|
+
return self.must()
|
1234
|
+
else:
|
1235
|
+
return other
|
1236
|
+
|
1237
|
+
@ta.final
|
1238
|
+
def or_else_get(self, supplier: ta.Callable[[], ta.Union[T, U]]) -> ta.Union[T, U]:
|
1239
|
+
if self.present:
|
1240
|
+
return self.must()
|
1241
|
+
else:
|
1242
|
+
return supplier()
|
1243
|
+
|
1244
|
+
@ta.final
|
1245
|
+
def or_else_raise(self, exception_supplier: ta.Callable[[], Exception]) -> T:
|
1246
|
+
if self.present:
|
1247
|
+
return self.must()
|
1248
|
+
else:
|
1249
|
+
raise exception_supplier()
|
1250
|
+
|
1251
|
+
#
|
1252
|
+
|
1253
|
+
@classmethod
|
1254
|
+
def of_optional(cls, v: ta.Optional[T]) -> 'Maybe[T]':
|
1255
|
+
if v is not None:
|
1256
|
+
return cls.just(v)
|
1257
|
+
else:
|
1258
|
+
return cls.empty()
|
1259
|
+
|
1158
1260
|
@classmethod
|
1159
1261
|
def just(cls, v: T) -> 'Maybe[T]':
|
1160
|
-
return
|
1262
|
+
return _JustMaybe(v)
|
1161
1263
|
|
1162
1264
|
_empty: ta.ClassVar['Maybe']
|
1163
1265
|
|
@@ -1166,36 +1268,81 @@ class Maybe(ta.Generic[T]):
|
|
1166
1268
|
return Maybe._empty
|
1167
1269
|
|
1168
1270
|
|
1169
|
-
|
1170
|
-
__slots__ = ()
|
1271
|
+
##
|
1171
1272
|
|
1172
|
-
|
1173
|
-
|
1273
|
+
|
1274
|
+
class _Maybe(Maybe[T], abc.ABC):
|
1275
|
+
def __lt__(self, other):
|
1276
|
+
if not isinstance(other, _Maybe):
|
1277
|
+
return NotImplemented
|
1278
|
+
sp = self.present
|
1279
|
+
op = other.present
|
1280
|
+
if self.present and other.present:
|
1281
|
+
return self.must() < other.must()
|
1282
|
+
else:
|
1283
|
+
return op and not sp
|
1284
|
+
|
1285
|
+
|
1286
|
+
class _JustMaybe(_Maybe[T]):
|
1287
|
+
__slots__ = ('_v', '_hash')
|
1288
|
+
|
1289
|
+
def __init__(self, v: T) -> None:
|
1290
|
+
super().__init__()
|
1291
|
+
|
1292
|
+
self._v = v
|
1174
1293
|
|
1175
1294
|
@property
|
1176
1295
|
def present(self) -> bool:
|
1177
|
-
return
|
1296
|
+
return True
|
1178
1297
|
|
1179
1298
|
def must(self) -> T:
|
1180
|
-
|
1181
|
-
raise ValueError
|
1182
|
-
return self[0]
|
1299
|
+
return self._v
|
1183
1300
|
|
1301
|
+
#
|
1184
1302
|
|
1185
|
-
|
1303
|
+
def __repr__(self) -> str:
|
1304
|
+
return f'just({self._v!r})'
|
1186
1305
|
|
1306
|
+
_hash: int
|
1187
1307
|
|
1188
|
-
|
1308
|
+
def __hash__(self) -> int:
|
1309
|
+
try:
|
1310
|
+
return self._hash
|
1311
|
+
except AttributeError:
|
1312
|
+
pass
|
1313
|
+
h = self._hash = hash((_JustMaybe, self._v))
|
1314
|
+
return h
|
1189
1315
|
|
1316
|
+
def __eq__(self, other):
|
1317
|
+
return (
|
1318
|
+
self.__class__ is other.__class__ and
|
1319
|
+
self._v == other._v # noqa
|
1320
|
+
)
|
1190
1321
|
|
1191
|
-
@functools.singledispatch
|
1192
|
-
def as_maybe(obj: ta.Any) -> Maybe:
|
1193
|
-
raise TypeError(obj)
|
1194
1322
|
|
1323
|
+
class _EmptyMaybe(_Maybe[T]):
|
1324
|
+
__slots__ = ()
|
1325
|
+
|
1326
|
+
@property
|
1327
|
+
def present(self) -> bool:
|
1328
|
+
return False
|
1329
|
+
|
1330
|
+
def must(self) -> T:
|
1331
|
+
raise Maybe.ValueNotPresentError
|
1332
|
+
|
1333
|
+
#
|
1334
|
+
|
1335
|
+
def __repr__(self) -> str:
|
1336
|
+
return 'empty()'
|
1195
1337
|
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1338
|
+
def __hash__(self) -> int:
|
1339
|
+
return hash(_EmptyMaybe)
|
1340
|
+
|
1341
|
+
def __eq__(self, other):
|
1342
|
+
return self.__class__ is other.__class__
|
1343
|
+
|
1344
|
+
|
1345
|
+
Maybe._empty = _EmptyMaybe() # noqa
|
1199
1346
|
|
1200
1347
|
|
1201
1348
|
########################################
|
@@ -1587,9 +1734,16 @@ class PredicateTimeout(Timeout):
|
|
1587
1734
|
# ../../../omlish/logs/filters.py
|
1588
1735
|
|
1589
1736
|
|
1737
|
+
##
|
1738
|
+
|
1739
|
+
|
1590
1740
|
class TidLogFilter(logging.Filter):
|
1591
1741
|
def filter(self, record):
|
1592
|
-
|
1742
|
+
# FIXME: handle better - missing from wasm and cosmos
|
1743
|
+
if hasattr(threading, 'get_native_id'):
|
1744
|
+
record.tid = threading.get_native_id()
|
1745
|
+
else:
|
1746
|
+
record.tid = '?'
|
1593
1747
|
return True
|
1594
1748
|
|
1595
1749
|
|
@@ -1597,6 +1751,9 @@ class TidLogFilter(logging.Filter):
|
|
1597
1751
|
# ../../../omlish/logs/proxy.py
|
1598
1752
|
|
1599
1753
|
|
1754
|
+
##
|
1755
|
+
|
1756
|
+
|
1600
1757
|
class ProxyLogFilterer(logging.Filterer):
|
1601
1758
|
def __init__(self, underlying: logging.Filterer) -> None: # noqa
|
1602
1759
|
self._underlying = underlying
|
@@ -5114,6 +5271,9 @@ TODO:
|
|
5114
5271
|
"""
|
5115
5272
|
|
5116
5273
|
|
5274
|
+
##
|
5275
|
+
|
5276
|
+
|
5117
5277
|
class JsonLogFormatter(logging.Formatter):
|
5118
5278
|
KEYS: ta.Mapping[str, bool] = {
|
5119
5279
|
'name': False,
|
omdev/scripts/interp.py
CHANGED
@@ -71,6 +71,9 @@ CheckOnRaiseFn = ta.Callable[[Exception], None] # ta.TypeAlias
|
|
71
71
|
CheckExceptionFactory = ta.Callable[..., Exception] # ta.TypeAlias
|
72
72
|
CheckArgsRenderer = ta.Callable[..., ta.Optional[str]] # ta.TypeAlias
|
73
73
|
|
74
|
+
# ../../omlish/lite/maybes.py
|
75
|
+
U = ta.TypeVar('U')
|
76
|
+
|
74
77
|
# ../../omlish/lite/timeouts.py
|
75
78
|
TimeoutLike = ta.Union['Timeout', ta.Type['Timeout.DEFAULT'], ta.Iterable['TimeoutLike'], float, None] # ta.TypeAlias
|
76
79
|
|
@@ -86,7 +89,6 @@ ArgparseCmdFn = ta.Callable[[], ta.Optional[int]] # ta.TypeAlias
|
|
86
89
|
AwaitableT = ta.TypeVar('AwaitableT', bound=ta.Awaitable)
|
87
90
|
|
88
91
|
# ../../omlish/lite/inject.py
|
89
|
-
U = ta.TypeVar('U')
|
90
92
|
InjectorKeyCls = ta.Union[type, ta.NewType]
|
91
93
|
InjectorProviderFn = ta.Callable[['Injector'], ta.Any]
|
92
94
|
InjectorProviderFnMap = ta.Mapping['InjectorKey', 'InjectorProviderFn']
|
@@ -1088,7 +1090,13 @@ json_dumps_compact: ta.Callable[..., str] = functools.partial(json.dumps, **JSON
|
|
1088
1090
|
##
|
1089
1091
|
|
1090
1092
|
|
1093
|
+
@functools.total_ordering
|
1091
1094
|
class Maybe(ta.Generic[T]):
|
1095
|
+
class ValueNotPresentError(BaseException):
|
1096
|
+
pass
|
1097
|
+
|
1098
|
+
#
|
1099
|
+
|
1092
1100
|
@property
|
1093
1101
|
@abc.abstractmethod
|
1094
1102
|
def present(self) -> bool:
|
@@ -1098,9 +1106,102 @@ class Maybe(ta.Generic[T]):
|
|
1098
1106
|
def must(self) -> T:
|
1099
1107
|
raise NotImplementedError
|
1100
1108
|
|
1109
|
+
#
|
1110
|
+
|
1111
|
+
@abc.abstractmethod
|
1112
|
+
def __repr__(self) -> str:
|
1113
|
+
raise NotImplementedError
|
1114
|
+
|
1115
|
+
@abc.abstractmethod
|
1116
|
+
def __hash__(self) -> int:
|
1117
|
+
raise NotImplementedError
|
1118
|
+
|
1119
|
+
@abc.abstractmethod
|
1120
|
+
def __eq__(self, other) -> bool:
|
1121
|
+
raise NotImplementedError
|
1122
|
+
|
1123
|
+
@abc.abstractmethod
|
1124
|
+
def __lt__(self, other) -> bool:
|
1125
|
+
raise NotImplementedError
|
1126
|
+
|
1127
|
+
#
|
1128
|
+
|
1129
|
+
@ta.final
|
1130
|
+
def __ne__(self, other):
|
1131
|
+
return not (self == other)
|
1132
|
+
|
1133
|
+
@ta.final
|
1134
|
+
def __iter__(self) -> ta.Iterator[T]:
|
1135
|
+
if self.present:
|
1136
|
+
yield self.must()
|
1137
|
+
|
1138
|
+
@ta.final
|
1139
|
+
def __bool__(self) -> ta.NoReturn:
|
1140
|
+
raise TypeError
|
1141
|
+
|
1142
|
+
#
|
1143
|
+
|
1144
|
+
@ta.final
|
1145
|
+
def if_present(self, consumer: ta.Callable[[T], None]) -> None:
|
1146
|
+
if self.present:
|
1147
|
+
consumer(self.must())
|
1148
|
+
|
1149
|
+
@ta.final
|
1150
|
+
def filter(self, predicate: ta.Callable[[T], bool]) -> 'Maybe[T]':
|
1151
|
+
if self.present and predicate(self.must()):
|
1152
|
+
return self
|
1153
|
+
else:
|
1154
|
+
return Maybe.empty()
|
1155
|
+
|
1156
|
+
@ta.final
|
1157
|
+
def map(self, mapper: ta.Callable[[T], U]) -> 'Maybe[U]':
|
1158
|
+
if self.present:
|
1159
|
+
return Maybe.just(mapper(self.must()))
|
1160
|
+
else:
|
1161
|
+
return Maybe.empty()
|
1162
|
+
|
1163
|
+
@ta.final
|
1164
|
+
def flat_map(self, mapper: ta.Callable[[T], 'Maybe[U]']) -> 'Maybe[U]':
|
1165
|
+
if self.present:
|
1166
|
+
if not isinstance(v := mapper(self.must()), Maybe):
|
1167
|
+
raise TypeError(v)
|
1168
|
+
return v
|
1169
|
+
else:
|
1170
|
+
return Maybe.empty()
|
1171
|
+
|
1172
|
+
@ta.final
|
1173
|
+
def or_else(self, other: ta.Union[T, U]) -> ta.Union[T, U]:
|
1174
|
+
if self.present:
|
1175
|
+
return self.must()
|
1176
|
+
else:
|
1177
|
+
return other
|
1178
|
+
|
1179
|
+
@ta.final
|
1180
|
+
def or_else_get(self, supplier: ta.Callable[[], ta.Union[T, U]]) -> ta.Union[T, U]:
|
1181
|
+
if self.present:
|
1182
|
+
return self.must()
|
1183
|
+
else:
|
1184
|
+
return supplier()
|
1185
|
+
|
1186
|
+
@ta.final
|
1187
|
+
def or_else_raise(self, exception_supplier: ta.Callable[[], Exception]) -> T:
|
1188
|
+
if self.present:
|
1189
|
+
return self.must()
|
1190
|
+
else:
|
1191
|
+
raise exception_supplier()
|
1192
|
+
|
1193
|
+
#
|
1194
|
+
|
1195
|
+
@classmethod
|
1196
|
+
def of_optional(cls, v: ta.Optional[T]) -> 'Maybe[T]':
|
1197
|
+
if v is not None:
|
1198
|
+
return cls.just(v)
|
1199
|
+
else:
|
1200
|
+
return cls.empty()
|
1201
|
+
|
1101
1202
|
@classmethod
|
1102
1203
|
def just(cls, v: T) -> 'Maybe[T]':
|
1103
|
-
return
|
1204
|
+
return _JustMaybe(v)
|
1104
1205
|
|
1105
1206
|
_empty: ta.ClassVar['Maybe']
|
1106
1207
|
|
@@ -1109,36 +1210,81 @@ class Maybe(ta.Generic[T]):
|
|
1109
1210
|
return Maybe._empty
|
1110
1211
|
|
1111
1212
|
|
1112
|
-
|
1113
|
-
__slots__ = ()
|
1213
|
+
##
|
1114
1214
|
|
1115
|
-
|
1116
|
-
|
1215
|
+
|
1216
|
+
class _Maybe(Maybe[T], abc.ABC):
|
1217
|
+
def __lt__(self, other):
|
1218
|
+
if not isinstance(other, _Maybe):
|
1219
|
+
return NotImplemented
|
1220
|
+
sp = self.present
|
1221
|
+
op = other.present
|
1222
|
+
if self.present and other.present:
|
1223
|
+
return self.must() < other.must()
|
1224
|
+
else:
|
1225
|
+
return op and not sp
|
1226
|
+
|
1227
|
+
|
1228
|
+
class _JustMaybe(_Maybe[T]):
|
1229
|
+
__slots__ = ('_v', '_hash')
|
1230
|
+
|
1231
|
+
def __init__(self, v: T) -> None:
|
1232
|
+
super().__init__()
|
1233
|
+
|
1234
|
+
self._v = v
|
1117
1235
|
|
1118
1236
|
@property
|
1119
1237
|
def present(self) -> bool:
|
1120
|
-
return
|
1238
|
+
return True
|
1121
1239
|
|
1122
1240
|
def must(self) -> T:
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1241
|
+
return self._v
|
1242
|
+
|
1243
|
+
#
|
1126
1244
|
|
1245
|
+
def __repr__(self) -> str:
|
1246
|
+
return f'just({self._v!r})'
|
1127
1247
|
|
1128
|
-
|
1248
|
+
_hash: int
|
1129
1249
|
|
1250
|
+
def __hash__(self) -> int:
|
1251
|
+
try:
|
1252
|
+
return self._hash
|
1253
|
+
except AttributeError:
|
1254
|
+
pass
|
1255
|
+
h = self._hash = hash((_JustMaybe, self._v))
|
1256
|
+
return h
|
1130
1257
|
|
1131
|
-
|
1258
|
+
def __eq__(self, other):
|
1259
|
+
return (
|
1260
|
+
self.__class__ is other.__class__ and
|
1261
|
+
self._v == other._v # noqa
|
1262
|
+
)
|
1132
1263
|
|
1133
1264
|
|
1134
|
-
|
1135
|
-
|
1136
|
-
raise TypeError(obj)
|
1265
|
+
class _EmptyMaybe(_Maybe[T]):
|
1266
|
+
__slots__ = ()
|
1137
1267
|
|
1268
|
+
@property
|
1269
|
+
def present(self) -> bool:
|
1270
|
+
return False
|
1271
|
+
|
1272
|
+
def must(self) -> T:
|
1273
|
+
raise Maybe.ValueNotPresentError
|
1274
|
+
|
1275
|
+
#
|
1276
|
+
|
1277
|
+
def __repr__(self) -> str:
|
1278
|
+
return 'empty()'
|
1279
|
+
|
1280
|
+
def __hash__(self) -> int:
|
1281
|
+
return hash(_EmptyMaybe)
|
1138
1282
|
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1283
|
+
def __eq__(self, other):
|
1284
|
+
return self.__class__ is other.__class__
|
1285
|
+
|
1286
|
+
|
1287
|
+
Maybe._empty = _EmptyMaybe() # noqa
|
1142
1288
|
|
1143
1289
|
|
1144
1290
|
########################################
|
@@ -1530,9 +1676,16 @@ class PredicateTimeout(Timeout):
|
|
1530
1676
|
# ../../../omlish/logs/filters.py
|
1531
1677
|
|
1532
1678
|
|
1679
|
+
##
|
1680
|
+
|
1681
|
+
|
1533
1682
|
class TidLogFilter(logging.Filter):
|
1534
1683
|
def filter(self, record):
|
1535
|
-
|
1684
|
+
# FIXME: handle better - missing from wasm and cosmos
|
1685
|
+
if hasattr(threading, 'get_native_id'):
|
1686
|
+
record.tid = threading.get_native_id()
|
1687
|
+
else:
|
1688
|
+
record.tid = '?'
|
1536
1689
|
return True
|
1537
1690
|
|
1538
1691
|
|
@@ -1540,6 +1693,9 @@ class TidLogFilter(logging.Filter):
|
|
1540
1693
|
# ../../../omlish/logs/proxy.py
|
1541
1694
|
|
1542
1695
|
|
1696
|
+
##
|
1697
|
+
|
1698
|
+
|
1543
1699
|
class ProxyLogFilterer(logging.Filterer):
|
1544
1700
|
def __init__(self, underlying: logging.Filterer) -> None: # noqa
|
1545
1701
|
self._underlying = underlying
|
@@ -3579,6 +3735,9 @@ TODO:
|
|
3579
3735
|
"""
|
3580
3736
|
|
3581
3737
|
|
3738
|
+
##
|
3739
|
+
|
3740
|
+
|
3582
3741
|
class JsonLogFormatter(logging.Formatter):
|
3583
3742
|
KEYS: ta.Mapping[str, bool] = {
|
3584
3743
|
'name': False,
|
omdev/scripts/pyproject.py
CHANGED
@@ -107,6 +107,9 @@ CheckOnRaiseFn = ta.Callable[[Exception], None] # ta.TypeAlias
|
|
107
107
|
CheckExceptionFactory = ta.Callable[..., Exception] # ta.TypeAlias
|
108
108
|
CheckArgsRenderer = ta.Callable[..., ta.Optional[str]] # ta.TypeAlias
|
109
109
|
|
110
|
+
# ../../omlish/lite/maybes.py
|
111
|
+
U = ta.TypeVar('U')
|
112
|
+
|
110
113
|
# ../../omlish/lite/timeouts.py
|
111
114
|
TimeoutLike = ta.Union['Timeout', ta.Type['Timeout.DEFAULT'], ta.Iterable['TimeoutLike'], float, None] # ta.TypeAlias
|
112
115
|
|
@@ -127,7 +130,6 @@ ArgparseCmdFn = ta.Callable[[], ta.Optional[int]] # ta.TypeAlias
|
|
127
130
|
AwaitableT = ta.TypeVar('AwaitableT', bound=ta.Awaitable)
|
128
131
|
|
129
132
|
# ../../omlish/lite/inject.py
|
130
|
-
U = ta.TypeVar('U')
|
131
133
|
InjectorKeyCls = ta.Union[type, ta.NewType]
|
132
134
|
InjectorProviderFn = ta.Callable[['Injector'], ta.Any]
|
133
135
|
InjectorProviderFnMap = ta.Mapping['InjectorKey', 'InjectorProviderFn']
|
@@ -2504,7 +2506,13 @@ log = logging.getLogger(__name__)
|
|
2504
2506
|
##
|
2505
2507
|
|
2506
2508
|
|
2509
|
+
@functools.total_ordering
|
2507
2510
|
class Maybe(ta.Generic[T]):
|
2511
|
+
class ValueNotPresentError(BaseException):
|
2512
|
+
pass
|
2513
|
+
|
2514
|
+
#
|
2515
|
+
|
2508
2516
|
@property
|
2509
2517
|
@abc.abstractmethod
|
2510
2518
|
def present(self) -> bool:
|
@@ -2514,9 +2522,102 @@ class Maybe(ta.Generic[T]):
|
|
2514
2522
|
def must(self) -> T:
|
2515
2523
|
raise NotImplementedError
|
2516
2524
|
|
2525
|
+
#
|
2526
|
+
|
2527
|
+
@abc.abstractmethod
|
2528
|
+
def __repr__(self) -> str:
|
2529
|
+
raise NotImplementedError
|
2530
|
+
|
2531
|
+
@abc.abstractmethod
|
2532
|
+
def __hash__(self) -> int:
|
2533
|
+
raise NotImplementedError
|
2534
|
+
|
2535
|
+
@abc.abstractmethod
|
2536
|
+
def __eq__(self, other) -> bool:
|
2537
|
+
raise NotImplementedError
|
2538
|
+
|
2539
|
+
@abc.abstractmethod
|
2540
|
+
def __lt__(self, other) -> bool:
|
2541
|
+
raise NotImplementedError
|
2542
|
+
|
2543
|
+
#
|
2544
|
+
|
2545
|
+
@ta.final
|
2546
|
+
def __ne__(self, other):
|
2547
|
+
return not (self == other)
|
2548
|
+
|
2549
|
+
@ta.final
|
2550
|
+
def __iter__(self) -> ta.Iterator[T]:
|
2551
|
+
if self.present:
|
2552
|
+
yield self.must()
|
2553
|
+
|
2554
|
+
@ta.final
|
2555
|
+
def __bool__(self) -> ta.NoReturn:
|
2556
|
+
raise TypeError
|
2557
|
+
|
2558
|
+
#
|
2559
|
+
|
2560
|
+
@ta.final
|
2561
|
+
def if_present(self, consumer: ta.Callable[[T], None]) -> None:
|
2562
|
+
if self.present:
|
2563
|
+
consumer(self.must())
|
2564
|
+
|
2565
|
+
@ta.final
|
2566
|
+
def filter(self, predicate: ta.Callable[[T], bool]) -> 'Maybe[T]':
|
2567
|
+
if self.present and predicate(self.must()):
|
2568
|
+
return self
|
2569
|
+
else:
|
2570
|
+
return Maybe.empty()
|
2571
|
+
|
2572
|
+
@ta.final
|
2573
|
+
def map(self, mapper: ta.Callable[[T], U]) -> 'Maybe[U]':
|
2574
|
+
if self.present:
|
2575
|
+
return Maybe.just(mapper(self.must()))
|
2576
|
+
else:
|
2577
|
+
return Maybe.empty()
|
2578
|
+
|
2579
|
+
@ta.final
|
2580
|
+
def flat_map(self, mapper: ta.Callable[[T], 'Maybe[U]']) -> 'Maybe[U]':
|
2581
|
+
if self.present:
|
2582
|
+
if not isinstance(v := mapper(self.must()), Maybe):
|
2583
|
+
raise TypeError(v)
|
2584
|
+
return v
|
2585
|
+
else:
|
2586
|
+
return Maybe.empty()
|
2587
|
+
|
2588
|
+
@ta.final
|
2589
|
+
def or_else(self, other: ta.Union[T, U]) -> ta.Union[T, U]:
|
2590
|
+
if self.present:
|
2591
|
+
return self.must()
|
2592
|
+
else:
|
2593
|
+
return other
|
2594
|
+
|
2595
|
+
@ta.final
|
2596
|
+
def or_else_get(self, supplier: ta.Callable[[], ta.Union[T, U]]) -> ta.Union[T, U]:
|
2597
|
+
if self.present:
|
2598
|
+
return self.must()
|
2599
|
+
else:
|
2600
|
+
return supplier()
|
2601
|
+
|
2602
|
+
@ta.final
|
2603
|
+
def or_else_raise(self, exception_supplier: ta.Callable[[], Exception]) -> T:
|
2604
|
+
if self.present:
|
2605
|
+
return self.must()
|
2606
|
+
else:
|
2607
|
+
raise exception_supplier()
|
2608
|
+
|
2609
|
+
#
|
2610
|
+
|
2611
|
+
@classmethod
|
2612
|
+
def of_optional(cls, v: ta.Optional[T]) -> 'Maybe[T]':
|
2613
|
+
if v is not None:
|
2614
|
+
return cls.just(v)
|
2615
|
+
else:
|
2616
|
+
return cls.empty()
|
2617
|
+
|
2517
2618
|
@classmethod
|
2518
2619
|
def just(cls, v: T) -> 'Maybe[T]':
|
2519
|
-
return
|
2620
|
+
return _JustMaybe(v)
|
2520
2621
|
|
2521
2622
|
_empty: ta.ClassVar['Maybe']
|
2522
2623
|
|
@@ -2525,36 +2626,81 @@ class Maybe(ta.Generic[T]):
|
|
2525
2626
|
return Maybe._empty
|
2526
2627
|
|
2527
2628
|
|
2528
|
-
|
2529
|
-
__slots__ = ()
|
2629
|
+
##
|
2530
2630
|
|
2531
|
-
|
2532
|
-
|
2631
|
+
|
2632
|
+
class _Maybe(Maybe[T], abc.ABC):
|
2633
|
+
def __lt__(self, other):
|
2634
|
+
if not isinstance(other, _Maybe):
|
2635
|
+
return NotImplemented
|
2636
|
+
sp = self.present
|
2637
|
+
op = other.present
|
2638
|
+
if self.present and other.present:
|
2639
|
+
return self.must() < other.must()
|
2640
|
+
else:
|
2641
|
+
return op and not sp
|
2642
|
+
|
2643
|
+
|
2644
|
+
class _JustMaybe(_Maybe[T]):
|
2645
|
+
__slots__ = ('_v', '_hash')
|
2646
|
+
|
2647
|
+
def __init__(self, v: T) -> None:
|
2648
|
+
super().__init__()
|
2649
|
+
|
2650
|
+
self._v = v
|
2533
2651
|
|
2534
2652
|
@property
|
2535
2653
|
def present(self) -> bool:
|
2536
|
-
return
|
2654
|
+
return True
|
2537
2655
|
|
2538
2656
|
def must(self) -> T:
|
2539
|
-
|
2540
|
-
|
2541
|
-
|
2657
|
+
return self._v
|
2658
|
+
|
2659
|
+
#
|
2542
2660
|
|
2661
|
+
def __repr__(self) -> str:
|
2662
|
+
return f'just({self._v!r})'
|
2543
2663
|
|
2544
|
-
|
2664
|
+
_hash: int
|
2545
2665
|
|
2666
|
+
def __hash__(self) -> int:
|
2667
|
+
try:
|
2668
|
+
return self._hash
|
2669
|
+
except AttributeError:
|
2670
|
+
pass
|
2671
|
+
h = self._hash = hash((_JustMaybe, self._v))
|
2672
|
+
return h
|
2546
2673
|
|
2547
|
-
|
2674
|
+
def __eq__(self, other):
|
2675
|
+
return (
|
2676
|
+
self.__class__ is other.__class__ and
|
2677
|
+
self._v == other._v # noqa
|
2678
|
+
)
|
2548
2679
|
|
2549
2680
|
|
2550
|
-
|
2551
|
-
|
2552
|
-
raise TypeError(obj)
|
2681
|
+
class _EmptyMaybe(_Maybe[T]):
|
2682
|
+
__slots__ = ()
|
2553
2683
|
|
2684
|
+
@property
|
2685
|
+
def present(self) -> bool:
|
2686
|
+
return False
|
2687
|
+
|
2688
|
+
def must(self) -> T:
|
2689
|
+
raise Maybe.ValueNotPresentError
|
2690
|
+
|
2691
|
+
#
|
2692
|
+
|
2693
|
+
def __repr__(self) -> str:
|
2694
|
+
return 'empty()'
|
2695
|
+
|
2696
|
+
def __hash__(self) -> int:
|
2697
|
+
return hash(_EmptyMaybe)
|
2554
2698
|
|
2555
|
-
|
2556
|
-
|
2557
|
-
|
2699
|
+
def __eq__(self, other):
|
2700
|
+
return self.__class__ is other.__class__
|
2701
|
+
|
2702
|
+
|
2703
|
+
Maybe._empty = _EmptyMaybe() # noqa
|
2558
2704
|
|
2559
2705
|
|
2560
2706
|
########################################
|
@@ -2994,9 +3140,16 @@ class Func3(ta.Generic[A0, A1, A2, T]):
|
|
2994
3140
|
# ../../../omlish/logs/filters.py
|
2995
3141
|
|
2996
3142
|
|
3143
|
+
##
|
3144
|
+
|
3145
|
+
|
2997
3146
|
class TidLogFilter(logging.Filter):
|
2998
3147
|
def filter(self, record):
|
2999
|
-
|
3148
|
+
# FIXME: handle better - missing from wasm and cosmos
|
3149
|
+
if hasattr(threading, 'get_native_id'):
|
3150
|
+
record.tid = threading.get_native_id()
|
3151
|
+
else:
|
3152
|
+
record.tid = '?'
|
3000
3153
|
return True
|
3001
3154
|
|
3002
3155
|
|
@@ -3004,6 +3157,9 @@ class TidLogFilter(logging.Filter):
|
|
3004
3157
|
# ../../../omlish/logs/proxy.py
|
3005
3158
|
|
3006
3159
|
|
3160
|
+
##
|
3161
|
+
|
3162
|
+
|
3007
3163
|
class ProxyLogFilterer(logging.Filterer):
|
3008
3164
|
def __init__(self, underlying: logging.Filterer) -> None: # noqa
|
3009
3165
|
self._underlying = underlying
|
@@ -5949,6 +6105,9 @@ TODO:
|
|
5949
6105
|
"""
|
5950
6106
|
|
5951
6107
|
|
6108
|
+
##
|
6109
|
+
|
6110
|
+
|
5952
6111
|
class JsonLogFormatter(logging.Formatter):
|
5953
6112
|
KEYS: ta.Mapping[str, bool] = {
|
5954
6113
|
'name': False,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: omdev
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev317
|
4
4
|
Summary: omdev
|
5
5
|
Author: wrmsr
|
6
6
|
License: BSD-3-Clause
|
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: Operating System :: POSIX
|
13
13
|
Requires-Python: >=3.12
|
14
14
|
License-File: LICENSE
|
15
|
-
Requires-Dist: omlish==0.0.0.
|
15
|
+
Requires-Dist: omlish==0.0.0.dev317
|
16
16
|
Provides-Extra: all
|
17
17
|
Requires-Dist: black~=25.1; extra == "all"
|
18
18
|
Requires-Dist: pycparser~=2.22; extra == "all"
|
@@ -250,9 +250,9 @@ omdev/pyproject/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
250
250
|
omdev/pyproject/resources/docker-dev.sh,sha256=DHkz5D18jok_oDolfg2mqrvGRWFoCe9GQo04dR1czcc,838
|
251
251
|
omdev/pyproject/resources/python.sh,sha256=rFaN4SiJ9hdLDXXsDTwugI6zsw6EPkgYMmtacZeTbvw,749
|
252
252
|
omdev/scripts/__init__.py,sha256=MKCvUAEQwsIvwLixwtPlpBqmkMXLCnjjXyAXvVpDwVk,91
|
253
|
-
omdev/scripts/ci.py,sha256=
|
254
|
-
omdev/scripts/interp.py,sha256=
|
255
|
-
omdev/scripts/pyproject.py,sha256=
|
253
|
+
omdev/scripts/ci.py,sha256=1IeNGWCyHtonK1PHaKETW7IqCyXMkIkMafXUVlFCtQo,357043
|
254
|
+
omdev/scripts/interp.py,sha256=ByjO0DdnYF8VDYu04v6oIops4CknA8bUTOmcbjmlXGk,155590
|
255
|
+
omdev/scripts/pyproject.py,sha256=psPWxTp0FAPrRTMEoLTvHOsbv15fkIf_Lh8LBl3pYZE,265071
|
256
256
|
omdev/scripts/slowcat.py,sha256=lssv4yrgJHiWfOiHkUut2p8E8Tq32zB-ujXESQxFFHY,2728
|
257
257
|
omdev/scripts/tmpexec.py,sha256=WTYcf56Tj2qjYV14AWmV8SfT0u6Y8eIU6cKgQRvEK3c,1442
|
258
258
|
omdev/tokens/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -294,9 +294,9 @@ omdev/tools/json/rendering.py,sha256=3HhdlKSetS6iK1tjF2aILzsl8Mb3D8wW92vYwGpRdVA
|
|
294
294
|
omdev/tools/pawk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
295
295
|
omdev/tools/pawk/__main__.py,sha256=VCqeRVnqT1RPEoIrqHFSu4PXVMg4YEgF4qCQm90-eRI,66
|
296
296
|
omdev/tools/pawk/pawk.py,sha256=zsEkfQX0jF5bn712uqPAyBSdJt2dno1LH2oeSMNfXQI,11424
|
297
|
-
omdev-0.0.0.
|
298
|
-
omdev-0.0.0.
|
299
|
-
omdev-0.0.0.
|
300
|
-
omdev-0.0.0.
|
301
|
-
omdev-0.0.0.
|
302
|
-
omdev-0.0.0.
|
297
|
+
omdev-0.0.0.dev317.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
298
|
+
omdev-0.0.0.dev317.dist-info/METADATA,sha256=b1BUgoKYpwixeg-HAJ7G-LNQn-N5rf4Y0gK77ere6yc,1674
|
299
|
+
omdev-0.0.0.dev317.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
300
|
+
omdev-0.0.0.dev317.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
|
301
|
+
omdev-0.0.0.dev317.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
|
302
|
+
omdev-0.0.0.dev317.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|