def make_server_description(server, hosts):
 server_type = server['type']
 if (server_type == 'Unknown'):
  return ServerDescription(clean_node(server['address']), IsMaster({}))
 ismaster_response = {'ok': True, 'hosts': hosts}
 if ((server_type != 'Standalone') and (server_type != 'Mongos')):
  ismaster_response['setName'] = 'rs'
 if (server_type == 'RSPrimary'):
  ismaster_response['ismaster'] = True
 elif (server_type == 'RSSecondary'):
  ismaster_response['secondary'] = True
 elif (server_type == 'Mongos'):
  ismaster_response['msg'] = 'isdbgrid'
 ismaster_response['lastWrite'] = {'lastWriteDate': make_last_write_date(server)}
 for field in ('maxWireVersion', 'tags', 'idleWritePeriodMillis'):
  if (field in server):
   ismaster_response[field] = server[field]
 sd = ServerDescription(clean_node(server['address']), IsMaster(ismaster_response), round_trip_time=(server['avg_rtt_ms'] / 1000.0))
 if ('lastUpdateTime' in server):
  sd._last_update_time = (server['lastUpdateTime'] / 1000.0)
 return sd

def make_server_description ( server , hosts ) : server_type = server [ 'type' ] if ( server_type == 'Unknown' ) : return ServerDescription ( clean_node ( server [ 'address' ] ) , IsMaster ( { } ) ) ismaster_response = { 'ok' : True , 'hosts' : hosts } if ( ( server_type != 'Standalone' ) and ( server_type != 'Mongos' ) ) : ismaster_response [ 'setName' ] = 'rs' if ( server_type == 'RSPrimary' ) : ismaster_response [ 'ismaster' ] = True elif ( server_type == 'RSSecondary' ) : ismaster_response [ 'secondary' ] = True elif ( server_type == 'Mongos' ) : ismaster_response [ 'msg' ] = 'isdbgrid' ismaster_response [ 'lastWrite' ] = { 'lastWriteDate' : make_last_write_date ( server ) } for field in ( 'maxWireVersion' , 'tags' , 'idleWritePeriodMillis' ) : if ( field in server ) : ismaster_response [ field ] = server [ field ] sd = ServerDescription ( clean_node ( server [ 'address' ] ) , IsMaster ( ismaster_response ) , round_trip_time = ( server [ 'avg_rtt_ms' ] / 1000.0 ) ) if ( 'lastUpdateTime' in server ) : sd . _last_update_time = ( server [ 'lastUpdateTime' ] / 1000.0 ) return sd
make a serverdescription from server info in a json test .