<s> from boto . regioninfo import RegionInfo , get_regions <EOL> class S3RegionInfo ( RegionInfo ) : <EOL> def connect ( self , ** kw_params ) : <EOL> """<STR_LIT>""" <EOL> if self . connection_cls : <EOL> return self . connection_cls ( host = self . endpoint , ** kw_params ) <EOL> def regions ( ) : <EOL> """<STR_LIT>""" <EOL> from boto . s3 . connection import S3Connection <EOL> return get_regions ( <EOL> '<STR_LIT>' , <EOL> region_cls = S3RegionInfo , <EOL> connection_cls = S3Connection <EOL> ) <EOL> def connect_to_region ( region_name , ** kw_params ) : <EOL> for region in regions ( ) : <EOL> if '<STR_LIT:host>' in kw_params . keys ( ) : <EOL> if kw_params [ '<STR_LIT:host>' ] not in [ '<STR_LIT>' , None ] : <EOL> region . endpoint = kw_params [ '<STR_LIT:host>' ] <EOL> del kw_params [ '<STR_LIT:host>' ] <EOL> return region . connect ( ** kw_params ) <EOL> else : <EOL> del kw_params [ '<STR_LIT:host>' ] <EOL> if region . name == region_name : <EOL> return region . connect ( ** kw_params ) <EOL> return None </s>
