Improve coding style
authorMikael Berthe <mikael@lilotux.net>
Tue, 01 May 2007 19:09:31 +0200
changeset 10 7de2fee2986f
parent 9 05f3731b8733
child 11 024fa3e33982
Improve coding style Thanks to Loic.
plugins/wtf_plugin.py
--- a/plugins/wtf_plugin.py	Tue May 01 19:08:47 2007 +0200
+++ b/plugins/wtf_plugin.py	Tue May 01 19:09:31 2007 +0200
@@ -5,29 +5,23 @@
 WTF_FILE = 'static/wtf.txt'
 
 def handler_wtf(type, source, parameters):
-	parameters = parameters.rstrip()
+	parameters = parameters.rstrip(" ?\n")
 	parameters = parameters.lstrip()
-
-	if parameters == '':
-		smsg(type, source, "Gimme an acronym!")
-		return;
-
-	#acronyms = open(WTF_FILE, 'r').readlines()
-
-	word = string.upper(parameters)+"\t"
+	word = parameters.upper() + "\t"
 	reply = ""
 
-	reader = open(WTF_FILE,'r')
-	while 1:
-		line = reader.readline()
-		if not line:
-			break
+	if not parameters:
+		smsg(type, source, "Gimme an acronym!")
+		return
+
+	for line in file(WTF_FILE):
 		if line.startswith(word):
-			reply = reply + re.sub("\t+", ": ", line)
+			reply += re.sub("\t+", ": ", line)
 
 	if not reply:
-		reply = "Sorry, I don't know what "+parameters+" means..."
+		reply = "Sorry, I don't know what " + parameters + " means..."
 
 	smsg(type, source, reply.rstrip())
 
-register_command_handler(handler_wtf, 'wtf', 0, 'Translates acronyms for you', 'wtf', ['wtf wtf'])
+register_command_handler(handler_wtf, 'wtf', 0,
+                         'Translates acronyms for you', 'wtf', ['wtf wtf'])