-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved GraphQL DSL 😊. Fixed #12
- Loading branch information
1 parent
8257777
commit 269d2e9
Showing
3 changed files
with
111 additions
and
52 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
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,21 @@ | ||
import re | ||
|
||
|
||
# From this response in Stackoverflow | ||
# http://stackoverflow.com/a/19053800/1072990 | ||
def to_camel_case(snake_str): | ||
components = snake_str.split('_') | ||
# We capitalize the first letter of each component except the first one | ||
# with the 'title' method and join them together. | ||
return components[0] + "".join(x.title() if x else '_' for x in components[1:]) | ||
|
||
|
||
# From this response in Stackoverflow | ||
# http://stackoverflow.com/a/1176023/1072990 | ||
def to_snake_case(name): | ||
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) | ||
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | ||
|
||
|
||
def to_const(string): | ||
return re.sub('[\W|^]+', '_', string).upper() |
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