def parse_accept_lang_header(lang_string):
 result = []
 pieces = accept_language_re.split(lang_string)
 if pieces[(-1)]:
  return []
 for i in range(0, (len(pieces) - 1), 3):
  (first, lang, priority) = pieces[i:(i + 3)]
  if first:
   return []
  priority = ((priority and float(priority)) or 1.0)
  result.append((lang, priority))
 result.sort((lambda x, y: (- cmp(x[1], y[1]))))
 return result

def parse_accept_lang_header ( lang_string ) : result = [ ] pieces = accept_language_re . split ( lang_string ) if pieces [ ( - 1 ) ] : return [ ] for i in range ( 0 , ( len ( pieces ) - 1 ) , 3 ) : ( first , lang , priority ) = pieces [ i : ( i + 3 ) ] if first : return [ ] priority = ( ( priority and float ( priority ) ) or 1.0 ) result . append ( ( lang , priority ) ) result . sort ( ( lambda x , y : ( - cmp ( x [ 1 ] , y [ 1 ] ) ) ) ) return result
parses the lang_string .