This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
larpe/larpe/trunk/larpe/plugins/site_authentication_plugins.py

29 lines
947 B
Python

class SiteAuthenticationPlugins:
""" This class manages the plugins for site authentification """
def __init__(self):
self.site_authentication_classes = dict()
def register(self, klass):
""" Register a custom SiteAuthentification instance """
self.site_authentication_classes[klass.plugin_name] = klass
def get(self, plugin_name):
""" Return a custom SiteAuthentification instance """
if self.site_authentication_classes.has_key(plugin_name):
return self.site_authentication_classes[plugin_name]
else:
return None
def auto_detect(self, html_doc):
"""
Try to find automatically the right plugin name
Return the plugin name or None
"""
for name, klass in self.site_authentication_classes.iteritems():
if klass.auto_detect_site(html_doc):
return klass.plugin_name
return None