mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 12:12:54 +01:00
* Added the most horribly named command ever - utils.ellipsisify
This commit is contained in:
parent
88f33ed8dd
commit
d9d141a8e7
@ -273,6 +273,15 @@ def wrapLines(s):
|
|||||||
L.append(textwrap.fill(line))
|
L.append(textwrap.fill(line))
|
||||||
return '\n'.join(L)
|
return '\n'.join(L)
|
||||||
|
|
||||||
|
def ellipsisify(s, n):
|
||||||
|
"""Returns a shortened version of s. Produces up to the first n chars at
|
||||||
|
the nearest word boundary.
|
||||||
|
"""
|
||||||
|
if len(s) <= n:
|
||||||
|
return s
|
||||||
|
else:
|
||||||
|
return (textwrap.wrap(s, n-3)[0] + '...')
|
||||||
|
|
||||||
plurals = {'match': 'matches'}
|
plurals = {'match': 'matches'}
|
||||||
def pluralize(i, s):
|
def pluralize(i, s):
|
||||||
"""Returns the plural of s based on its number i. Put any exceptions to
|
"""Returns the plural of s based on its number i. Put any exceptions to
|
||||||
|
Loading…
Reference in New Issue
Block a user