ominfra 0.0.0.dev429__py3-none-any.whl → 0.0.0.dev430__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.
@@ -1600,8 +1600,6 @@ class AttrOps(ta.Generic[T]):
1600
1600
  self._eq = _eq
1601
1601
  return _eq
1602
1602
 
1603
- #
1604
-
1605
1603
  @property
1606
1604
  def hash_eq(self) -> ta.Tuple[
1607
1605
  ta.Callable[[T], int],
@@ -1609,6 +1607,8 @@ class AttrOps(ta.Generic[T]):
1609
1607
  ]:
1610
1608
  return (self.hash, self.eq)
1611
1609
 
1610
+ #
1611
+
1612
1612
  @property
1613
1613
  def repr_hash_eq(self) -> ta.Tuple[
1614
1614
  ta.Callable[[T], str],
@@ -1619,20 +1619,25 @@ class AttrOps(ta.Generic[T]):
1619
1619
 
1620
1620
  #
1621
1621
 
1622
+ class NOT_SET: # noqa
1623
+ def __new__(cls, *args, **kwargs): # noqa
1624
+ raise TypeError
1625
+
1622
1626
  def install(
1623
1627
  self,
1624
1628
  locals_dct: ta.MutableMapping[str, ta.Any],
1625
1629
  *,
1626
- all: bool = False, # noqa
1627
- repr: bool = False, # noqa
1628
- hash: bool = False, # noqa
1629
- eq: bool = False,
1630
+ repr: ta.Union[bool, ta.Type[NOT_SET]] = NOT_SET, # noqa
1631
+ hash: ta.Union[bool, ta.Type[NOT_SET]] = NOT_SET, # noqa
1632
+ eq: ta.Union[bool, ta.Type[NOT_SET]] = NOT_SET,
1630
1633
  ) -> 'AttrOps[T]':
1631
- if repr or all:
1634
+ if all(a is self.NOT_SET for a in (repr, hash, eq)):
1635
+ repr = hash = eq = True # noqa
1636
+ if repr:
1632
1637
  locals_dct.update(__repr__=self.repr)
1633
- if hash or all:
1638
+ if hash:
1634
1639
  locals_dct.update(__hash__=self.hash)
1635
- if eq or all:
1640
+ if eq:
1636
1641
  locals_dct.update(__eq__=self.eq)
1637
1642
  return self
1638
1643
 
@@ -2717,8 +2722,8 @@ class LoggingSourceFileInfo(ta.NamedTuple):
2717
2722
  return None
2718
2723
 
2719
2724
  return cls(
2720
- file_name,
2721
- module,
2725
+ file_name=file_name,
2726
+ module=module,
2722
2727
  )
2723
2728
 
2724
2729
 
@@ -2735,9 +2740,9 @@ class LoggingThreadInfo(ta.NamedTuple):
2735
2740
  @classmethod
2736
2741
  def build(cls) -> 'LoggingThreadInfo':
2737
2742
  return cls(
2738
- threading.get_ident(),
2739
- threading.get_native_id() if hasattr(threading, 'get_native_id') else None,
2740
- threading.current_thread().name,
2743
+ ident=threading.get_ident(),
2744
+ native_id=threading.get_native_id() if hasattr(threading, 'get_native_id') else None,
2745
+ name=threading.current_thread().name,
2741
2746
  )
2742
2747
 
2743
2748
 
@@ -2752,7 +2757,7 @@ class LoggingProcessInfo(ta.NamedTuple):
2752
2757
  @classmethod
2753
2758
  def build(cls) -> 'LoggingProcessInfo':
2754
2759
  return cls(
2755
- os.getpid(),
2760
+ pid=os.getpid(),
2756
2761
  )
2757
2762
 
2758
2763
 
@@ -2771,7 +2776,7 @@ class LoggingMultiprocessingInfo(ta.NamedTuple):
2771
2776
  return None
2772
2777
 
2773
2778
  return cls(
2774
- mp.current_process().name,
2779
+ process_name=mp.current_process().name,
2775
2780
  )
2776
2781
 
2777
2782
 
@@ -2798,7 +2803,7 @@ class LoggingAsyncioTaskInfo(ta.NamedTuple):
2798
2803
  return None
2799
2804
 
2800
2805
  return cls(
2801
- task.get_name(), # Always non-None
2806
+ name=task.get_name(), # Always non-None
2802
2807
  )
2803
2808
 
2804
2809
 
@@ -2821,36 +2826,66 @@ class NamedLogLevel(int):
2821
2826
 
2822
2827
  #
2823
2828
 
2824
- @property
2825
- def exact_name(self) -> ta.Optional[str]:
2826
- return self._NAMES_BY_INT.get(self)
2829
+ _CACHE: ta.ClassVar[ta.MutableMapping[int, 'NamedLogLevel']] = {}
2830
+
2831
+ @ta.overload
2832
+ def __new__(cls, name: str, offset: int = 0, /) -> 'NamedLogLevel':
2833
+ ...
2834
+
2835
+ @ta.overload
2836
+ def __new__(cls, i: int, /) -> 'NamedLogLevel':
2837
+ ...
2838
+
2839
+ def __new__(cls, x, offset=0, /):
2840
+ if isinstance(x, str):
2841
+ return cls(cls._INTS_BY_NAME[x.upper()] + offset)
2842
+ elif not offset and (c := cls._CACHE.get(x)) is not None:
2843
+ return c
2844
+ else:
2845
+ return super().__new__(cls, x + offset)
2827
2846
 
2828
- _effective_name: ta.Optional[str]
2847
+ #
2848
+
2849
+ _name_and_offset: ta.Tuple[str, int]
2829
2850
 
2830
2851
  @property
2831
- def effective_name(self) -> ta.Optional[str]:
2852
+ def name_and_offset(self) -> ta.Tuple[str, int]:
2832
2853
  try:
2833
- return self._effective_name
2854
+ return self._name_and_offset
2834
2855
  except AttributeError:
2835
2856
  pass
2836
2857
 
2837
- if (n := self.exact_name) is None:
2858
+ if (n := self._NAMES_BY_INT.get(self)) is not None:
2859
+ t = (n, 0)
2860
+ else:
2838
2861
  for n, i in self._NAME_INT_PAIRS: # noqa
2839
2862
  if self >= i:
2863
+ t = (n, (self - i))
2840
2864
  break
2841
2865
  else:
2842
- n = None
2866
+ t = ('NOTSET', int(self))
2867
+
2868
+ self._name_and_offset = t
2869
+ return t
2843
2870
 
2844
- self._effective_name = n
2871
+ @property
2872
+ def exact_name(self) -> ta.Optional[str]:
2873
+ n, o = self.name_and_offset
2874
+ return n if not o else None
2875
+
2876
+ @property
2877
+ def effective_name(self) -> str:
2878
+ n, _ = self.name_and_offset
2845
2879
  return n
2846
2880
 
2847
2881
  #
2848
2882
 
2849
- def __repr__(self) -> str:
2850
- return f'{self.__class__.__name__}({int(self)})'
2851
-
2852
2883
  def __str__(self) -> str:
2853
- return self.exact_name or f'{self.effective_name or "INVALID"}:{int(self)}'
2884
+ return self.exact_name or f'{self.effective_name}{int(self):+}'
2885
+
2886
+ def __repr__(self) -> str:
2887
+ n, o = self.name_and_offset
2888
+ return f'{self.__class__.__name__}({n!r}{f", {int(o)}" if o else ""})'
2854
2889
 
2855
2890
  #
2856
2891
 
@@ -2870,6 +2905,9 @@ NamedLogLevel.DEBUG = NamedLogLevel(logging.DEBUG)
2870
2905
  NamedLogLevel.NOTSET = NamedLogLevel(logging.NOTSET)
2871
2906
 
2872
2907
 
2908
+ NamedLogLevel._CACHE.update({i: NamedLogLevel(i) for i in NamedLogLevel._NAMES_BY_INT}) # noqa
2909
+
2910
+
2873
2911
  ########################################
2874
2912
  # ../../../../../omlish/logs/std/filters.py
2875
2913
 
@@ -4968,10 +5006,10 @@ class LoggingCaller(ta.NamedTuple):
4968
5006
  sinfo = sinfo[:-1]
4969
5007
 
4970
5008
  return cls(
4971
- f.f_code.co_filename,
4972
- f.f_lineno or 0,
4973
- f.f_code.co_name,
4974
- sinfo,
5009
+ file_path=f.f_code.co_filename,
5010
+ line_no=f.f_lineno or 0,
5011
+ name=f.f_code.co_name,
5012
+ stack_info=sinfo,
4975
5013
  )
4976
5014
 
4977
5015
 
@@ -5089,9 +5127,9 @@ class LoggingTimeFields(ta.NamedTuple):
5089
5127
  relative_created = (time_ns - start_time_ns) / 1e6
5090
5128
 
5091
5129
  return cls(
5092
- created,
5093
- msecs,
5094
- relative_created,
5130
+ created=created,
5131
+ msecs=msecs,
5132
+ relative_created=relative_created,
5095
5133
  )
5096
5134
 
5097
5135
 
@@ -5734,7 +5772,6 @@ def subprocess_maybe_shell_wrap_exec(*cmd: str) -> ta.Tuple[str, ...]:
5734
5772
 
5735
5773
 
5736
5774
  class AnyLogger(Abstract, ta.Generic[T]):
5737
- @ta.final
5738
5775
  def is_enabled_for(self, level: LogLevel) -> bool:
5739
5776
  return level >= self.get_effective_level()
5740
5777
 
@@ -5933,7 +5970,7 @@ class AsyncLogger(AnyLogger[ta.Awaitable[None]], Abstract):
5933
5970
  class AnyNopLogger(AnyLogger[T], Abstract):
5934
5971
  @ta.final
5935
5972
  def get_effective_level(self) -> LogLevel:
5936
- return 999
5973
+ return -999
5937
5974
 
5938
5975
 
5939
5976
  @ta.final
@@ -6243,7 +6280,7 @@ class LoggingContextLogRecord(logging.LogRecord):
6243
6280
 
6244
6281
 
6245
6282
  ########################################
6246
- # ../../../../../omlish/logs/std/adapters.py
6283
+ # ../../../../../omlish/logs/std/loggers.py
6247
6284
 
6248
6285
 
6249
6286
  ##
@@ -6259,6 +6296,9 @@ class StdLogger(Logger):
6259
6296
  def std(self) -> logging.Logger:
6260
6297
  return self._std
6261
6298
 
6299
+ def is_enabled_for(self, level: LogLevel) -> bool:
6300
+ return self._std.isEnabledFor(level)
6301
+
6262
6302
  def get_effective_level(self) -> LogLevel:
6263
6303
  return self._std.getEffectiveLevel()
6264
6304
 
ominfra/scripts/manage.py CHANGED
@@ -2779,8 +2779,6 @@ class AttrOps(ta.Generic[T]):
2779
2779
  self._eq = _eq
2780
2780
  return _eq
2781
2781
 
2782
- #
2783
-
2784
2782
  @property
2785
2783
  def hash_eq(self) -> ta.Tuple[
2786
2784
  ta.Callable[[T], int],
@@ -2788,6 +2786,8 @@ class AttrOps(ta.Generic[T]):
2788
2786
  ]:
2789
2787
  return (self.hash, self.eq)
2790
2788
 
2789
+ #
2790
+
2791
2791
  @property
2792
2792
  def repr_hash_eq(self) -> ta.Tuple[
2793
2793
  ta.Callable[[T], str],
@@ -2798,20 +2798,25 @@ class AttrOps(ta.Generic[T]):
2798
2798
 
2799
2799
  #
2800
2800
 
2801
+ class NOT_SET: # noqa
2802
+ def __new__(cls, *args, **kwargs): # noqa
2803
+ raise TypeError
2804
+
2801
2805
  def install(
2802
2806
  self,
2803
2807
  locals_dct: ta.MutableMapping[str, ta.Any],
2804
2808
  *,
2805
- all: bool = False, # noqa
2806
- repr: bool = False, # noqa
2807
- hash: bool = False, # noqa
2808
- eq: bool = False,
2809
+ repr: ta.Union[bool, ta.Type[NOT_SET]] = NOT_SET, # noqa
2810
+ hash: ta.Union[bool, ta.Type[NOT_SET]] = NOT_SET, # noqa
2811
+ eq: ta.Union[bool, ta.Type[NOT_SET]] = NOT_SET,
2809
2812
  ) -> 'AttrOps[T]':
2810
- if repr or all:
2813
+ if all(a is self.NOT_SET for a in (repr, hash, eq)):
2814
+ repr = hash = eq = True # noqa
2815
+ if repr:
2811
2816
  locals_dct.update(__repr__=self.repr)
2812
- if hash or all:
2817
+ if hash:
2813
2818
  locals_dct.update(__hash__=self.hash)
2814
- if eq or all:
2819
+ if eq:
2815
2820
  locals_dct.update(__eq__=self.eq)
2816
2821
  return self
2817
2822
 
@@ -4019,8 +4024,8 @@ class LoggingSourceFileInfo(ta.NamedTuple):
4019
4024
  return None
4020
4025
 
4021
4026
  return cls(
4022
- file_name,
4023
- module,
4027
+ file_name=file_name,
4028
+ module=module,
4024
4029
  )
4025
4030
 
4026
4031
 
@@ -4037,9 +4042,9 @@ class LoggingThreadInfo(ta.NamedTuple):
4037
4042
  @classmethod
4038
4043
  def build(cls) -> 'LoggingThreadInfo':
4039
4044
  return cls(
4040
- threading.get_ident(),
4041
- threading.get_native_id() if hasattr(threading, 'get_native_id') else None,
4042
- threading.current_thread().name,
4045
+ ident=threading.get_ident(),
4046
+ native_id=threading.get_native_id() if hasattr(threading, 'get_native_id') else None,
4047
+ name=threading.current_thread().name,
4043
4048
  )
4044
4049
 
4045
4050
 
@@ -4054,7 +4059,7 @@ class LoggingProcessInfo(ta.NamedTuple):
4054
4059
  @classmethod
4055
4060
  def build(cls) -> 'LoggingProcessInfo':
4056
4061
  return cls(
4057
- os.getpid(),
4062
+ pid=os.getpid(),
4058
4063
  )
4059
4064
 
4060
4065
 
@@ -4073,7 +4078,7 @@ class LoggingMultiprocessingInfo(ta.NamedTuple):
4073
4078
  return None
4074
4079
 
4075
4080
  return cls(
4076
- mp.current_process().name,
4081
+ process_name=mp.current_process().name,
4077
4082
  )
4078
4083
 
4079
4084
 
@@ -4100,7 +4105,7 @@ class LoggingAsyncioTaskInfo(ta.NamedTuple):
4100
4105
  return None
4101
4106
 
4102
4107
  return cls(
4103
- task.get_name(), # Always non-None
4108
+ name=task.get_name(), # Always non-None
4104
4109
  )
4105
4110
 
4106
4111
 
@@ -4123,36 +4128,66 @@ class NamedLogLevel(int):
4123
4128
 
4124
4129
  #
4125
4130
 
4126
- @property
4127
- def exact_name(self) -> ta.Optional[str]:
4128
- return self._NAMES_BY_INT.get(self)
4131
+ _CACHE: ta.ClassVar[ta.MutableMapping[int, 'NamedLogLevel']] = {}
4132
+
4133
+ @ta.overload
4134
+ def __new__(cls, name: str, offset: int = 0, /) -> 'NamedLogLevel':
4135
+ ...
4136
+
4137
+ @ta.overload
4138
+ def __new__(cls, i: int, /) -> 'NamedLogLevel':
4139
+ ...
4140
+
4141
+ def __new__(cls, x, offset=0, /):
4142
+ if isinstance(x, str):
4143
+ return cls(cls._INTS_BY_NAME[x.upper()] + offset)
4144
+ elif not offset and (c := cls._CACHE.get(x)) is not None:
4145
+ return c
4146
+ else:
4147
+ return super().__new__(cls, x + offset)
4148
+
4149
+ #
4129
4150
 
4130
- _effective_name: ta.Optional[str]
4151
+ _name_and_offset: ta.Tuple[str, int]
4131
4152
 
4132
4153
  @property
4133
- def effective_name(self) -> ta.Optional[str]:
4154
+ def name_and_offset(self) -> ta.Tuple[str, int]:
4134
4155
  try:
4135
- return self._effective_name
4156
+ return self._name_and_offset
4136
4157
  except AttributeError:
4137
4158
  pass
4138
4159
 
4139
- if (n := self.exact_name) is None:
4160
+ if (n := self._NAMES_BY_INT.get(self)) is not None:
4161
+ t = (n, 0)
4162
+ else:
4140
4163
  for n, i in self._NAME_INT_PAIRS: # noqa
4141
4164
  if self >= i:
4165
+ t = (n, (self - i))
4142
4166
  break
4143
4167
  else:
4144
- n = None
4168
+ t = ('NOTSET', int(self))
4169
+
4170
+ self._name_and_offset = t
4171
+ return t
4145
4172
 
4146
- self._effective_name = n
4173
+ @property
4174
+ def exact_name(self) -> ta.Optional[str]:
4175
+ n, o = self.name_and_offset
4176
+ return n if not o else None
4177
+
4178
+ @property
4179
+ def effective_name(self) -> str:
4180
+ n, _ = self.name_and_offset
4147
4181
  return n
4148
4182
 
4149
4183
  #
4150
4184
 
4151
- def __repr__(self) -> str:
4152
- return f'{self.__class__.__name__}({int(self)})'
4153
-
4154
4185
  def __str__(self) -> str:
4155
- return self.exact_name or f'{self.effective_name or "INVALID"}:{int(self)}'
4186
+ return self.exact_name or f'{self.effective_name}{int(self):+}'
4187
+
4188
+ def __repr__(self) -> str:
4189
+ n, o = self.name_and_offset
4190
+ return f'{self.__class__.__name__}({n!r}{f", {int(o)}" if o else ""})'
4156
4191
 
4157
4192
  #
4158
4193
 
@@ -4172,6 +4207,9 @@ NamedLogLevel.DEBUG = NamedLogLevel(logging.DEBUG)
4172
4207
  NamedLogLevel.NOTSET = NamedLogLevel(logging.NOTSET)
4173
4208
 
4174
4209
 
4210
+ NamedLogLevel._CACHE.update({i: NamedLogLevel(i) for i in NamedLogLevel._NAMES_BY_INT}) # noqa
4211
+
4212
+
4175
4213
  ########################################
4176
4214
  # ../../../omlish/logs/std/filters.py
4177
4215
 
@@ -7646,10 +7684,10 @@ class LoggingCaller(ta.NamedTuple):
7646
7684
  sinfo = sinfo[:-1]
7647
7685
 
7648
7686
  return cls(
7649
- f.f_code.co_filename,
7650
- f.f_lineno or 0,
7651
- f.f_code.co_name,
7652
- sinfo,
7687
+ file_path=f.f_code.co_filename,
7688
+ line_no=f.f_lineno or 0,
7689
+ name=f.f_code.co_name,
7690
+ stack_info=sinfo,
7653
7691
  )
7654
7692
 
7655
7693
 
@@ -7660,6 +7698,7 @@ class LoggingCaller(ta.NamedTuple):
7660
7698
  ##
7661
7699
 
7662
7700
 
7701
+ @ta.runtime_checkable
7663
7702
  class LoggerLike(ta.Protocol):
7664
7703
  """Satisfied by both our Logger and stdlib logging.Logger."""
7665
7704
 
@@ -7798,9 +7837,9 @@ class LoggingTimeFields(ta.NamedTuple):
7798
7837
  relative_created = (time_ns - start_time_ns) / 1e6
7799
7838
 
7800
7839
  return cls(
7801
- created,
7802
- msecs,
7803
- relative_created,
7840
+ created=created,
7841
+ msecs=msecs,
7842
+ relative_created=relative_created,
7804
7843
  )
7805
7844
 
7806
7845
 
@@ -10970,7 +11009,6 @@ class DeploySpec(DeploySpecKeyed[DeployKey]):
10970
11009
 
10971
11010
 
10972
11011
  class AnyLogger(Abstract, ta.Generic[T]):
10973
- @ta.final
10974
11012
  def is_enabled_for(self, level: LogLevel) -> bool:
10975
11013
  return level >= self.get_effective_level()
10976
11014
 
@@ -11169,7 +11207,7 @@ class AsyncLogger(AnyLogger[ta.Awaitable[None]], Abstract):
11169
11207
  class AnyNopLogger(AnyLogger[T], Abstract):
11170
11208
  @ta.final
11171
11209
  def get_effective_level(self) -> LogLevel:
11172
- return 999
11210
+ return -999
11173
11211
 
11174
11212
 
11175
11213
  @ta.final
@@ -12091,7 +12129,7 @@ class SingleDirDeployPathOwner(DeployPathOwner, Abstract):
12091
12129
 
12092
12130
 
12093
12131
  ########################################
12094
- # ../../../omlish/logs/std/adapters.py
12132
+ # ../../../omlish/logs/std/loggers.py
12095
12133
 
12096
12134
 
12097
12135
  ##
@@ -12107,6 +12145,9 @@ class StdLogger(Logger):
12107
12145
  def std(self) -> logging.Logger:
12108
12146
  return self._std
12109
12147
 
12148
+ def is_enabled_for(self, level: LogLevel) -> bool:
12149
+ return self._std.isEnabledFor(level)
12150
+
12110
12151
  def get_effective_level(self) -> LogLevel:
12111
12152
  return self._std.getEffectiveLevel()
12112
12153
 
@@ -2125,8 +2125,6 @@ class AttrOps(ta.Generic[T]):
2125
2125
  self._eq = _eq
2126
2126
  return _eq
2127
2127
 
2128
- #
2129
-
2130
2128
  @property
2131
2129
  def hash_eq(self) -> ta.Tuple[
2132
2130
  ta.Callable[[T], int],
@@ -2134,6 +2132,8 @@ class AttrOps(ta.Generic[T]):
2134
2132
  ]:
2135
2133
  return (self.hash, self.eq)
2136
2134
 
2135
+ #
2136
+
2137
2137
  @property
2138
2138
  def repr_hash_eq(self) -> ta.Tuple[
2139
2139
  ta.Callable[[T], str],
@@ -2144,20 +2144,25 @@ class AttrOps(ta.Generic[T]):
2144
2144
 
2145
2145
  #
2146
2146
 
2147
+ class NOT_SET: # noqa
2148
+ def __new__(cls, *args, **kwargs): # noqa
2149
+ raise TypeError
2150
+
2147
2151
  def install(
2148
2152
  self,
2149
2153
  locals_dct: ta.MutableMapping[str, ta.Any],
2150
2154
  *,
2151
- all: bool = False, # noqa
2152
- repr: bool = False, # noqa
2153
- hash: bool = False, # noqa
2154
- eq: bool = False,
2155
+ repr: ta.Union[bool, ta.Type[NOT_SET]] = NOT_SET, # noqa
2156
+ hash: ta.Union[bool, ta.Type[NOT_SET]] = NOT_SET, # noqa
2157
+ eq: ta.Union[bool, ta.Type[NOT_SET]] = NOT_SET,
2155
2158
  ) -> 'AttrOps[T]':
2156
- if repr or all:
2159
+ if all(a is self.NOT_SET for a in (repr, hash, eq)):
2160
+ repr = hash = eq = True # noqa
2161
+ if repr:
2157
2162
  locals_dct.update(__repr__=self.repr)
2158
- if hash or all:
2163
+ if hash:
2159
2164
  locals_dct.update(__hash__=self.hash)
2160
- if eq or all:
2165
+ if eq:
2161
2166
  locals_dct.update(__eq__=self.eq)
2162
2167
  return self
2163
2168
 
@@ -3102,8 +3107,8 @@ class LoggingSourceFileInfo(ta.NamedTuple):
3102
3107
  return None
3103
3108
 
3104
3109
  return cls(
3105
- file_name,
3106
- module,
3110
+ file_name=file_name,
3111
+ module=module,
3107
3112
  )
3108
3113
 
3109
3114
 
@@ -3120,9 +3125,9 @@ class LoggingThreadInfo(ta.NamedTuple):
3120
3125
  @classmethod
3121
3126
  def build(cls) -> 'LoggingThreadInfo':
3122
3127
  return cls(
3123
- threading.get_ident(),
3124
- threading.get_native_id() if hasattr(threading, 'get_native_id') else None,
3125
- threading.current_thread().name,
3128
+ ident=threading.get_ident(),
3129
+ native_id=threading.get_native_id() if hasattr(threading, 'get_native_id') else None,
3130
+ name=threading.current_thread().name,
3126
3131
  )
3127
3132
 
3128
3133
 
@@ -3137,7 +3142,7 @@ class LoggingProcessInfo(ta.NamedTuple):
3137
3142
  @classmethod
3138
3143
  def build(cls) -> 'LoggingProcessInfo':
3139
3144
  return cls(
3140
- os.getpid(),
3145
+ pid=os.getpid(),
3141
3146
  )
3142
3147
 
3143
3148
 
@@ -3156,7 +3161,7 @@ class LoggingMultiprocessingInfo(ta.NamedTuple):
3156
3161
  return None
3157
3162
 
3158
3163
  return cls(
3159
- mp.current_process().name,
3164
+ process_name=mp.current_process().name,
3160
3165
  )
3161
3166
 
3162
3167
 
@@ -3183,7 +3188,7 @@ class LoggingAsyncioTaskInfo(ta.NamedTuple):
3183
3188
  return None
3184
3189
 
3185
3190
  return cls(
3186
- task.get_name(), # Always non-None
3191
+ name=task.get_name(), # Always non-None
3187
3192
  )
3188
3193
 
3189
3194
 
@@ -3206,36 +3211,66 @@ class NamedLogLevel(int):
3206
3211
 
3207
3212
  #
3208
3213
 
3209
- @property
3210
- def exact_name(self) -> ta.Optional[str]:
3211
- return self._NAMES_BY_INT.get(self)
3214
+ _CACHE: ta.ClassVar[ta.MutableMapping[int, 'NamedLogLevel']] = {}
3215
+
3216
+ @ta.overload
3217
+ def __new__(cls, name: str, offset: int = 0, /) -> 'NamedLogLevel':
3218
+ ...
3219
+
3220
+ @ta.overload
3221
+ def __new__(cls, i: int, /) -> 'NamedLogLevel':
3222
+ ...
3223
+
3224
+ def __new__(cls, x, offset=0, /):
3225
+ if isinstance(x, str):
3226
+ return cls(cls._INTS_BY_NAME[x.upper()] + offset)
3227
+ elif not offset and (c := cls._CACHE.get(x)) is not None:
3228
+ return c
3229
+ else:
3230
+ return super().__new__(cls, x + offset)
3212
3231
 
3213
- _effective_name: ta.Optional[str]
3232
+ #
3233
+
3234
+ _name_and_offset: ta.Tuple[str, int]
3214
3235
 
3215
3236
  @property
3216
- def effective_name(self) -> ta.Optional[str]:
3237
+ def name_and_offset(self) -> ta.Tuple[str, int]:
3217
3238
  try:
3218
- return self._effective_name
3239
+ return self._name_and_offset
3219
3240
  except AttributeError:
3220
3241
  pass
3221
3242
 
3222
- if (n := self.exact_name) is None:
3243
+ if (n := self._NAMES_BY_INT.get(self)) is not None:
3244
+ t = (n, 0)
3245
+ else:
3223
3246
  for n, i in self._NAME_INT_PAIRS: # noqa
3224
3247
  if self >= i:
3248
+ t = (n, (self - i))
3225
3249
  break
3226
3250
  else:
3227
- n = None
3251
+ t = ('NOTSET', int(self))
3252
+
3253
+ self._name_and_offset = t
3254
+ return t
3228
3255
 
3229
- self._effective_name = n
3256
+ @property
3257
+ def exact_name(self) -> ta.Optional[str]:
3258
+ n, o = self.name_and_offset
3259
+ return n if not o else None
3260
+
3261
+ @property
3262
+ def effective_name(self) -> str:
3263
+ n, _ = self.name_and_offset
3230
3264
  return n
3231
3265
 
3232
3266
  #
3233
3267
 
3234
- def __repr__(self) -> str:
3235
- return f'{self.__class__.__name__}({int(self)})'
3236
-
3237
3268
  def __str__(self) -> str:
3238
- return self.exact_name or f'{self.effective_name or "INVALID"}:{int(self)}'
3269
+ return self.exact_name or f'{self.effective_name}{int(self):+}'
3270
+
3271
+ def __repr__(self) -> str:
3272
+ n, o = self.name_and_offset
3273
+ return f'{self.__class__.__name__}({n!r}{f", {int(o)}" if o else ""})'
3239
3274
 
3240
3275
  #
3241
3276
 
@@ -3255,6 +3290,9 @@ NamedLogLevel.DEBUG = NamedLogLevel(logging.DEBUG)
3255
3290
  NamedLogLevel.NOTSET = NamedLogLevel(logging.NOTSET)
3256
3291
 
3257
3292
 
3293
+ NamedLogLevel._CACHE.update({i: NamedLogLevel(i) for i in NamedLogLevel._NAMES_BY_INT}) # noqa
3294
+
3295
+
3258
3296
  ########################################
3259
3297
  # ../../../omlish/logs/std/filters.py
3260
3298
 
@@ -6233,10 +6271,10 @@ class LoggingCaller(ta.NamedTuple):
6233
6271
  sinfo = sinfo[:-1]
6234
6272
 
6235
6273
  return cls(
6236
- f.f_code.co_filename,
6237
- f.f_lineno or 0,
6238
- f.f_code.co_name,
6239
- sinfo,
6274
+ file_path=f.f_code.co_filename,
6275
+ line_no=f.f_lineno or 0,
6276
+ name=f.f_code.co_name,
6277
+ stack_info=sinfo,
6240
6278
  )
6241
6279
 
6242
6280
 
@@ -6247,6 +6285,7 @@ class LoggingCaller(ta.NamedTuple):
6247
6285
  ##
6248
6286
 
6249
6287
 
6288
+ @ta.runtime_checkable
6250
6289
  class LoggerLike(ta.Protocol):
6251
6290
  """Satisfied by both our Logger and stdlib logging.Logger."""
6252
6291
 
@@ -6385,9 +6424,9 @@ class LoggingTimeFields(ta.NamedTuple):
6385
6424
  relative_created = (time_ns - start_time_ns) / 1e6
6386
6425
 
6387
6426
  return cls(
6388
- created,
6389
- msecs,
6390
- relative_created,
6427
+ created=created,
6428
+ msecs=msecs,
6429
+ relative_created=relative_created,
6391
6430
  )
6392
6431
 
6393
6432
 
@@ -9578,7 +9617,6 @@ class CoroHttpServer:
9578
9617
 
9579
9618
 
9580
9619
  class AnyLogger(Abstract, ta.Generic[T]):
9581
- @ta.final
9582
9620
  def is_enabled_for(self, level: LogLevel) -> bool:
9583
9621
  return level >= self.get_effective_level()
9584
9622
 
@@ -9777,7 +9815,7 @@ class AsyncLogger(AnyLogger[ta.Awaitable[None]], Abstract):
9777
9815
  class AnyNopLogger(AnyLogger[T], Abstract):
9778
9816
  @ta.final
9779
9817
  def get_effective_level(self) -> LogLevel:
9780
- return 999
9818
+ return -999
9781
9819
 
9782
9820
 
9783
9821
  @ta.final
@@ -10360,7 +10398,7 @@ class CoroHttpServerConnectionFdioHandler(SocketFdioHandler):
10360
10398
 
10361
10399
 
10362
10400
  ########################################
10363
- # ../../../omlish/logs/std/adapters.py
10401
+ # ../../../omlish/logs/std/loggers.py
10364
10402
 
10365
10403
 
10366
10404
  ##
@@ -10376,6 +10414,9 @@ class StdLogger(Logger):
10376
10414
  def std(self) -> logging.Logger:
10377
10415
  return self._std
10378
10416
 
10417
+ def is_enabled_for(self, level: LogLevel) -> bool:
10418
+ return self._std.isEnabledFor(level)
10419
+
10379
10420
  def get_effective_level(self) -> LogLevel:
10380
10421
  return self._std.getEffectiveLevel()
10381
10422
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ominfra
3
- Version: 0.0.0.dev429
3
+ Version: 0.0.0.dev430
4
4
  Summary: ominfra
5
5
  Author: wrmsr
6
6
  License-Expression: BSD-3-Clause
@@ -14,8 +14,8 @@ Classifier: Programming Language :: Python :: 3.13
14
14
  Requires-Python: >=3.13
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
- Requires-Dist: omdev==0.0.0.dev429
18
- Requires-Dist: omlish==0.0.0.dev429
17
+ Requires-Dist: omdev==0.0.0.dev430
18
+ Requires-Dist: omlish==0.0.0.dev430
19
19
  Provides-Extra: all
20
20
  Requires-Dist: paramiko~=4.0; extra == "all"
21
21
  Requires-Dist: asyncssh~=2.21; extra == "all"
@@ -112,9 +112,9 @@ ominfra/manage/targets/connection.py,sha256=mOHCsDVG-DZBhl3Mb7TTr1vhPb0gxDOOMW1x
112
112
  ominfra/manage/targets/inject.py,sha256=3M4wBkxtvymq_yhiotHlTN8iydELMjVCndyp9Bq-4eo,1572
113
113
  ominfra/manage/targets/targets.py,sha256=LjSQrDsHEjEQMDHcxtNKmLjy0YGLXJRGPFdUjazzFIM,1918
114
114
  ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
115
- ominfra/scripts/journald2aws.py,sha256=PcwfGVueNPjOLOsig6J9phO2BMC7KGhag4mij0YVFFQ,225572
116
- ominfra/scripts/manage.py,sha256=LNPJYbNiIW_sYtXN7_Top02C4ry3-ftE3kOQKb-x9zY,449259
117
- ominfra/scripts/supervisor.py,sha256=Qbn0go8hCer5wO2r5EY-T8pszD33q8NGUIGwbTcOFi8,358998
115
+ ominfra/scripts/journald2aws.py,sha256=KQk5-KwQ3qJ55BUXW5pqErekh3DtX8f0BIxTBcMAm7Y,226969
116
+ ominfra/scripts/manage.py,sha256=3QIvVi1F1RwkYKk7ZIDsLd6VdNastEC2SUSG7kwUUHU,450678
117
+ ominfra/scripts/supervisor.py,sha256=ztxeLtlQCpmelXJYW9wotwTSc0JZBf4FauAnlu4ufV0,360417
118
118
  ominfra/supervisor/LICENSE.txt,sha256=ZrHY15PVR98y26Yg6iQfa-SXnUaYTDhrUsPVcEO5OKM,1874
119
119
  ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
120
120
  ominfra/supervisor/__main__.py,sha256=I0yFw-C08OOiZ3BF6lF1Oiv789EQXu-_j6whDhQUTEA,66
@@ -156,9 +156,9 @@ ominfra/tailscale/api.py,sha256=XASv9C_CWI-u-yX5jVzhJrkJhlwQRkYQWQQG1uJwAd8,1375
156
156
  ominfra/tailscale/cli.py,sha256=zRV7-tKB7kBah1oTVZlol-vwx1FBlnfzYAPGkeU5jX4,3543
157
157
  ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
158
158
  ominfra/tools/listresources.py,sha256=ePmo7cUAiBZARkM_3K4GKYZXxV73An_aioS1m-AAJis,6181
159
- ominfra-0.0.0.dev429.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
160
- ominfra-0.0.0.dev429.dist-info/METADATA,sha256=1aOXl62enLVpevDZyuNFqKG_Y1aLk7pc7SzBYpqiBQE,2377
161
- ominfra-0.0.0.dev429.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
162
- ominfra-0.0.0.dev429.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
163
- ominfra-0.0.0.dev429.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
164
- ominfra-0.0.0.dev429.dist-info/RECORD,,
159
+ ominfra-0.0.0.dev430.dist-info/licenses/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
160
+ ominfra-0.0.0.dev430.dist-info/METADATA,sha256=B2xt-CHjl1EF8ATwYHnpAEuHRSLrtUofFVa-UWDA2KU,2377
161
+ ominfra-0.0.0.dev430.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
162
+ ominfra-0.0.0.dev430.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
163
+ ominfra-0.0.0.dev430.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
164
+ ominfra-0.0.0.dev430.dist-info/RECORD,,