Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
ethe committed Jul 26, 2019
1 parent fed4d67 commit db5747d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ Pygraphy **does not support** full features of GraphQL according to Spec right n
- ID Scalar
- Type Extensions
- Some Validation Check
- Alias Field

Most of features are already implemented so do not panic.

Expand Down
8 changes: 6 additions & 2 deletions pygraphy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ def to_camel_case(name):
return '__' + res if has_prefix else res


seprate_upper_case = re.compile("(.)([A-Z][a-z]+)")
seprate_upper_case_behind_lower_case = re.compile("([a-z0-9])([A-Z])")


def to_snake_case(name):
has_prefix = False
if '__' in name:
has_prefix = True
without_prifix_name = ''.join(name.split('__')[1:])
else:
without_prifix_name = name
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", without_prifix_name)
res = re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
s1 = seprate_upper_case.sub(r"\1_\2", without_prifix_name)
res = seprate_upper_case_behind_lower_case.sub(r"\1_\2", s1).lower()
return '__' + res if has_prefix else res


Expand Down

0 comments on commit db5747d

Please sign in to comment.