diff --git a/qubes/tools/qvm_ls.py b/qubes/tools/qvm_ls.py index 533836de..f5f6257e 100644 --- a/qubes/tools/qvm_ls.py +++ b/qubes/tools/qvm_ls.py @@ -99,7 +99,7 @@ class Column(object): Return value to put in a table cell. :param qubes.vm.qubesvm.QubesVM: Domain to get a value from. - :returns: Value to put, or :py:obj:`None` if no value . + :returns: Value to put, or :py:obj:`None` if no value. :rtype: str or None ''' @@ -185,23 +185,11 @@ class PropertyColumn(Column): super(PropertyColumn, self).__init__( head=holder.ls_head, width=holder.ls_width, + attr=holder.__name__, + fmt=getattr(holder, 'ls_fmt', None), doc=holder.__doc__) self.holder = holder - def format(self, vm): - try: - value = getattr(vm, self.holder.__name__) - except AttributeError: - return None - - if not hasattr(self.holder, 'ls_fmt') or self.holder.ls_fmt is None: - return value - - return self.holder.ls_fmt.format( - getattr(vm, self.holder.__name__)).ljust( - self.ls_width) - - def __repr__(self): return '{}(head={!r}, width={!r} holder={!r})'.format( self.__class__.__name__, @@ -409,10 +397,6 @@ class StatusColumn(Column): # todo maxmem -Column('LABEL', width=14, - attr='label.name', - doc='Colour of the label.') - Column('GATEWAY', width=15, attr='netvm.gateway', doc='Network gateway.') diff --git a/qubes/vm/qubesvm.py b/qubes/vm/qubesvm.py index 0fd68894..2852c7d8 100644 --- a/qubes/vm/qubesvm.py +++ b/qubes/vm/qubesvm.py @@ -138,6 +138,7 @@ class QubesVM(qubes.vm.BaseVM): label = qubes.property('label', setter=_setter_label, saver=(lambda self, prop, value: 'label-{}'.format(value.index)), + ls_width=14, doc='''Colourful label assigned to VM. This is where the colour of the padlock is set.''')