Ñò ñG“Ic@sÊdZddkZyeWn#ej oddklZnXeidƒZd„Zdefd„ƒYZ defd „ƒYZ d e fd „ƒYZ d e fd „ƒYZ de fd„ƒYZ dS(sÚ Parses a variety of ``Accept-*`` headers. These headers generally take the form of:: value1; q=0.5, value2; q=0 Where the ``q`` parameter is optional. In theory other parameters exists, but this ignores them. iÿÿÿÿN(tsorteds*,\s*([^\s;,\n]+)(?:[^,]*?;\s*q=([0-9.]*))?cCsÃg}x¶tid|ƒD]¡}|idƒ}|djoqn|idƒpd}|p d}n?y"ttt|ƒdƒdƒ}Wntj o d}nX|i||fƒqW|S(s– Parses an ``Accept-*`` style header. A list of ``[(value, quality), ...]`` is returned. ``quality`` will be 1 if it was not given. t,itqiti(tpart_retfinditertgrouptmaxtmintfloatt ValueErrortappend(tvaluetresulttmatchtnametquality((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt parse_accepts  " tAcceptcBszeZdZd„Zd„Zd„Zed„Zd„Zd„Z d„Z d„Z d d „Z d d „Zd „ZRS( s´ Represents a generic ``Accept-*`` style header. This object should not be modified. To add items you can use ``accept_obj + 'accept_thing'`` to get a new object cCs%||_||_t|ƒ|_dS(N(t header_namet header_valueRt_parsed(tselfRR((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt__init__4s  cCs/d|iitt|ƒƒ|it|ƒfS(Ns<%s at 0x%x %s: %s>(t __class__t__name__tabstidRtstr(R((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt__repr__9s cCs[g}xE|iD]:\}}|djod||f}n|i|ƒqWdi|ƒS(Nis %s;q=%0.1fs, (RR tjoin(RR RR((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt__str__?s  c CsFt|tƒo |i}nt|dƒot|iƒdd„ƒ}nt|ttfƒotg}xX|D]P}t|ttfƒo'|\}}|id||fƒqo|i|ƒqoWdi |ƒ}nt |ƒ}|i}|o||}}n|p |}n |p |}n|d|}|i |i |ƒS(NtitemstkeycSs |d S(i((titem((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pytLss%s; q=%ss, ( t isinstanceRRthasattrRR tlistttupleR RRRR( RtothertreversedR R"RRtmy_valuet new_value((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt__add__Hs.      cCs|i|tƒS(N(R,tTrue(RR(((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt__radd__bscCs6x/|iD]$\}}|i||ƒotSq WdS(s[ Returns true if the given object is listed in the accepted types. N(Rt_matchR-(RRR"R((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt __contains__es cCs6x/|iD]$\}}|i||ƒo|Sq WdS(sl Return the quality of the given match. Returns None if there is no match (not 0). N(RR/tNone(RRR"R((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyRns   cCst|ptdƒ‚nxR|D]J}x/|iD]$\}}|i||ƒo|Sq.W|djodSqW|dS(s Returns the first match in the sequences of matches that is allowed. Ignores quality. Returns the first item if nothing else matches; or if you include None at the end of the match list then that will be returned. s!You must pass in a non-empty listiN(R RR/R1(RtmatchesRR"R((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt first_matchxs     c Cs®d}|}x›|D]“}t|ttfƒo|\}}n |}d}xX|iD]M\}} || } | |joqUn|i||ƒo| }|}qUqUWqW|S(s„ Returns the best match in the sequence of matches. The sequence can be a simple sequence, or you can have ``(match, server_quality)`` items in the sequence. If you have these tuples then the client quality is multiplied by the server_quality to get a total. default_match (default None) is returned if there is no intersection. iÿÿÿÿi(R$R'R&RR/( RR2t default_matcht best_qualityt best_matcht match_itemRtserver_qualityR"Rtpossible_quality((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR6Šs"    cCs˜g}t|idd„ƒD]\}}||q~}|oTxQt|ƒD]2\}}|i||ƒog||d)PqMqMW|i|ƒn|S(sj Return all the matches in order of quality, with fallback (if given) at the end. R!cSs |d S(i((tiq((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR#¬si(RRt enumerateR/R (Rtfallbackt_[1]tiRR tindexR"((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt best_matches¦s9  cCs#|iƒ|iƒjp |djS(Nt*(tlower(RR"R((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR/¶sN(Rt __module__t__doc__RRRtFalseR,R.R0RR3R1R6R@R/(((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR,s       t NilAcceptcBsweZdZeZd„Zd„Zd„Zd„Zd„Z d„Z dd„Z d „Z d d „Zd d „ZRS( s4 Represents an Accept header with no value. cCs ||_dS(N(R(RR((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyRÁscCsd|ii|i|ifS(Ns<%s for %s: %s>(RRRt MasterClass(R((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyRÄscCsdS(NR((R((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyRÈscCs3t||iƒo|S|i|idƒ|SdS(NR(R$RGR(RR"((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR,ËscCs3t||iƒo|S||i|idƒSdS(NR(R$RGR(RR"((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR.ÑscCstS(N(R-(RR"((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR0×sicCsdS(Ni((RRtdefault_quality((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyRÚscCs|dS(Ni((RR2((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR3ÝscCspd}|}x]|D]U}t|ttfƒo|\}}n |}d}||jo|}|}qqW|S(Niÿÿÿÿi(R$R&R'(RR2R4R5R6R7RR((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR6às cCs|o|gSgSdS(N((RR<((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR@îsN(RRCRDRRGRRRR,R.R0RR3R1R6R@(((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyRF¹s         tNoAcceptcBseZd„ZRS(cCstS(N(RE(RR"((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR0ös(RRCR0(((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyRIôst MIMEAcceptcBs eZdZd„Zd„ZRS(s† Represents the ``Accept`` header, which is a list of mimetypes. This class knows about mime wildcards, like ``image/*`` cCsl|iƒ}|djo d}n|iƒ}|djo d}nd|jotSd|jotd|ƒ‚n|iddƒ\}}|iddƒ\}}|djo!|djotd|ƒ‚n|djo|djotS|djo |djp|djo|djotS||jo,|djp|djp ||jotStS(NRAs*/*t/s%MIME matches must include / (bad: %r)is$A MIME type of %r doesn't make sense(RBRER tsplitR-(RR"Rt item_majort item_minort match_majort match_minor((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyR/s4          cCs1d|jp$d|jpd|jp d|jS(s@ Returns true if any HTML-like type is accepted s text/htmlsapplication/xhtml+xmlsapplication/xmlstext/xml((R((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt accept_htmls   (RRCRDR/RQ(((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyRJùs t MIMENilAcceptcBseZeZRS((RRCRJRG(((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyRR(s(RDtreRt NameErrort webob.compattcompileRRtobjectRRFRIRJRR(((s5/usr/lib/python2.6/site-packages/webob/acceptparse.pyt s   ;/