Skip to content

Commit

Permalink
Add pascal to snake case helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-f-cruz committed Dec 4, 2024
1 parent 03c3c9f commit fd71b02
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions _topics/08-reproducible-research-practices/src/python/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ def export_schema(
return json_model


def screaming_snake_case_to_pascal_case(s: str) -> str:
words = s.split("_")
def screaming_snake_case_to_pascal_case(value: str) -> str:
words = value.split("_")
return "".join(word.capitalize() for word in words)


Expand Down Expand Up @@ -243,3 +243,15 @@ def bonsai_sgen(
cmd_string += " --serializer"
cmd_string += " ".join([f" {sr.value}" for sr in serializer])
return run(cmd_string, shell=True, check=True)


def pascal_to_snake_case(value: str) -> str:
result = ""
for i, char in enumerate(value):
if char.isupper():
if i != 0:
result += "_"
result += char.lower()
else:
result += char
return result

0 comments on commit fd71b02

Please sign in to comment.