From 016d04b3c4e8b1861bd516ef447603b686114efd Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 3 Sep 2009 18:15:50 +0200 Subject: [PATCH] Even more style fixes Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Luca Bigliardi <shammash@google.com> --- lib/hypervisor/hv_xen.py | 22 +++++++++++----------- lib/objects.py | 9 ++++----- lib/utils.py | 2 ++ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index 552ff2f41..e26646142 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -493,19 +493,19 @@ class XenHvmHypervisor(XenHypervisor): PARAMETERS = { constants.HV_ACPI: hv_base.NO_CHECK, - constants.HV_BOOT_ORDER: (True, ) + \ - (lambda x: x and len(x.strip("acdn")) == 0, - "Invalid boot order specified, must be one or more of [acdn]", - None, None), + constants.HV_BOOT_ORDER: (True, ) + + (lambda x: x and len(x.strip("acdn")) == 0, + "Invalid boot order specified, must be one or more of [acdn]", + None, None), constants.HV_CDROM_IMAGE_PATH: hv_base.OPT_FILE_CHECK, - constants.HV_DISK_TYPE: \ - hv_base.ParamInSet(True, constants.HT_HVM_VALID_DISK_TYPES), - constants.HV_NIC_TYPE: \ - hv_base.ParamInSet(True, constants.HT_HVM_VALID_NIC_TYPES), + constants.HV_DISK_TYPE: + hv_base.ParamInSet(True, constants.HT_HVM_VALID_DISK_TYPES), + constants.HV_NIC_TYPE: + hv_base.ParamInSet(True, constants.HT_HVM_VALID_NIC_TYPES), constants.HV_PAE: hv_base.NO_CHECK, - constants.HV_VNC_BIND_ADDRESS: \ - (False, utils.IsValidIP, - "VNC bind address is not a valid IP address", None, None), + constants.HV_VNC_BIND_ADDRESS: + (False, utils.IsValidIP, + "VNC bind address is not a valid IP address", None, None), constants.HV_KERNEL_PATH: hv_base.REQ_FILE_CHECK, constants.HV_DEVICE_MODEL: hv_base.REQ_FILE_CHECK, } diff --git a/lib/objects.py b/lib/objects.py index 9e098ddee..e2154db17 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -285,8 +285,8 @@ class TaggableObject(ConfigObject): class ConfigData(ConfigObject): """Top-level config object.""" - __slots__ = ["version", "cluster", "nodes", "instances", "serial_no"] + \ - _TIMESTAMPS + __slots__ = (["version", "cluster", "nodes", "instances", "serial_no"] + + _TIMESTAMPS) def ToDict(self): """Custom function for top-level config data. @@ -828,12 +828,11 @@ class Cluster(TaggableObject): # default_hypervisor is just the first enabled one in 2.1 if self.default_hypervisor is not None: - self.enabled_hypervisors = [self.default_hypervisor] + \ + self.enabled_hypervisors = ([self.default_hypervisor] + [hvname for hvname in self.enabled_hypervisors - if hvname != self.default_hypervisor] + if hvname != self.default_hypervisor]) self.default_hypervisor = None - def ToDict(self): """Custom function for cluster. diff --git a/lib/utils.py b/lib/utils.py index 1e78b7ff4..07be8c04f 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -1767,6 +1767,7 @@ def SetupLogging(logfile, debug=False, stderr_logging=False, program="", # we need to re-raise the exception raise + def IsNormAbsPath(path): """Check whether a path is absolute and also normalized @@ -1775,6 +1776,7 @@ def IsNormAbsPath(path): """ return os.path.normpath(path) == path and os.path.isabs(path) + def TailFile(fname, lines=20): """Return the last lines from a file. -- GitLab