File tree 2 files changed +24
-3
lines changed
2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 13
13
if TYPE_CHECKING :
14
14
from typing_extensions import Protocol
15
15
16
+ from libtmux .neo import ListExtraArgs
17
+
16
18
class LookupProtocol (Protocol ):
17
19
"""Protocol for :class:`QueryList` filtering operators."""
18
20
@@ -37,6 +39,21 @@ class MultipleObjectsReturned(Exception):
37
39
class ObjectDoesNotExist (Exception ):
38
40
"""The query returned multiple objects when only one was expected."""
39
41
42
+ def __init__ (
43
+ self ,
44
+ obj_key : Optional [str ] = None ,
45
+ obj_id : Optional [str ] = None ,
46
+ list_cmd : Optional [str ] = None ,
47
+ list_extra_args : "Optional[ListExtraArgs]" = None ,
48
+ * args : object ,
49
+ ):
50
+ if all (arg is not None for arg in [obj_key , obj_id , list_cmd , list_extra_args ]):
51
+ return super ().__init__ (
52
+ f"Could not find { obj_key } ={ obj_id } for { list_cmd } "
53
+ f'{ list_extra_args if list_extra_args is not None else "" } '
54
+ )
55
+ return super ().__init__ ("Could not find object" )
56
+
40
57
41
58
def keygetter (
42
59
obj : "Mapping[str, Any]" ,
Original file line number Diff line number Diff line change @@ -179,7 +179,9 @@ def _refresh(
179
179
180
180
181
181
def fetch_objs (
182
- server : "Server" , list_cmd : "ListCmd" , list_extra_args : "t.Optional[ListExtraArgs]" = None
182
+ server : "Server" ,
183
+ list_cmd : "ListCmd" ,
184
+ list_extra_args : "t.Optional[ListExtraArgs]" = None ,
183
185
) -> OutputsRaw :
184
186
formats = list (Obj .__dataclass_fields__ .keys ())
185
187
@@ -239,8 +241,10 @@ def fetch_obj(
239
241
240
242
if obj is None :
241
243
raise ObjectDoesNotExist (
242
- f"Could not find { obj_key } ={ obj_id } for { list_cmd } "
243
- f'{ list_extra_args if list_extra_args is not None else "" } '
244
+ obj_key = obj_key ,
245
+ obj_id = obj_id ,
246
+ list_cmd = list_cmd ,
247
+ list_extra_args = list_extra_args ,
244
248
)
245
249
246
250
assert obj is not None
You can’t perform that action at this time.
0 commit comments