Skip to content

Commit

Permalink
fix: add snake_case utility
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Nov 5, 2021
1 parent 718b36b commit 8009226
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions beet/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"required_field",
"intersperse",
"normalize_string",
"snake_case",
"log_time",
]

Expand Down Expand Up @@ -68,6 +69,13 @@ def normalize_string(string: str) -> str:
return NORMALIZE_REGEX.sub("_", string.lower()).strip("_")


CAMEL_REGEX = re.compile(r"((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))")


def snake_case(string: str) -> str:
return CAMEL_REGEX.sub(r"_\1", string).lower()


time_logger = logging.getLogger("time")


Expand Down

0 comments on commit 8009226

Please sign in to comment.