-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Frédéric Collonval
committed
Feb 23, 2021
1 parent
adc74d8
commit 05e731a
Showing
33 changed files
with
1,510 additions
and
674 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = false | ||
|
||
[*.{css,json,ts,tsx}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import re | ||
|
||
UPPER_CASE = re.compile(r"(?<!^)(?=[A-Z])") | ||
|
||
|
||
def snake_to_camel_case(name: str) -> str: | ||
first, *rest = name.split("_") | ||
return "".join([first.lower(), *map(str.title, rest)]) | ||
|
||
|
||
def camel_to_snake_case(name: str) -> str: | ||
return UPPER_CASE.sub("_", name).lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pytest | ||
|
||
from jupyterlab_pullrequests.managers.utils import snake_to_camel_case, camel_to_snake_case | ||
|
||
TO_BE_TESTED = [ | ||
("banana", "banana"), | ||
("banana_split", "bananaSplit"), | ||
("the_famous_banana_split", "theFamousBananaSplit"), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize("input_, expected", TO_BE_TESTED) | ||
def test_snake_to_camel_case(input_, expected): | ||
assert snake_to_camel_case(input_) == expected | ||
|
||
|
||
@pytest.mark.parametrize("expected, input_", TO_BE_TESTED) | ||
def test_camel_to_snake_case(expected, input_): | ||
assert camel_to_snake_case(input_) == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.