Source code for annotations.utils
"""
General-purpose helper functions.
"""
from django.conf import settings
from itertools import chain, combinations, groupby
import re
[docs]def help_text(text):
"""
Remove excess whitespace from a string. Intended for use in model and form
fields when writing long help_texts.
"""
return re.sub('(\s+)', ' ', text)
[docs]def basepath(request):
"""
Generate the base path (domain + path) for the site.
TODO: Do we need this anymore?
Parameters
----------
request : :class:`django.http.request.HttpRequest`
Returns
-------
str
"""
if request.is_secure():
scheme = 'https://'
else:
scheme = 'http://'
return scheme + request.get_host() + settings.SUBPATH