#NEWLINE# def clone_db( source_socket , destination_socket , source_db , destination_db ) : #NEWLINE# #INDENT# src = redis_conn ( source_socket , source_db ) #NEWLINE# dest = redis_conn ( destination_socket , destination_db ) #NEWLINE# dest . flushdb ( ) #NEWLINE# keys = src . keys ( ) #NEWLINE# for key in keys : #NEWLINE# #INDENT# key_type = src . type ( key ) #NEWLINE# if ( key_type == 'string' ) : #NEWLINE# #INDENT# dest . set ( key , src . get ( key ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( key_type == 'set' ) : #NEWLINE# #INDENT# for sval in src . smembers ( key ) : #NEWLINE# #INDENT# dest . sadd ( key , sval ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( key_type == 'hash' ) : #NEWLINE# #INDENT# for ( hkey , hval ) in src . hgetall ( key ) . iteritems ( ) : #NEWLINE# #INDENT# dest . hset ( key , hkey , hval ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise UnsupportedKeyType ( key_type , key )