<s> from django . conf import settings <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> try : <EOL> from django . utils . module_loading import import_module <EOL> except ImportError : <EOL> from django . utils . importlib import import_module <EOL> class MetricsProvider ( object ) : <EOL> """<STR_LIT>""" <EOL> alias = '<STR_LIT>' <EOL> title = '<STR_LIT>' <EOL> params = None <EOL> @ classmethod <EOL> def get_template_name ( cls ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' % cls . alias <EOL> @ classmethod <EOL> def get_params ( cls ) : <EOL> """<STR_LIT>""" <EOL> return cls . params or { } <EOL> class Yandex ( MetricsProvider ) : <EOL> """<STR_LIT>""" <EOL> alias = '<STR_LIT>' <EOL> title = _ ( '<STR_LIT>' ) <EOL> params = { <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : False , <EOL> } <EOL> class Openstat ( MetricsProvider ) : <EOL> """<STR_LIT>""" <EOL> alias = '<STR_LIT>' <EOL> title = _ ( '<STR_LIT>' ) <EOL> params = { <EOL> '<STR_LIT:image>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> class Google ( MetricsProvider ) : <EOL> """<STR_LIT>""" <EOL> alias = '<STR_LIT>' <EOL> title = _ ( '<STR_LIT>' ) <EOL> def get_custom_providers ( ) : <EOL> """<STR_LIT>""" <EOL> providers = getattr ( settings , '<STR_LIT>' , False ) <EOL> if not providers : <EOL> return None <EOL> p_clss = [ ] <EOL> for provider_path in providers : <EOL> path_splitted = provider_path . split ( '<STR_LIT:.>' ) <EOL> mod = import_module ( '<STR_LIT:.>' . join ( path_splitted [ : - <NUM_LIT:1> ] ) ) <EOL> p_cls = getattr ( mod , path_splitted [ - <NUM_LIT:1> ] ) <EOL> p_clss . append ( p_cls ) <EOL> return p_clss <EOL> BUILTIN_PROVIDERS = ( Yandex , Google , Openstat ) <EOL> METRICS_PROVIDERS = get_custom_providers ( ) or BUILTIN_PROVIDERS </s>
