From 1f65953090d3025154ce37f1184a884a47730d6d Mon Sep 17 00:00:00 2001 From: Maciej Delmanowski Date: Sat, 25 Jul 2015 18:14:03 +0200 Subject: [PATCH] Rewrite for loops in a more Pythonic style --- lib/ansible/modules/extras/cloud/misc/virt_net.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/misc/virt_net.py b/lib/ansible/modules/extras/cloud/misc/virt_net.py index cd579a3f785..3622d455e48 100644 --- a/lib/ansible/modules/extras/cloud/misc/virt_net.py +++ b/lib/ansible/modules/extras/cloud/misc/virt_net.py @@ -177,14 +177,12 @@ class LibvirtConnection(object): results = [] # Get active entries - entries = self.conn.listNetworks() - for name in entries: + for name in self.conn.listNetworks(): entry = self.conn.networkLookupByName(name) results.append(entry) # Get inactive entries - entries = self.conn.listDefinedNetworks() - for name in entries: + for name in self.conn.listDefinedNetworks(): entry = self.conn.networkLookupByName(name) results.append(entry) @@ -334,9 +332,8 @@ class VirtNetwork(object): return results def state(self): - entries = self.list_nets() results = [] - for entry in entries: + for entry in self.list_nets(): state_blurb = self.conn.get_status(entry) results.append("%s %s" % (entry,state_blurb)) return results @@ -378,9 +375,8 @@ class VirtNetwork(object): return self.facts(facts_mode) def facts(self, facts_mode='facts'): - entries = self.list_nets() results = dict() - for entry in entries: + for entry in self.list_nets(): results[entry] = dict() results[entry]["autostart"] = self.conn.get_autostart(entry) results[entry]["persistent"] = self.conn.get_persistent(entry)