Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'twelve, zero')
self.assertEqual(numwords('120', group=2, zero='oh', one='unity'),
'twelve, oh')
# TODO: ignoring 'one' param with group=2
self.TODO(numwords('101', group=2, zero='oh', one='unity'),
'ten, unity',
'ten, one')
self.assertEqual(numwords('555_1202', group=1, zero='oh'),
'five, five, five, one, two, oh, two')
self.assertEqual(numwords('555_1202', group=1, one='unity'),
'five, five, five, unity, two, zero, two')
self.assertEqual(numwords('123.456', group=1, decimal='mark', one='one'),
'one, two, three, mark, four, five, six')
inflect.STDOUT_ON = False
self.assertRaises(BadChunkingOptionError,
numwords, '1234', group=4)
inflect.STDOUT_ON = True
)
self.assertEqual(
numwords("555_1202", group=1, zero="oh"),
"five, five, five, one, two, oh, two",
)
self.assertEqual(
numwords("555_1202", group=1, one="unity"),
"five, five, five, unity, two, zero, two",
)
self.assertEqual(
numwords("123.456", group=1, decimal="mark", one="one"),
"one, two, three, mark, four, five, six",
)
inflect.STDOUT_ON = False
self.assertRaises(BadChunkingOptionError, numwords, "1234", group=4)
inflect.STDOUT_ON = True
'twelve, zero')
self.assertEqual(numwords('120', group=2, zero='oh', one='unity'),
'twelve, oh')
# TODO: ignoring 'one' param with group=2
self.TODO(numwords('101', group=2, zero='oh', one='unity'),
'ten, unity',
'ten, one')
self.assertEqual(numwords('555_1202', group=1, zero='oh'),
'five, five, five, one, two, oh, two')
self.assertEqual(numwords('555_1202', group=1, one='unity'),
'five, five, five, unity, two, zero, two')
self.assertEqual(numwords('123.456', group=1, decimal='mark', one='one'),
'one, two, three, mark, four, five, six')
inflect.STDOUT_ON = False
self.assertRaises(BadChunkingOptionError,
numwords, '1234', group=4)
inflect.STDOUT_ON = True
num = "%s" % num
# Handle "stylistic" conversions (up to a given threshold)...
if threshold is not None and float(num) > threshold:
spnum = num.split(".", 1)
while comma:
(spnum[0], n) = re.subn(r"(\d)(\d{3}(?:,|\Z))", r"\1,\2", spnum[0])
if n == 0:
break
try:
return "{}.{}".format(spnum[0], spnum[1])
except IndexError:
return "%s" % spnum[0]
if group < 0 or group > 3:
raise BadChunkingOptionError
nowhite = num.lstrip()
if nowhite[0] == "+":
sign = "plus"
elif nowhite[0] == "-":
sign = "minus"
else:
sign = ""
myord = num[-2:] in ("st", "nd", "rd", "th")
if myord:
num = num[:-2]
finalpoint = False
if decimal:
if group != 0:
chunks = num.split(".")
else: