def _MatchDirective(token):

  if token.startswith('.'):
    token = token[1:]
  else:
    return None, None  # Must start with .

  if token == 'alternates with':
    return ALTERNATES_TOKEN, token

  if token.startswith('or'):
    if token.strip() == 'or':
      return OR_TOKEN, None
    else:
      pred_str = token[2:].strip()
      return OR_TOKEN, pred_str

  if token == 'end':
    return END_TOKEN, None

  match = _SECTION_RE.match(token)
  if match:
    repeated, section_name = match.groups()
    if repeated:
      return REPEATED_SECTION_TOKEN, section_name
    else:
      return SECTION_TOKEN, section_name

  # {.if plural?} and {.plural?} are synonyms.  The ".if" will read better for
  # expressions, for people who like that kind of dirty thing...
  if token.startswith('if '):
    return PREDICATE_TOKEN, token[3:].strip()
  if token.endswith('?'):
    return PREDICATE_TOKEN, token

  return None, None  # no match
Same as above, but than sek.
dataset/ETHPy150Open cloudbuilders/radioedit/jsontemplate.py/_MatchDirective--crossover with--dataset/ETHPy150Open bread-and-pepper/django-brookie/brookie/templatetags/monetize.py/sek