improvements to calc module

* .wa output cleanup (remove ugly html entities in places)
* add some more test cases
This commit is contained in:
mutantmonkey
2013-11-17 12:37:14 -08:00
parent d692a5271b
commit c3815c9cfe
2 changed files with 26 additions and 12 deletions

View File

@@ -11,20 +11,13 @@ http://inamidst.com/phenny/
import re
import web
r_result = re.compile(r'(?i)<A NAME=results>(.*?)</A>')
r_tag = re.compile(r'<\S+.*?>')
subs = [
(' in ', ' -> '),
(' over ', ' / '),
('£', 'GBP '),
('', 'EUR '),
('\$', 'USD '),
(r'\bKB\b', 'kilobytes'),
(r'\bMB\b', 'megabytes'),
(r'\bGB\b', 'kilobytes'),
('kbps', '(kilobits / second)'),
('mbps', '(megabits / second)')
(r'\n', '; '),
('&deg;', '°'),
(r'\/', '/'),
]
@@ -70,7 +63,9 @@ def wa(phenny, input):
return
answer = answers[1]
answer = answer.replace('\\n', ', ')
for sub in subs:
answer = answer.replace(sub[0], sub[1])
phenny.say(answer)
wa.commands = ['wa']