changes to to_camel_case and to_snake_case

This commit is contained in:
onyx-and-iris 2022-07-27 23:19:10 +01:00
parent 20851c3880
commit 13a0694190
2 changed files with 3 additions and 5 deletions

View File

@ -14,7 +14,7 @@ class Callback:
def get(self) -> list:
"""returns a list of registered events"""
return [to_camel_case(fn.__name__) for fn in self._callbacks]
return [to_camel_case(fn.__name__[2:]) for fn in self._callbacks]
def trigger(self, event, data):
"""trigger callback on update"""

View File

@ -3,13 +3,11 @@ from dataclasses import dataclass
def to_camel_case(s):
s = "".join(word.title() for word in s.split("_"))
return s[2:]
return "".join(word.title() for word in s.split("_"))
def to_snake_case(s):
s = re.sub(r"(?<!^)(?=[A-Z])", "_", s).lower()
return f"{s}"
return re.sub(r"(?<!^)(?=[A-Z])", "_", s).lower()
def as_dataclass(identifier, data):