@@ -134,7 +134,7 @@ def pack_property(cls, key: str, value: Optional[str]):
134
134
135
135
@staticmethod
136
136
def parse_basic_device_properties (
137
- expected_device : 'Device ' , properties : Dict [str , Any ]):
137
+ expected_device : 'VirtualDevice ' , properties : Dict [str , Any ]):
138
138
"""
139
139
Validates properties against an expected port configuration.
140
140
@@ -318,7 +318,7 @@ def devclass(self) -> str:
318
318
return "peripheral"
319
319
320
320
321
- class Device :
321
+ class VirtualDevice :
322
322
def __init__ (
323
323
self ,
324
324
port : Optional [Port ] = None ,
@@ -376,7 +376,7 @@ def __hash__(self):
376
376
return hash ((self .port , self .device_id ))
377
377
378
378
def __eq__ (self , other ):
379
- if isinstance (other , (Device , DeviceAssignment )):
379
+ if isinstance (other , (VirtualDevice , DeviceAssignment )):
380
380
result = (
381
381
self .port == other .port
382
382
and self .device_id == other .device_id
@@ -398,7 +398,7 @@ def __lt__(self, other):
398
398
3. *:<devid>
399
399
4. *:*
400
400
"""
401
- if isinstance (other , (Device , DeviceAssignment )):
401
+ if isinstance (other , (VirtualDevice , DeviceAssignment )):
402
402
if self .port == '*' and other .port != '*' :
403
403
return True
404
404
if self .port != '*' and other .port == '*' :
@@ -409,7 +409,7 @@ def __lt__(self, other):
409
409
reprs [obj ].append (obj .device_id )
410
410
return reprs [self ] < reprs [other ]
411
411
elif isinstance (other , Port ):
412
- _other = Device (other , '*' )
412
+ _other = VirtualDevice (other , '*' )
413
413
return self < _other
414
414
else :
415
415
raise TypeError (
@@ -430,7 +430,7 @@ def from_qarg(
430
430
domains ,
431
431
blind = False ,
432
432
backend = None ,
433
- ) -> 'Device ' :
433
+ ) -> 'VirtualDevice ' :
434
434
if backend is None :
435
435
if blind :
436
436
get_domain = domains .get_blind
@@ -444,7 +444,7 @@ def from_qarg(
444
444
def from_str (
445
445
cls , representation : str , devclass : Optional [str ], domains ,
446
446
blind = False , backend = None
447
- ) -> 'Device ' :
447
+ ) -> 'VirtualDevice ' :
448
448
if backend is None :
449
449
if blind :
450
450
get_domain = domains .get_blind
@@ -462,7 +462,7 @@ def _parse(
462
462
get_domain : Callable ,
463
463
backend ,
464
464
sep : str
465
- ) -> 'Device ' :
465
+ ) -> 'VirtualDevice ' :
466
466
if backend is None :
467
467
backend_name , identity = representation .split (sep , 1 )
468
468
backend = get_domain (backend_name )
@@ -673,7 +673,7 @@ def _load_classes(bus: str):
673
673
return result
674
674
675
675
676
- class DeviceInfo (Device ):
676
+ class DeviceInfo (VirtualDevice ):
677
677
""" Holds all information about a device """
678
678
679
679
def __init__ (
@@ -813,7 +813,7 @@ def interfaces(self) -> List[DeviceInterface]:
813
813
return self ._interfaces
814
814
815
815
@property
816
- def parent_device (self ) -> Optional [Device ]:
816
+ def parent_device (self ) -> Optional [VirtualDevice ]:
817
817
"""
818
818
The parent device, if any.
819
819
@@ -823,7 +823,7 @@ def parent_device(self) -> Optional[Device]:
823
823
return self ._parent
824
824
825
825
@property
826
- def subdevices (self ) -> List [Device ]:
826
+ def subdevices (self ) -> List [VirtualDevice ]:
827
827
"""
828
828
The list of children devices if any.
829
829
@@ -844,7 +844,7 @@ def serialize(self) -> bytes:
844
844
"""
845
845
Serialize an object to be transmitted via Qubes API.
846
846
"""
847
- properties = Device .serialize (self )
847
+ properties = VirtualDevice .serialize (self )
848
848
# 'attachment', 'interfaces', 'data', 'parent_device'
849
849
# are not string, so they need special treatment
850
850
default = DeviceInfo (self .port )
@@ -884,7 +884,7 @@ def deserialize(
884
884
Recovers a serialized object, see: :py:meth:`serialize`.
885
885
"""
886
886
head , _ , rest = serialization .partition (b' ' )
887
- device = Device .from_str (
887
+ device = VirtualDevice .from_str (
888
888
head .decode ('ascii' , errors = 'ignore' ), expected_devclass ,
889
889
domains = None , backend = expected_backend_domain )
890
890
@@ -900,7 +900,7 @@ def deserialize(
900
900
def _deserialize (
901
901
cls ,
902
902
untrusted_serialization : bytes ,
903
- expected_device : Device
903
+ expected_device : VirtualDevice
904
904
) -> 'DeviceInfo' :
905
905
"""
906
906
Actually deserializes the object.
@@ -1000,13 +1000,13 @@ class DeviceAssignment:
1000
1000
1001
1001
def __init__ (
1002
1002
self ,
1003
- device : Device ,
1003
+ device : VirtualDevice ,
1004
1004
frontend_domain = None ,
1005
1005
options = None ,
1006
1006
mode : Union [str , AssignmentMode ] = "manual" ,
1007
1007
):
1008
1008
if isinstance (device , DeviceInfo ):
1009
- device = Device (device .port , device .device_id )
1009
+ device = VirtualDevice (device .port , device .device_id )
1010
1010
self ._device_ident = device
1011
1011
self .__options = options or {}
1012
1012
if isinstance (mode , AssignmentMode ):
@@ -1020,7 +1020,7 @@ def clone(self, **kwargs):
1020
1020
Clone object and substitute attributes with explicitly given.
1021
1021
"""
1022
1022
kwargs ["device" ] = kwargs .get (
1023
- "device" , Device (
1023
+ "device" , VirtualDevice (
1024
1024
Port (self .backend_domain , self .port_id , self .devclass ),
1025
1025
self .device_id
1026
1026
))
@@ -1042,7 +1042,7 @@ def __hash__(self):
1042
1042
return hash (self ._device_ident )
1043
1043
1044
1044
def __eq__ (self , other ):
1045
- if isinstance (other , (Device , DeviceAssignment )):
1045
+ if isinstance (other , (VirtualDevice , DeviceAssignment )):
1046
1046
result = (
1047
1047
self .port == other .port
1048
1048
and self .device_id == other .device_id
@@ -1053,7 +1053,7 @@ def __eq__(self, other):
1053
1053
def __lt__ (self , other ):
1054
1054
if isinstance (other , DeviceAssignment ):
1055
1055
return self ._device_ident < other ._device_ident
1056
- if isinstance (other , Device ):
1056
+ if isinstance (other , VirtualDevice ):
1057
1057
return self ._device_ident < other
1058
1058
raise TypeError (
1059
1059
f"Comparing instances of { type (self )} and '{ type (other )} ' "
@@ -1078,7 +1078,8 @@ def device_id(self):
1078
1078
@property
1079
1079
def device (self ) -> DeviceInfo :
1080
1080
"""Get DeviceInfo object corresponding to this DeviceAssignment"""
1081
- dev = self .backend_domain .devices [self .devclass ][self .port_id ]
1081
+ if self .port_id :
1082
+ dev = self .backend_domain .devices [self .devclass ][self .port_id ]
1082
1083
# TODO: device identity could not match
1083
1084
return dev
1084
1085
@@ -1162,7 +1163,7 @@ def serialize(self) -> bytes:
1162
1163
def deserialize (
1163
1164
cls ,
1164
1165
serialization : bytes ,
1165
- expected_device : Device ,
1166
+ expected_device : VirtualDevice ,
1166
1167
) -> 'DeviceAssignment' :
1167
1168
"""
1168
1169
Recovers a serialized object, see: :py:meth:`serialize`.
@@ -1177,7 +1178,7 @@ def deserialize(
1177
1178
def _deserialize (
1178
1179
cls ,
1179
1180
untrusted_serialization : bytes ,
1180
- expected_device : Device ,
1181
+ expected_device : VirtualDevice ,
1181
1182
) -> 'DeviceAssignment' :
1182
1183
"""
1183
1184
Actually deserializes the object.
0 commit comments