<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from werkzeug . utils import import_string <EOL> from flask import Blueprint , Config <EOL> from . core import ListRegistry , ImportPathRegistry <EOL> from . modulediscovery import ModuleDiscoveryRegistry , ModuleAutoDiscoveryRegistry <EOL> class ExtensionRegistry ( ListRegistry ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , app ) : <EOL> super ( ExtensionRegistry , self ) . __init__ ( ) <EOL> for ext_name in app . config . get ( '<STR_LIT>' , [ ] ) : <EOL> self . register ( app , ext_name ) <EOL> def register ( self , app , ext_name ) : <EOL> """<STR_LIT>""" <EOL> ext = import_string ( ext_name ) <EOL> super ( ExtensionRegistry , self ) . register ( ext_name ) <EOL> ext = getattr ( ext , '<STR_LIT>' , ext ) <EOL> ext ( app ) <EOL> def unregister ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> class PackageRegistry ( ImportPathRegistry ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , app ) : <EOL> super ( PackageRegistry , self ) . __init__ ( <EOL> initial = app . config . get ( '<STR_LIT>' , [ ] ) , <EOL> exclude = app . config . get ( '<STR_LIT>' , [ ] ) <EOL> ) <EOL> class ConfigurationRegistry ( ModuleDiscoveryRegistry ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , app , registry_namespace = None ) : <EOL> super ( ConfigurationRegistry , self ) . __init__ ( <EOL> '<STR_LIT>' , <EOL> registry_namespace = registry_namespace , <EOL> with_setup = False , <EOL> ) <EOL> self . new_config = Config ( app . config . root_path ) <EOL> self . discover ( app ) <EOL> self . new_config . update ( app . config ) <EOL> app . config . update ( self . new_config ) <EOL> def register ( self , new_object ) : <EOL> """<STR_LIT>""" <EOL> self . new_config . from_object ( new_object ) <EOL> super ( ConfigurationRegistry , self ) . register ( new_object ) <EOL> def unregister ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> class BlueprintAutoDiscoveryRegistry ( ModuleAutoDiscoveryRegistry ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , module_name = None , app = None , with_setup = False , <EOL> silent = False ) : <EOL> super ( BlueprintAutoDiscoveryRegistry , self ) . __init__ ( <EOL> module_name or '<STR_LIT>' , app = app , with_setup = with_setup , <EOL> silent = silent <EOL> ) <EOL> def _discover_module ( self , pkg ) : <EOL> import_str = pkg + '<STR_LIT:.>' + self . module_name <EOL> try : <EOL> module = import_string ( import_str , silent = self . silent ) <EOL> except ImportError as e : <EOL> self . _handle_importerror ( e , pkg , import_str ) <EOL> return <EOL> except SyntaxError as e : <EOL> self . _handle_syntaxerror ( e , pkg , import_str ) <EOL> return <EOL> candidates = [ ] <EOL> if '<STR_LIT>' in dir ( module ) : <EOL> candidates += getattr ( module , '<STR_LIT>' ) <EOL> if '<STR_LIT>' in dir ( module ) : <EOL> candidates . append ( getattr ( module , '<STR_LIT>' ) ) <EOL> for candidate in candidates : <EOL> if isinstance ( candidate , Blueprint ) : <EOL> self . app . register_blueprint ( <EOL> candidate , <EOL> url_prefix = self . app . config . get ( <EOL> '<STR_LIT>' , { } <EOL> ) . get ( candidate . name ) <EOL> ) <EOL> self . register ( candidate ) </s>
