Compare commits
2 Commits
6df7089900
...
459806683a
Author | SHA1 | Date | |
---|---|---|---|
459806683a | |||
4ff137d758 |
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from singleton import Singleton
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Communicator module
|
Communicator module
|
||||||
@ -11,15 +12,10 @@ __copyright__ = "Copyright 2020, GoldenPogácsa Team"
|
|||||||
__module_name__ = "messagesender"
|
__module_name__ = "messagesender"
|
||||||
__version__text__ = "1"
|
__version__text__ = "1"
|
||||||
|
|
||||||
class Communicator:
|
class Communicator(Singleton):
|
||||||
"""
|
"""
|
||||||
Class handling low level communication with consumers.
|
Class handling low level communication with consumers.
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
|
||||||
"""
|
|
||||||
Initalize class
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
def sendmessage(self, message: str) -> None:
|
def sendmessage(self, message: str) -> None:
|
||||||
"""
|
"""
|
||||||
|
30
singleton.py
Normal file
30
singleton.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
"""
|
||||||
|
Singleton meta module
|
||||||
|
"""
|
||||||
|
|
||||||
|
__author__ = "@tormakris"
|
||||||
|
__copyright__ = "Copyright 2020, GoldenPogácsa Team"
|
||||||
|
__module_name__ = "singleton"
|
||||||
|
__version__text__ = "1"
|
||||||
|
|
||||||
|
|
||||||
|
class Singleton(object):
|
||||||
|
"""
|
||||||
|
Singleton metaclass
|
||||||
|
"""
|
||||||
|
_instances = {}
|
||||||
|
|
||||||
|
def __new__(class_, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
New
|
||||||
|
:param args:
|
||||||
|
:param kwargs:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
if class_ not in class_._instances:
|
||||||
|
class_._instances[class_] = super(
|
||||||
|
Singleton, class_).__new__(
|
||||||
|
class_, *args, **kwargs)
|
||||||
|
return class_._instances[class_]
|
Reference in New Issue
Block a user