Use voussoirkit.stringtools for collapse_whitespace.
This commit is contained in:
parent
9ca40c6ae7
commit
98b6d93094
2 changed files with 4 additions and 8 deletions
|
@ -149,11 +149,6 @@ def checkerboard_image(color_1, color_2, image_size, checker_size):
|
|||
offset = not offset
|
||||
return image
|
||||
|
||||
def collapse_whitespace(s):
|
||||
s = s.strip()
|
||||
s = re.sub(r'\s+', ' ', s)
|
||||
return s
|
||||
|
||||
def comma_space_split(s):
|
||||
'''
|
||||
Split the string apart by commas and spaces, discarding all extra
|
||||
|
|
|
@ -16,6 +16,7 @@ from voussoirkit import pathclass
|
|||
from voussoirkit import sentinel
|
||||
from voussoirkit import spinal
|
||||
from voussoirkit import sqlhelpers
|
||||
from voussoirkit import stringtools
|
||||
|
||||
from . import constants
|
||||
from . import decorators
|
||||
|
@ -307,7 +308,7 @@ class Album(ObjectBase, GroupableMixin):
|
|||
if not isinstance(title, str):
|
||||
raise TypeError(f'Title must be {str}, not {type(title)}.')
|
||||
|
||||
title = helpers.collapse_whitespace(title)
|
||||
title = stringtools.collapse_whitespace(title)
|
||||
|
||||
return title
|
||||
|
||||
|
@ -613,7 +614,7 @@ class Bookmark(ObjectBase):
|
|||
if not isinstance(title, str):
|
||||
raise TypeError(f'Title must be {str}, not {type(title)}.')
|
||||
|
||||
title = helpers.collapse_whitespace(title)
|
||||
title = stringtools.collapse_whitespace(title)
|
||||
|
||||
return title
|
||||
|
||||
|
@ -1569,7 +1570,7 @@ class User(ObjectBase):
|
|||
if not isinstance(display_name, str):
|
||||
raise TypeError(f'Display name must be string, not {type(display_name)}.')
|
||||
|
||||
display_name = helpers.collapse_whitespace(display_name)
|
||||
display_name = stringtools.collapse_whitespace(display_name)
|
||||
|
||||
if display_name == '':
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue