def _trailing(template, *targets):
"""Substring of *template* following all *targets*.
**Example**::
template = "this is a test of the bunnies."
_trailing(template, "is", "est", "the") == " bunnies"
Each target is matched successively in the string, and the string
remaining after the last target is returned. If one of the targets
fails to match, a ValueError is raised.
:param template: Template to extract a trailing string from.
:type template: ``string``
:param targets: Strings to successively match in *template*.
:type targets: list of ``string``s
:return: Trailing string after all targets are matched.
:rtype: ``string``
:raises ValueError: Raised when one of the targets does not match.
"""
s = template
for t in targets:
n = s.find(t)
if n == -1:
raise ValueError("Target " + t + " not found in template.")
s = s[n + len(t):]
return s
# Filter the given state content record according to the given arg list.
评论列表
文章目录