<s> from __future__ import print_function <EOL> from . import exceptions <EOL> from . import entities <EOL> class ShipsProvider : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config ) : <EOL> self . _config = config <EOL> self . _defaults = config . get ( '<STR_LIT>' , { } ) <EOL> def _from_ship_or_defaults ( self , ship , key ) : <EOL> return ship . get ( key , self . _defaults . get ( key ) ) <EOL> def ships ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> class StaticShipsProvider ( ShipsProvider ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config ) : <EOL> ShipsProvider . __init__ ( self , config ) <EOL> self . _ships = dict ( <EOL> ( k , entities . Ship ( <EOL> k , ip = v [ '<STR_LIT>' ] , endpoint = v . get ( '<STR_LIT>' ) , <EOL> docker_port = self . _from_ship_or_defaults ( v , '<STR_LIT>' ) , <EOL> socket_path = self . _from_ship_or_defaults ( v , '<STR_LIT>' ) , <EOL> ssh_tunnel = self . _from_ship_or_defaults ( v , '<STR_LIT>' ) , <EOL> api_version = self . _from_ship_or_defaults ( v , '<STR_LIT>' ) , <EOL> timeout = self . _from_ship_or_defaults ( v , '<STR_LIT>' ) , <EOL> tls = v . get ( '<STR_LIT>' , False ) , <EOL> tls_cert = v . get ( '<STR_LIT>' , None ) , <EOL> tls_key = v . get ( '<STR_LIT>' , None ) , <EOL> tls_verify = v . get ( '<STR_LIT>' , False ) , <EOL> tls_ca_cert = v . get ( '<STR_LIT>' , None ) , <EOL> ssl_version = v . get ( '<STR_LIT>' , None ) ) ) <EOL> for k , v in self . _config [ '<STR_LIT>' ] . items ( ) ) <EOL> def ships ( self ) : <EOL> return self . _ships <EOL> class ShipsProviderFactory : <EOL> """<STR_LIT>""" <EOL> DEFAULT_PROVIDER = '<STR_LIT>' <EOL> PROVIDERS = { <EOL> '<STR_LIT>' : StaticShipsProvider , <EOL> } <EOL> @ staticmethod <EOL> def from_config ( config ) : <EOL> provider = config . get ( '<STR_LIT>' , <EOL> ShipsProviderFactory . DEFAULT_PROVIDER ) <EOL> if provider not in ShipsProviderFactory . PROVIDERS : <EOL> raise exceptions . EnvironmentConfigurationException ( <EOL> '<STR_LIT>' <EOL> . format ( provider , <EOL> '<STR_LIT:U+002CU+0020>' . join ( ShipsProviderFactory . PROVIDERS . keys ( ) ) ) ) <EOL> return ShipsProviderFactory . PROVIDERS [ provider ] ( config ) </s>
