Add moto.core.utils.underscores_to_camelcase()
This commit is contained in:
parent
a4dfdc8274
commit
a06f8b15f5
2 changed files with 25 additions and 1 deletions
|
|
@ -23,6 +23,22 @@ def camelcase_to_underscores(argument):
|
|||
return result
|
||||
|
||||
|
||||
def underscores_to_camelcase(argument):
|
||||
''' Converts a camelcase param like the_new_attribute to the equivalent
|
||||
camelcase version like theNewAttribute. Note that the first letter is
|
||||
NOT capitalized by this function '''
|
||||
result = ''
|
||||
previous_was_underscore = False
|
||||
for char in argument:
|
||||
if char != '_':
|
||||
if previous_was_underscore:
|
||||
result += char.upper()
|
||||
else:
|
||||
result += char
|
||||
previous_was_underscore = char == '_'
|
||||
return result
|
||||
|
||||
|
||||
def method_names_from_class(clazz):
|
||||
# On Python 2, methods are different from functions, and the `inspect`
|
||||
# predicates distinguish between them. On Python 3, methods are just
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue