def UnCamelCase(phrase, separator='_'):
  phrase_len = len(phrase)
  if not phrase_len:
    return ''

  ch = phrase[0]
  text_run = ch.isalnum()
  last_was_separator = ch.isupper() or not text_run
  caps_run = False
  result = ch.lower()

  # already did first index
  for i in range(phrase_len - 1):
    ch = phrase[i + 1]
    if ch.isupper():
      caps_run = text_run and last_was_separator
      text_run = True
      if not last_was_separator:
        result += separator
        last_was_separator = True
    elif not ch.isalnum():
      caps_run = False
      text_run = False
      last_was_separator = True
    else:
      text_run = True
      last_was_separator = False
      if caps_run:
        result += separator
        last_was_separator = True
        caps_run = False

    result += ch.lower()
  return result
Convert CamelCased phrase into lower-case delimited words.
dataset/ETHPy150Open google/apis-client-generator/src/googleapis/codegen/utilities/__init__.py/UnCamelCase