3 # Copyright (C) 2014 Ipsilon Project Contributors
5 # See the file named COPYING for the project license
7 from ipsilon.util.log import Log
8 from ipsilon.util.plugin import PluginLoader, PluginObject
9 from ipsilon.util.plugin import PluginInstaller
12 class InfoProviderBase(PluginObject):
15 super(InfoProviderBase, self).__init__()
17 def get_user_attrs(self, user):
18 raise NotImplementedError
21 FACILITY = 'info_config'
26 def __init__(self, *args, **kwargs):
29 loader = PluginLoader(Info, FACILITY, 'InfoProvider')
30 plugins = loader.get_plugin_data()
32 available = plugins['available'].keys()
33 self.debug('Available info providers: %s' % str(available))
35 for item in plugins['whitelist']:
36 self.debug('Login plugin in whitelist: %s' % item)
37 if item not in plugins['available']:
38 self.debug('Info Plugin %s not found' % item)
40 self.providers.append((item, plugins['available'][item]))
41 self.debug('Added Info plugin: %s' % item)
43 def get_user_attrs(self, user, provider=None):
45 for p in self.providers:
47 return p[1].get_user_attrs(user)
49 for p in self.providers:
50 ret = p[1].get_user_attrs(user)
57 class InfoProviderInstaller(object):
60 self.facility = FACILITY
64 def install_args(self, group):
65 raise NotImplementedError
67 def configure(self, opts):
68 raise NotImplementedError
71 class InfoProviderInstall(object):
74 pi = PluginInstaller(InfoProviderInstall)
75 self.plugins = pi.get_plugins()