mirror of
https://github.com/django/django.git
synced 2025-09-25 03:32:37 +00:00
Removed a few gratuitous lambdas.
This commit is contained in:
parent
4e7aa573ec
commit
8f04f53dd8
7 changed files with 37 additions and 20 deletions
|
@ -17,6 +17,7 @@ if six.PY2:
|
|||
# people rely on it being here.
|
||||
from django.utils.encoding import force_unicode # NOQA
|
||||
|
||||
|
||||
# Capitalizes the first letter of a string.
|
||||
capfirst = lambda x: x and force_text(x)[0].upper() + force_text(x)[1:]
|
||||
capfirst = allow_lazy(capfirst, six.text_type)
|
||||
|
@ -25,6 +26,7 @@ capfirst = allow_lazy(capfirst, six.text_type)
|
|||
re_words = re.compile(r'<.*?>|((?:\w[-\w]*|&.*?;)+)', re.U | re.S)
|
||||
re_tag = re.compile(r'<(/)?([^ ]+?)(?:(\s*/)| .*?)?>', re.S)
|
||||
re_newlines = re.compile(r'\r\n|\r') # Used in normalize_newlines
|
||||
re_camel_case = re.compile(r'(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))')
|
||||
|
||||
|
||||
def wrap(text, width):
|
||||
|
@ -420,3 +422,11 @@ def slugify(value):
|
|||
value = re.sub('[^\w\s-]', '', value).strip().lower()
|
||||
return mark_safe(re.sub('[-\s]+', '-', value))
|
||||
slugify = allow_lazy(slugify, six.text_type)
|
||||
|
||||
|
||||
def camel_case_to_spaces(value):
|
||||
"""
|
||||
Splits CamelCase and converts to lower case. Also strips leading and
|
||||
trailing whitespace.
|
||||
"""
|
||||
return re_camel_case.sub(r' \1', value).strip().lower()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue