move utils.consts.BITBOT_MAGIC to utils.decorators
This commit is contained in:
parent
5d01db8514
commit
5d55086847
2 changed files with 5 additions and 6 deletions
|
@ -1,8 +1,6 @@
|
||||||
import typing
|
import typing
|
||||||
from . import _consts_256_color
|
from . import _consts_256_color
|
||||||
|
|
||||||
BITBOT_MAGIC = "__bitbot"
|
|
||||||
|
|
||||||
class IRCColor(object):
|
class IRCColor(object):
|
||||||
def __init__(self, irc: int, ansi: int, is_256):
|
def __init__(self, irc: int, ansi: int, is_256):
|
||||||
self.irc = irc
|
self.irc = irc
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import typing
|
import typing
|
||||||
from . import consts
|
|
||||||
|
BITBOT_MAGIC = "__bitbot"
|
||||||
|
|
||||||
class BitBotMagic(object):
|
class BitBotMagic(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -24,10 +25,10 @@ class BitBotMagic(object):
|
||||||
|
|
||||||
def get_magic(obj: typing.Any):
|
def get_magic(obj: typing.Any):
|
||||||
if not has_magic(obj):
|
if not has_magic(obj):
|
||||||
setattr(obj, consts.BITBOT_MAGIC, BitBotMagic())
|
setattr(obj, BITBOT_MAGIC, BitBotMagic())
|
||||||
return getattr(obj, consts.BITBOT_MAGIC)
|
return getattr(obj, BITBOT_MAGIC)
|
||||||
def has_magic(obj: typing.Any):
|
def has_magic(obj: typing.Any):
|
||||||
return hasattr(obj, consts.BITBOT_MAGIC)
|
return hasattr(obj, BITBOT_MAGIC)
|
||||||
|
|
||||||
def hook(event: str, **kwargs):
|
def hook(event: str, **kwargs):
|
||||||
def _hook_func(func):
|
def _hook_func(func):
|
||||||
|
|
Loading…
Reference in a new issue