Fix to comments.

This commit is contained in:
Adam Donahue 2017-06-27 18:22:22 -04:00
parent c012c48866
commit faf8a41118

View File

@ -5,7 +5,7 @@ def to_camel_case(snake_str):
""" """
Return a camel-cased version of a snake-cased string. Return a camel-cased version of a snake-cased string.
Leading underscores and multiple-underscores are kept Leading underscores and multiple consecutive underscores are kept
intact. intact.
:param snake_str: A snake-cased string. :param snake_str: A snake-cased string.
@ -16,13 +16,13 @@ def to_camel_case(snake_str):
# component. # component.
snake_case_sub_strings = re.findall(r'(_*[a-zA-Z]+|_+$)', snake_str) snake_case_sub_strings = re.findall(r'(_*[a-zA-Z]+|_+$)', snake_str)
# The first variable is unchanged case wise (and leading # The first variable is unchanged case-wise (and leading
# underscores preserved as-is). # underscores preserved as-is).
camel_case_sub_strings = [snake_case_sub_strings[0]] camel_case_sub_strings = [snake_case_sub_strings[0]]
for s in snake_case_sub_strings[1:]: for s in snake_case_sub_strings[1:]:
# We reset the camel casing algorithm if more than one # We reset the camel casing algorithm if more than one
# underscore is encountered. The endwiths handles any # underscore is encountered. The endswith handles any
# trailing underscores in the original snake-cased # trailing underscores in the original snake-cased
# variable. # variable.
if s.startswith('__') or s.endswith('_'): if s.startswith('__') or s.endswith('_'):