mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-22 17:46:57 +03:00
Remove to_const function (#1212)
This commit is contained in:
parent
4b70186031
commit
a1fc3688aa
|
@ -1,5 +1,4 @@
|
||||||
import re
|
import re
|
||||||
from unidecode import unidecode
|
|
||||||
|
|
||||||
|
|
||||||
# Adapted from this response in Stackoverflow
|
# Adapted from this response in Stackoverflow
|
||||||
|
@ -16,7 +15,3 @@ def to_camel_case(snake_str):
|
||||||
def to_snake_case(name):
|
def to_snake_case(name):
|
||||||
s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", 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()
|
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower()
|
||||||
|
|
||||||
|
|
||||||
def to_const(string):
|
|
||||||
return re.sub(r"[\W|^]+", "_", unidecode(string)).upper()
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from ..str_converters import to_camel_case, to_const, to_snake_case
|
from ..str_converters import to_camel_case, to_snake_case
|
||||||
|
|
||||||
|
|
||||||
def test_snake_case():
|
def test_snake_case():
|
||||||
|
@ -17,11 +17,3 @@ def test_camel_case():
|
||||||
assert to_camel_case("snakes_on_a__plane") == "snakesOnA_Plane"
|
assert to_camel_case("snakes_on_a__plane") == "snakesOnA_Plane"
|
||||||
assert to_camel_case("i_phone_hysteria") == "iPhoneHysteria"
|
assert to_camel_case("i_phone_hysteria") == "iPhoneHysteria"
|
||||||
assert to_camel_case("field_i18n") == "fieldI18n"
|
assert to_camel_case("field_i18n") == "fieldI18n"
|
||||||
|
|
||||||
|
|
||||||
def test_to_const():
|
|
||||||
assert to_const('snakes $1. on a "#plane') == "SNAKES_1_ON_A_PLANE"
|
|
||||||
|
|
||||||
|
|
||||||
def test_to_const_unicode():
|
|
||||||
assert to_const("Skoða þetta unicode stöff") == "SKODA_THETTA_UNICODE_STOFF"
|
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -85,7 +85,6 @@ setup(
|
||||||
"graphql-core>=3.1.0b1,<4",
|
"graphql-core>=3.1.0b1,<4",
|
||||||
"graphql-relay>=3.0,<4",
|
"graphql-relay>=3.0,<4",
|
||||||
"aniso8601>=8,<9",
|
"aniso8601>=8,<9",
|
||||||
"unidecode>=1.1.1,<2",
|
|
||||||
],
|
],
|
||||||
tests_require=tests_require,
|
tests_require=tests_require,
|
||||||
extras_require={"test": tests_require, "dev": dev_requires},
|
extras_require={"test": tests_require, "dev": dev_requires},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user