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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
  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

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list



[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux