|
15 | 15 |
|
16 | 16 |
|
17 | 17 | def to_camel_case(snake_case): |
18 | | - """Convert a snake case string to camel case""" |
| 18 | + """Convert a snake case string to camel case. |
| 19 | +
|
| 20 | + Args: |
| 21 | + snake_case (str): String to convert to camel case. |
| 22 | +
|
| 23 | + Returns: |
| 24 | + str: String converted to camel case. |
| 25 | + """ |
19 | 26 | return "".join([x.title() for x in snake_case.split("_")]) |
20 | 27 |
|
21 | 28 |
|
22 | 29 | def to_snake_case(name): |
23 | | - """Convert a camel case string to snake case""" |
| 30 | + """Convert a camel case string to snake case |
| 31 | +
|
| 32 | + Args: |
| 33 | + name (str): String to convert to snake case. |
| 34 | +
|
| 35 | + Returns: |
| 36 | + str: String converted to snake case. |
| 37 | + """ |
24 | 38 | # https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case |
25 | 39 | s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name) |
26 | 40 | return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower() |
27 | 41 |
|
28 | 42 |
|
29 | 43 | def from_boto(boto_dict, boto_name_to_member_name, member_name_to_type): |
30 | | - """Convert an UpperCamelCase boto response to a snake case representation. |
| 44 | + """ |
| 45 | + Convert an UpperCamelCase boto response to a snake case representation. |
31 | 46 |
|
32 | | - Args: |
33 | | - boto_dict dict[str, ?]: A boto response dictionary. |
34 | | - boto_name_to_member_name dict[str, str]: A map from boto name to snake_case name. If a given boto name is |
35 | | - not in the map then a default mapping is applied. |
36 | | - member_name_to_type dict[str, (_base_types.ApiObject, boolean)]: A map from snake case name to a type |
37 | | - description tuple. The first element of the tuple, a sublcass of ApiObject, is the type of the mapped |
38 | | - object. The second element indicates whether the mapped element is a collection or singleton. |
| 47 | + Args: |
| 48 | + boto_dict (dict[str, ?]): A boto response dictionary. |
| 49 | + boto_name_to_member_name (dict[str, str]): A map from boto name to snake_case name. If a given boto name is |
| 50 | + not in the map then a default mapping is applied. |
| 51 | + member_name_to_type (dict[str, (_base_types.ApiObject, boolean)]): A map from snake case name to a type |
| 52 | + description tuple. The first element of the tuple, a subclass of ApiObject, is the type of the mapped |
| 53 | + object. The second element indicates whether the mapped element is a collection or singleton. |
| 54 | +
|
| 55 | + Returns: |
| 56 | + dict: Boto response in snake case. |
39 | 57 | """ |
40 | 58 | from_boto_values = {} |
41 | 59 | for boto_name, boto_value in boto_dict.items(): |
@@ -68,6 +86,10 @@ def to_boto(member_vars, member_name_to_boto_name, member_name_to_type): |
68 | 86 | Args: |
69 | 87 | member_vars dict[str, ?]: A map from snake case name to value. |
70 | 88 | member_name_to_boto_name dict[str, ?]: A map from snake_case name to boto name. |
| 89 | +
|
| 90 | + Returns: |
| 91 | + dict: boto dict converted to snake case |
| 92 | +
|
71 | 93 | """ |
72 | 94 | to_boto_values = {} |
73 | 95 | # Strip out all entries in member_vars that have a None value. None values are treated as not having a value |
|
0 commit comments