mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Added unCommaThe function.
This commit is contained in:
parent
17478daca2
commit
53d883710e
@ -271,4 +271,12 @@ def commaAndify(seq):
|
||||
L[-1] = 'and %s' % L[-1]
|
||||
return ', '.join(L)
|
||||
|
||||
_unCommaTheRe = re.compile(r'(.*),\s*(the)$', re.I)
|
||||
def unCommaThe(s):
|
||||
m = _unCommaTheRe.match(s)
|
||||
if m is not None:
|
||||
return '%s %s' % (m.group(2), m.group(1))
|
||||
else:
|
||||
return s
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -148,5 +148,10 @@ class UtilsTest(unittest.TestCase):
|
||||
self.assertEqual(L, original)
|
||||
self.failUnless(utils.commaAndify(sets.Set(L)))
|
||||
|
||||
def testUnCommaThe(self):
|
||||
self.assertEqual(utils.unCommaThe('foo bar'), 'foo bar')
|
||||
self.assertEqual(utils.unCommaThe('foo bar, the'), 'the foo bar')
|
||||
self.assertEqual(utils.unCommaThe('foo bar, The'), 'The foo bar')
|
||||
self.assertEqual(utils.unCommaThe('foo bar,the'), 'the foo bar')
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user