<s> """<STR_LIT>""" <EOL> from pymongo . master_slave_connection import MasterSlaveConnection as PymongoMasterSlaveConnection <EOL> try : <EOL> from pymongo import MongoClient as PymongoConnection <EOL> except ImportError : <EOL> from pymongo import Connection as PymongoConnection <EOL> from mongokit . connection import MongoKitConnection <EOL> class MasterSlaveConnection ( MongoKitConnection , PymongoMasterSlaveConnection ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , master , slaves = [ ] ) : <EOL> """<STR_LIT>""" <EOL> MongoKitConnection . __init__ ( self ) <EOL> if not isinstance ( master , dict ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> master_connection = PymongoConnection ( ** master ) <EOL> if not slaves : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> slave_connections = list ( ) <EOL> for slave in slaves : <EOL> if not isinstance ( slave , dict ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> slave [ '<STR_LIT>' ] = True <EOL> slave_connections . append ( PymongoConnection ( ** slave ) ) <EOL> PymongoMasterSlaveConnection . __init__ ( self , master_connection , slave_connections ) </s>
