<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> import os <EOL> from werkzeug . utils import import_string <EOL> from pkg_resources import iter_entry_points , resource_listdir , resource_isdir <EOL> from . core import DictRegistry <EOL> from . modulediscovery import ModuleAutoDiscoveryRegistry <EOL> class EntryPointRegistry ( DictRegistry ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , entry_point_ns , load = True ) : <EOL> super ( EntryPointRegistry , self ) . __init__ ( ) <EOL> self . load = load <EOL> for entry_point_group in iter_entry_points ( entry_point_ns ) : <EOL> self . register ( entry_point_group ) <EOL> def register ( self , entry_point ) : <EOL> """<STR_LIT>""" <EOL> if entry_point . name not in self . registry : <EOL> self . registry [ entry_point . name ] = [ ] <EOL> self . registry [ entry_point . name ] . append ( <EOL> entry_point . load ( ) if self . load else entry_point <EOL> ) <EOL> class PkgResourcesDirDiscoveryRegistry ( ModuleAutoDiscoveryRegistry ) : <EOL> """<STR_LIT>""" <EOL> def _discover_module ( self , pkg ) : <EOL> """<STR_LIT>""" <EOL> if resource_isdir ( pkg , self . module_name ) : <EOL> for filename in resource_listdir ( pkg , self . module_name ) : <EOL> self . register ( os . path . join ( <EOL> os . path . dirname ( import_string ( pkg ) . __file__ ) , <EOL> self . module_name , filename ) <EOL> ) </s>
