Improve coding style
Thanks to Loic.
--- 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'])