mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-30 14:02:06 +00:00
Improve snake_case generation
This commit is contained in:
@@ -99,5 +99,11 @@ def make_request(
|
||||
|
||||
|
||||
def to_snake_case(string: str) -> str:
|
||||
"""Convert a string to snake case."""
|
||||
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", string)
|
||||
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
|
||||
return (
|
||||
re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1)
|
||||
.lower()
|
||||
.replace(" ", "_")
|
||||
.replace("__", "_")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user