[virt-tools-list] [PATCH virt-manager 10/14] domain: os: use decorator syntax for declaring properties

Cole Robinson crobinso at redhat.com
Mon Jan 7 20:44:04 UTC 2019


On 12/18/2018 08:44 AM, Marc Hartmayer wrote:
> This makes it's easier to understand the code.
> 
> Signed-off-by: Marc Hartmayer <mhartmay at linux.ibm.com>
> Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
> ---
>   virtinst/domain/os.py | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/virtinst/domain/os.py b/virtinst/domain/os.py
> index c6e49f80a432..d0a73f63dfbd 100644
> --- a/virtinst/domain/os.py
> +++ b/virtinst/domain/os.py
> @@ -67,17 +67,20 @@ class DomainOs(XMLBuilder):
>                          "nvram", "nvram_template", "kernel", "initrd",
>                          "kernel_args", "dtb", "_bootdevs", "smbios_mode"]
>   
> -    def _get_bootorder(self):
> +    _bootdevs = XMLChildProperty(_BootDevice)
> +
> +    @property
> +    def bootorder(self):
>           return [dev.dev for dev in self._bootdevs]
> -    def _set_bootorder(self, newdevs):
> +
> +    @bootorder.setter
> +    def bootorder(self, newdevs):
>           for dev in self._bootdevs:
>               self.remove_child(dev)
>   
>           for d in newdevs:
>               dev = self._bootdevs.add_new()
>               dev.dev = d
> -    _bootdevs = XMLChildProperty(_BootDevice)
> -    bootorder = property(_get_bootorder, _set_bootorder)
>   
>       initargs = XMLChildProperty(_InitArg)
>       def set_initargs_string(self, argstring):
> 

Eh I know this is more typical python convention but I certainly don't 
find it more readable. Plus we have 0 usages of property.setter in the 
code and 50+ usages of property(), so I'm skipping this patch

Thanks,
Cole




More information about the virt-tools-list mailing list