class DecisionService(Service): def __init__(self, ircclient): self.rotational = Rotational("dc") self.ircclient = ircclient def add(self, decision): name = self.rotational.add(decision) decision.set_name(name) decision.present(self.ircclient) return decision def _decide(self, decision_name, selection): decision_name = decision_name.upper() try: decision = self.rotational[decision_name] decision.fulfill(selection) del self.rotational[selection] except KeyError: raise DecisionError("no such decision: %s" % decision_name) except DecisionOptionError: raise DecisionError("not a valid option: %s" % selection) def decide(self, decision_name, selection): try: self._decide(decision_name, selection) except DecisionError, e: self.ircclient.error(e)
def __init__(self, ircclient): self.rotational = Rotational("dc") self.ircclient = ircclient