import helper from source

This commit is contained in:
Diogo Sousa
2023-11-23 12:51:27 +00:00
parent 199f995882
commit 0400bea644
2 changed files with 0 additions and 28 deletions

View File

@@ -119,22 +119,3 @@ def to_snake_case(string: str) -> str:
.replace(" ", "_")
.replace("__", "_")
)
def to_camel_case(string: str):
"""Convert a string to camel case.
If all characters are lower case we return title version of the string.
Examples
--------
"close" -> "Close"
"some_field" -> "someField"
"""
s_list = string.replace("-", " ").replace("_", " ").split()
if len(string) == 0:
return string
result = s_list[0] + "".join(i.capitalize() for i in s_list[1:])
if result.islower():
return result.title()
return result

View File

@@ -6,7 +6,6 @@ from openbb_core.provider.utils.helpers import (
get_querystring,
get_user_agent,
make_request,
to_camel_case,
to_snake_case,
)
@@ -69,11 +68,3 @@ def test_to_snake_case():
assert to_snake_case("SomeRandomString") == "some_random_string"
assert to_snake_case("someRandomString") == "some_random_string"
assert to_snake_case("already_snake_case") == "already_snake_case"
def test_to_camel_case():
"""Test the to_camel_case helper."""
assert to_camel_case("some_field") == "someField"
assert to_camel_case("alreadyCamelCase") == "alreadyCamelCase"
assert to_camel_case("close") == "Close"
assert not to_camel_case("")