parameters: (accept_lang)
return_statement: return res
docstring: Parses the 'Accept-Language' HTTP header.
  
      Returns a list of language codes in *ascending* order of preference
      (with the most preferred language last).
docstring_summary: Parses the 'Accept-Language' HTTP header.
docstring_tokens: Parses the Accept - Language HTTP header .
function: def parse_accept_lang_header(accept_lang):
      """Parses the 'Accept-Language' HTTP header.
  
      Returns a list of language codes in *ascending* order of preference
      (with the most preferred language last).
      """
      by_q = defaultdict(list)
      for part in accept_lang.split(','):
          m = _accept_lang_re.match(part.strip())
          if not m:
              continue
          lang, qvalue = m.group('lang', 'qvalue')
          # Browser header format is zh-CN, gettext uses zh_CN
          lang = lang.replace('-', '_')
          if qvalue is None:
              qvalue = 1.
          else:
              qvalue = float(qvalue)
          if qvalue == 0:
              continue  # 0 means not accepted
          by_q[qvalue].append(lang)
          if '_' in lang:
              short = lang.split('_')[0]
              if short != 'en':
                  by_q[qvalue].append(short)
  
      res = []
      for qvalue, langs in sorted(by_q.items()):
          res.extend(sorted(langs))
      return res
function_tokens: def parse_accept_lang_header ( accept_lang ) : by_q = defaultdict ( list ) for part in accept_lang . split ( ',' ) : m = _accept_lang_re . match ( part . strip ( ) ) if not m : continue lang , qvalue = m . group ( 'lang' , 'qvalue' ) # Browser header format is zh-CN, gettext uses zh_CN lang = lang . replace ( '-' , '_' ) if qvalue is None : qvalue = 1. else : qvalue = float ( qvalue ) if qvalue == 0 : continue # 0 means not accepted by_q [ qvalue ] . append ( lang ) if '_' in lang : short = lang . split ( '_' ) [ 0 ] if short != 'en' : by_q [ qvalue ] . append ( short ) res = [ ] for qvalue , langs in sorted ( by_q . items ( ) ) : res . extend ( sorted ( langs ) ) return res