Any() and All() don't short-circuit.
This commit is contained in:
parent
ded39c6a2f
commit
d9ae742a55
@ -351,9 +351,9 @@ class MySQLUser(Base):
|
||||
self._databases = []
|
||||
|
||||
def _is_valid(self, value):
|
||||
if any([not value,
|
||||
self.not_supported_chars.search(value),
|
||||
string.find("%r" % value, "\\") != -1]):
|
||||
if (not value or
|
||||
self.not_supported_chars.search(value) or
|
||||
string.find("%r" % value, "\\") != -1):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@ -212,9 +212,9 @@ class MySqlAppStatus(object):
|
||||
True if MySQL app should be installed and attempts to ascertain
|
||||
its status won't result in nonsense.
|
||||
"""
|
||||
return all([self.status is not None,
|
||||
self.status != rd_models.ServiceStatuses.BUILDING,
|
||||
self.status != rd_models.ServiceStatuses.FAILED])
|
||||
return (self.status is not None and
|
||||
self.status != rd_models.ServiceStatuses.BUILDING and
|
||||
self.status != rd_models.ServiceStatuses.FAILED)
|
||||
|
||||
@property
|
||||
def _is_mysql_restarting(self):
|
||||
|
@ -481,9 +481,9 @@ class Instance(BuiltInstance):
|
||||
"""
|
||||
Raises exception if an instance action cannot currently be performed.
|
||||
"""
|
||||
if any([self.db_info.server_status != "ACTIVE",
|
||||
self.db_info.task_status != InstanceTasks.NONE,
|
||||
not self.service_status.status.action_is_allowed]):
|
||||
if (self.db_info.server_status != "ACTIVE" or
|
||||
self.db_info.task_status != InstanceTasks.NONE or
|
||||
not self.service_status.status.action_is_allowed):
|
||||
msg = ("Instance is not currently available for an action to be "
|
||||
"performed (status was %s).")
|
||||
LOG.error(msg % self.status)
|
||||
|
@ -25,13 +25,13 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_ip_address(addresses):
|
||||
if all([addresses is not None,
|
||||
addresses.get('private') is not None,
|
||||
len(addresses['private']) > 0]):
|
||||
if (addresses is not None and
|
||||
addresses.get('private') is not None and
|
||||
len(addresses['private']) > 0):
|
||||
return [addr.get('addr') for addr in addresses['private']]
|
||||
if all([addresses is not None,
|
||||
addresses.get('usernet') is not None,
|
||||
len(addresses['usernet']) > 0]):
|
||||
if (addresses is not None and
|
||||
addresses.get('usernet') is not None and
|
||||
len(addresses['usernet']) > 0):
|
||||
return [addr.get('addr') for addr in addresses['usernet']]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user