def parse_servers(result):
 from version import PROTOCOL_VERSION
 servers = {}
 for item in result:
  host = item[1]
  out = {}
  version = None
  pruning_level = '-'
  if (len(item) > 2):
   for v in item[2]:
    if re.match('[st]\\d*', v):
     (protocol, port) = (v[0], v[1:])
     if (port == ''):
      port = DEFAULT_PORTS[protocol]
     out[protocol] = port
    elif re.match('v(.?)+', v):
     version = v[1:]
    elif re.match('p\\d*', v):
     pruning_level = v[1:]
    if (pruning_level == ''):
     pruning_level = '0'
  try:
   is_recent = (cmp(util.normalize_version(version), util.normalize_version(PROTOCOL_VERSION)) >= 0)
  except Exception:
   is_recent = False
  if (out and is_recent):
   out['pruning'] = pruning_level
   servers[host] = out
 return servers

def parse_servers ( result ) : from version import PROTOCOL_VERSION servers = { } for item in result : host = item [ 1 ] out = { } version = None pruning_level = '-' if ( len ( item ) > 2 ) : for v in item [ 2 ] : if re . match ( '[st]\\d*' , v ) : ( protocol , port ) = ( v [ 0 ] , v [ 1 : ] ) if ( port == '' ) : port = DEFAULT_PORTS [ protocol ] out [ protocol ] = port elif re . match ( 'v(.?)+' , v ) : version = v [ 1 : ] elif re . match ( 'p\\d*' , v ) : pruning_level = v [ 1 : ] if ( pruning_level == '' ) : pruning_level = '0' try : is_recent = ( cmp ( util . normalize_version ( version ) , util . normalize_version ( PROTOCOL_VERSION ) ) >= 0 ) except Exception : is_recent = False if ( out and is_recent ) : out [ 'pruning' ] = pruning_level servers [ host ] = out return servers
parse servers list into dict format .