From 74b9a3c702bf10a5f1b74a7c2ebf03e46b80558a Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 26 Jan 2005 14:41:42 +0000 Subject: [PATCH] Moved eachSubstring to be a nested function; we don't use it anywhere else. --- src/utils.py | 10 +++------- test/test_utils.py | 5 ----- 2 files changed, 3 insertions(+), 12 deletions(-) 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)