Use voussoirkit.stringtools for collapse_whitespace.

This commit is contained in:
voussoir 2020-11-15 22:13:06 -08:00
parent 9ca40c6ae7
commit 98b6d93094
2 changed files with 4 additions and 8 deletions

View file

@ -149,11 +149,6 @@ def checkerboard_image(color_1, color_2, image_size, checker_size):
offset = not offset offset = not offset
return image return image
def collapse_whitespace(s):
s = s.strip()
s = re.sub(r'\s+', ' ', s)
return s
def comma_space_split(s): def comma_space_split(s):
''' '''
Split the string apart by commas and spaces, discarding all extra Split the string apart by commas and spaces, discarding all extra

View file

@ -16,6 +16,7 @@ from voussoirkit import pathclass
from voussoirkit import sentinel from voussoirkit import sentinel
from voussoirkit import spinal from voussoirkit import spinal
from voussoirkit import sqlhelpers from voussoirkit import sqlhelpers
from voussoirkit import stringtools
from . import constants from . import constants
from . import decorators from . import decorators
@ -307,7 +308,7 @@ class Album(ObjectBase, GroupableMixin):
if not isinstance(title, str): if not isinstance(title, str):
raise TypeError(f'Title must be {str}, not {type(title)}.') raise TypeError(f'Title must be {str}, not {type(title)}.')
title = helpers.collapse_whitespace(title) title = stringtools.collapse_whitespace(title)
return title return title
@ -613,7 +614,7 @@ class Bookmark(ObjectBase):
if not isinstance(title, str): if not isinstance(title, str):
raise TypeError(f'Title must be {str}, not {type(title)}.') raise TypeError(f'Title must be {str}, not {type(title)}.')
title = helpers.collapse_whitespace(title) title = stringtools.collapse_whitespace(title)
return title return title
@ -1569,7 +1570,7 @@ class User(ObjectBase):
if not isinstance(display_name, str): if not isinstance(display_name, str):
raise TypeError(f'Display name must be string, not {type(display_name)}.') 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 == '': if display_name == '':
return None return None