def key_list(items=None):
 if (items is None):
  items = []
 ret = {}
 if (items and isinstance(items, list)):
  for item in items:
   if ('name' in item):
    if ('id' not in item):
     item['id'] = item['name']
    ret[item['name']] = item
 return ret

def key_list ( items = None ) : if ( items is None ) : items = [ ] ret = { } if ( items and isinstance ( items , list ) ) : for item in items : if ( 'name' in item ) : if ( 'id' not in item ) : item [ 'id' ] = item [ 'name' ] ret [ item [ 'name' ] ] = item return ret
convert list to dictionary using the key as the identifier .