--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/iro/providerlist.py Wed Oct 28 02:35:01 2009 +0100
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+#Copyright (C) 2009 Sandro Knauß <bugs@sandroknauss.de>
+
+#This program is free software; you can redistribute it and/or modify it under the terms
+#of the GNU General Public License as published by the Free Software Foundation;
+#either version 3 of the License, or any later version.
+#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+#without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#See the GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+class Providerlist:
+ def __init__(self):
+ self.provider={}
+ self.types={}
+ self.defaults={}
+
+ def add(self, name, provider, typeslist):
+ self.provider[name]={"name":name, "class":provider, "types":typeslist}
+ for stype in typeslist:
+ try:
+ self.types[stype].append(self.provider[name])
+ except KeyError:
+ self.types[stype]=[self.provider[name]]
+
+
+ def setDefault(self, stype, name):
+ self.defaults[stype]=self.provider[name]
+
+ def getDefault(self, stype):
+ return self.defaults[stype]
+
+ def getProviderlist(self, stype):
+ llist=[ provider["name"] for provider in self.types[stype] ]
+ llist.sort()
+ return llist
+
+ def getProvider(self, stype, name="default"):
+ if name=="default":
+ return self.getDefault(stype)["class"]
+
+ if not stype in self.provider[name] ["types"]:
+ raise "argh"
+
+ return self.provider[name]["class"]