Moved eachSubstring to be a nested function; we don't use it anywhere else.

This commit is contained in:
Jeremy Fincher 2005-01-26 14:41:42 +00:00
parent 6d02564965
commit 74b9a3c702
2 changed files with 3 additions and 12 deletions

View File

@ -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

View File

@ -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)