Rewrite for loops in a more Pythonic style

This commit is contained in:
Maciej Delmanowski 2015-07-25 18:22:31 +02:00
parent 055a31ba07
commit d8b6dd5927

View file

@ -215,14 +215,12 @@ class LibvirtConnection(object):
results = [] results = []
# Get active entries # Get active entries
entries = self.conn.listStoragePools() for name in self.conn.listStoragePools():
for name in entries:
entry = self.conn.storagePoolLookupByName(name) entry = self.conn.storagePoolLookupByName(name)
results.append(entry) results.append(entry)
# Get inactive entries # Get inactive entries
entries = self.conn.listDefinedStoragePools() for name in self.conn.listDefinedStoragePools():
for name in entries:
entry = self.conn.storagePoolLookupByName(name) entry = self.conn.storagePoolLookupByName(name)
results.append(entry) results.append(entry)
@ -422,9 +420,8 @@ class VirtStoragePool(object):
return results return results
def state(self): def state(self):
entries = self.list_pools()
results = [] results = []
for entry in entries: for entry in self.list_pools():
state_blurb = self.conn.get_status(entry) state_blurb = self.conn.get_status(entry)
results.append("%s %s" % (entry,state_blurb)) results.append("%s %s" % (entry,state_blurb))
return results return results
@ -475,9 +472,8 @@ class VirtStoragePool(object):
return self.facts(facts_mode) return self.facts(facts_mode)
def facts(self, facts_mode='facts'): def facts(self, facts_mode='facts'):
entries = self.list_pools()
results = dict() results = dict()
for entry in entries: for entry in self.list_pools():
results[entry] = dict() results[entry] = dict()
if self.conn.find_entry(entry): if self.conn.find_entry(entry):
data = self.conn.get_info(entry) data = self.conn.get_info(entry)