--- a/iro/offer/provider.py Thu Feb 23 16:56:25 2012 +0100
+++ b/iro/offer/provider.py Thu Feb 23 16:57:57 2012 +0100
@@ -1,6 +1,8 @@
from functools import partial
-from iro.error import NoRoute, NoTyp
+from ..error import NoRoute, NoTyp, ValidateException, NoProvider, NeededOption
+from ..config import Option
+
class Provider():
def __init__(self, name, config, typs={}):
self.name = name
@@ -8,9 +10,22 @@
self.typs=typs
self.testmode = False
- self.loadConfig()
+ self.options = {
+ "typ":Option(vProvider, long="One available provider typ.", must=True)
+ }
def loadConfig(self):
+ c=dict(self.config)
+ for o in self.options:
+ try:
+ value = self.options[o].validate(c[o],o)
+ setattr(self, o, value)
+ except (KeyError):
+ if self.options[o].must:
+ raise NeededOption(self.name, o)
+ elif self.options[o].default is not None:
+ setattr(self,o,self.options[o].default)
+
for (n, v) in self.config:
if n == "typ":
self.typ = v