from functools import partial
from iro.error import NoRoute, NoTyp
class Provider():
def __init__(self, name, config, typs={}):
self.name = name
self.config = config
self.typs=typs
self.testmode = False
self.loadConfig()
def loadConfig(self):
for (n, v) in self.config:
if n == "typ":
self.typ = v
def send(self, typ, route, recipient, message):
pass
def getSendFunc(self, typ, route):
try:
if route not in self.typs[typ]:
raise NoRoute(route)
except KeyError:
raise NoTyp(route)
return partial(self.send, typ, route)