mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 19:52:54 +01:00
Made <number> optional in convert.
This commit is contained in:
parent
65b87f822c
commit
8914543d35
@ -212,13 +212,17 @@ class Math(callbacks.Privmsg):
|
|||||||
if isinstance(v, unum.Unum):
|
if isinstance(v, unum.Unum):
|
||||||
_convertEnv[k.lower()] = v
|
_convertEnv[k.lower()] = v
|
||||||
def convert(self, irc, msg, args):
|
def convert(self, irc, msg, args):
|
||||||
"""<number> <units> to <other units>
|
"""[<number>] <units> to <other units>
|
||||||
|
|
||||||
Converts the first number of <units> to the <other units>. Valid units
|
Converts the first number of <units> to the <other units>. Valid units
|
||||||
expressions include the standard Python math operators applied to valid
|
expressions include the standard Python math operators applied to valid
|
||||||
units.
|
units. If <number> isn't given, it defaults to 1.
|
||||||
"""
|
"""
|
||||||
(n, unit1, to, unit2) = privmsgs.getArgs(args, needed=4)
|
if args and args[0].isdigit():
|
||||||
|
n = args.pop(0)
|
||||||
|
else:
|
||||||
|
n = 1
|
||||||
|
(unit1, to, unit2) = privmsgs.getArgs(args, needed=3)
|
||||||
if to != 'to':
|
if to != 'to':
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
try:
|
try:
|
||||||
|
@ -62,6 +62,7 @@ class MathTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
|
|
||||||
def testConvert(self):
|
def testConvert(self):
|
||||||
self.assertResponse('convert 1 m to cm', '100.0 cm')
|
self.assertResponse('convert 1 m to cm', '100.0 cm')
|
||||||
|
self.assertResponse('convert m to cm', '100.0 cm')
|
||||||
self.assertResponse('convert 1 M to cm', '100.0 cm')
|
self.assertResponse('convert 1 M to cm', '100.0 cm')
|
||||||
self.assertResponse('convert 1 m to CM', '100.0 cm')
|
self.assertResponse('convert 1 m to CM', '100.0 cm')
|
||||||
self.assertResponse('convert 1 m to cM', '100.0 cm')
|
self.assertResponse('convert 1 m to cM', '100.0 cm')
|
||||||
|
Loading…
Reference in New Issue
Block a user