mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2024-11-22 12:50:53 +00:00
changes to to_camel_case and to_snake_case
This commit is contained in:
parent
20851c3880
commit
13a0694190
@ -14,7 +14,7 @@ class Callback:
|
|||||||
def get(self) -> list:
|
def get(self) -> list:
|
||||||
"""returns a list of registered events"""
|
"""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):
|
def trigger(self, event, data):
|
||||||
"""trigger callback on update"""
|
"""trigger callback on update"""
|
||||||
|
@ -3,13 +3,11 @@ from dataclasses import dataclass
|
|||||||
|
|
||||||
|
|
||||||
def to_camel_case(s):
|
def to_camel_case(s):
|
||||||
s = "".join(word.title() for word in s.split("_"))
|
return "".join(word.title() for word in s.split("_"))
|
||||||
return s[2:]
|
|
||||||
|
|
||||||
|
|
||||||
def to_snake_case(s):
|
def to_snake_case(s):
|
||||||
s = re.sub(r"(?<!^)(?=[A-Z])", "_", s).lower()
|
return re.sub(r"(?<!^)(?=[A-Z])", "_", s).lower()
|
||||||
return f"{s}"
|
|
||||||
|
|
||||||
|
|
||||||
def as_dataclass(identifier, data):
|
def as_dataclass(identifier, data):
|
||||||
|
Loading…
Reference in New Issue
Block a user