<s> """<STR_LIT>""" <EOL> from traits . api import Dict , HasTraits , Str , provides <EOL> from . i_resource_manager import IResourceManager <EOL> from . i_resource_protocol import IResourceProtocol <EOL> @ provides ( IResourceManager ) <EOL> class ResourceManager ( HasTraits ) : <EOL> """<STR_LIT>""" <EOL> resource_protocols = Dict ( Str , IResourceProtocol ) <EOL> def _resource_protocols_default ( self ) : <EOL> """<STR_LIT>""" <EOL> from . file_resource_protocol import FileResourceProtocol <EOL> from . http_resource_protocol import HTTPResourceProtocol <EOL> from . package_resource_protocol import PackageResourceProtocol <EOL> resource_protocols = { <EOL> '<STR_LIT:file>' : FileResourceProtocol ( ) , <EOL> '<STR_LIT:http>' : HTTPResourceProtocol ( ) , <EOL> '<STR_LIT>' : PackageResourceProtocol ( ) <EOL> } <EOL> return resource_protocols <EOL> def file ( self , url ) : <EOL> """<STR_LIT>""" <EOL> protocol_name , address = url . split ( '<STR_LIT>' ) <EOL> protocol = self . resource_protocols . get ( protocol_name ) <EOL> if protocol is None : <EOL> raise ValueError ( '<STR_LIT>' % url ) <EOL> return protocol . file ( address ) </s>
