0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Removes keyword_split.

This commit is contained in:
Bertrand Bordage 2017-11-23 18:52:50 +01:00
parent 6fe6935997
commit 4c4dfac806

View File

@ -1,7 +1,6 @@
from __future__ import absolute_import, division, unicode_literals from __future__ import absolute_import, division, unicode_literals
import operator import operator
import re
from functools import partial, reduce from functools import partial, reduce
from itertools import zip_longest from itertools import zip_longest
@ -31,25 +30,6 @@ AND = partial(reduce, operator.and_)
ADD = partial(reduce, operator.add) ADD = partial(reduce, operator.add)
def keyword_split(keywords):
"""
Return all the keywords in a keyword string.
Keeps keywords surrounded by quotes together, removing the surrounding quotes:
>>> keyword_split('Hello I\\'m looking for "something special"')
['Hello', "I'm", 'looking', 'for', 'something special']
Nested quoted strings are returned as is:
>>> keyword_split("He said \\"I'm looking for 'something special'\\" so I've given him the 'special item'")
['He', 'said', "I'm looking for 'something special'", 'so', "I've", 'given', 'him', 'the', 'special item']
"""
matches = re.findall(r'"([^"]+)"|\'([^\']+)\'|(\S+)', keywords)
return [match[0] or match[1] or match[2] for match in matches]
def get_descendant_models(model): def get_descendant_models(model):
""" """
Returns all descendants of a model, including the model itself. Returns all descendants of a model, including the model itself.