fence-agents: master - [cleanup] Replace map/filter by list comprehensions

Marek GrĂ¡c marx at fedoraproject.org
Wed Apr 16 13:05:14 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=756796d3ab7a9a9933a7ebca2c6b0259a7a7ab9c
Commit:        756796d3ab7a9a9933a7ebca2c6b0259a7a7ab9c
Parent:        92928f5fd7f90805df98d46311a6e99e17ae0fd9
Author:        Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate:    Wed Apr 16 14:50:24 2014 +0200
Committer:     Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Wed Apr 16 14:50:24 2014 +0200

[cleanup] Replace map/filter by list comprehensions

---
 fence/agents/cisco_mds/fence_cisco_mds.py |    2 +-
 fence/agents/ifmib/fence_ifmib.py         |    2 +-
 fence/agents/lib/fencing.py.py            |    2 +-
 fence/agents/lib/fencing_snmp.py.py       |    4 ++--
 fence/agents/wti/fence_wti.py             |    2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py
index 84adee2..0508f90 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -54,7 +54,7 @@ def set_power_status(conn, options):
 # Convert array of format [[key1, value1], [key2, value2], ... [keyN, valueN]] to dict, where key is
 # in format a.b.c.d...z and returned dict has key only z
 def array_to_dict(ar):
-	return dict(map(lambda y:[y[0].split('.')[-1], y[1]], ar))
+	return dict([[x[0].split(".")[-1], x[1]] for x in ar])
 
 def get_outlets_status(conn, options):
 	result = {}
diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py
index f8beaa5..c477ba2 100644
--- a/fence/agents/ifmib/fence_ifmib.py
+++ b/fence/agents/ifmib/fence_ifmib.py
@@ -77,7 +77,7 @@ def set_power_status(conn, options):
 # Convert array of format [[key1, value1], [key2, value2], ... [keyN, valueN]] to dict, where key is
 # in format a.b.c.d...z and returned dict has key only z
 def array_to_dict(ar):
-	return dict(map(lambda y:[y[0].split('.')[-1], y[1]], ar))
+	return dict([[x[0].split(".")[-1], x[1]] for x in ar])
 
 def get_outlets_status(conn, options):
 	result = {}
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 31155ac..a37cd0d 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -762,7 +762,7 @@ def check_input(device_opt, opt):
 	for opt in device_opt:
 		if all_opt[opt].has_key("choices"):
 			longopt = "--" + all_opt[opt]["longopt"]
-			possible_values_upper = map (lambda y : y.upper(), all_opt[opt]["choices"])
+			possible_values_upper = [y.upper() for y in all_opt[opt]["choices"]]
 			if options.has_key(longopt):
 				options[longopt] = options[longopt].upper()
 				if not options["--" + all_opt[opt]["longopt"]] in possible_values_upper:
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index 9ebdcbc..055c8f2 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -25,7 +25,7 @@ class FencingSnmp:
 		logging.debug("%s\n" % message)
 
 	def quote_for_run(self, string):
-		return ''.join(map(lambda x:x==r"'" and "'\\''" or x, string))
+		return string.replace(r"'", "'\\''")
 
 	def complete_missed_params(self):
 		mapping = [[
@@ -134,4 +134,4 @@ class FencingSnmp:
 
 		output = self.run_command(cmd, additional_timemout).splitlines()
 
-		return map(lambda x:x.split(None, 1), filter(lambda y:len(y)>0 and y[0]=='.', output))
+		return [ x.split(None,1) for x in output if x.startswith(".") ]
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 9d49854..d502a0e 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -212,7 +212,7 @@ is running because the connection will block any necessary fencing actions."
 			conn.send("open %s -%s\n"%(options["--ip"], options["--ipport"]))
 
 			re_login = re.compile("(login: )|(Login Name:  )|(username: )|(User Name :)", re.IGNORECASE)
-			re_prompt = re.compile("|".join(map (lambda x: "(" + x + ")", options["--command-prompt"])), re.IGNORECASE)
+			re_prompt = re.compile("|".join(["(" + x + ")" for x in options["--command-prompt"]]), re.IGNORECASE)
 
 			result = conn.log_expect(options, [ re_login, "Password: ", re_prompt ], int(options["--shell-timeout"]))
 			if result == 0:


More information about the cluster-commits mailing list