qubes/vm: fixed __repr__ for BaseVM
Previously it could fail with AttributeError when any of the properties was unset.
This commit is contained in:
parent
ef4f00dac0
commit
f149c7b59b
@ -285,11 +285,16 @@ class BaseVM(qubes.PropertyHolder):
|
|||||||
return element
|
return element
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<{} object at {:#x} {}>'.format(
|
proprepr = []
|
||||||
self.__class__.__name__, id(self),
|
for prop in self.get_props_list():
|
||||||
' '.join('{}={}'.format(prop.__name__, getattr(self, prop.__name__))
|
try:
|
||||||
for prop in self.get_props_list()))
|
proprepr.append('{}={!r}'.format(
|
||||||
|
prop.__name__, getattr(self, prop.__name__)))
|
||||||
|
except AttributeError:
|
||||||
|
continue
|
||||||
|
|
||||||
|
return '<{} object at {:#x} {}>'.format(
|
||||||
|
self.__class__.__name__, id(self), ' '.join(proprepr))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_hook(cls, event, f):
|
def add_hook(cls, event, f):
|
||||||
|
Loading…
Reference in New Issue
Block a user