diff --git a/src/utils.py b/src/utils.py index b6aeb8df8..e570633fb 100644 --- a/src/utils.py +++ b/src/utils.py @@ -31,8 +31,6 @@ Simple utility functions. """ - - import supybot.fix as fix import os @@ -94,13 +92,11 @@ def htmlToText(s, tagReplace=' '): x.feed(s) return x.getText() -def eachSubstring(s): - """Returns every substring starting at the first index until the last.""" - for i in xrange(1, len(s)+1): - yield s[:i] - def abbrev(strings, d=None): """Returns a dictionary mapping unambiguous abbreviations to full forms.""" + def eachSubstring(s): + for i in xrange(1, len(s)+1): + yield s[:i] if len(strings) != len(set(strings)): raise ValueError, \ 'strings given to utils.abbrev have duplicates: %r' % strings diff --git a/test/test_utils.py b/test/test_utils.py index e3e22b83d..d637b27a8 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -101,11 +101,6 @@ class UtilsTest(SupyTestCase): def timeElapsedShort(self): self.assertEqual(utils.timeElapsed(123, short=True), '2m 3s') - def testEachSubstring(self): - s = 'foobar' - L = ['f', 'fo', 'foo', 'foob', 'fooba', 'foobar'] - self.assertEqual(list(utils.eachSubstring(s)), L) - def testDistance(self): self.assertEqual(utils.distance('', ''), 0) self.assertEqual(utils.distance('a', 'b'), 1)