+
    ÂHàj‚  ã                   ó`   € R t ^ RIHt ^ RIHt RtRtRtRtRt	R t
R	 tR
 tR tR tR tR tR# )au  MIME-Type Parser

This module provides basic functions for handling mime-types. It can handle
matching mime-types against a list of media-ranges. See section 14.1 of the
HTTP specification [RFC 2616] for a complete explanation.

   http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1

Contents:
 - parse_mime_type():   Parses a mime-type into its component parts.
 - parse_media_range(): Media-ranges are mime-types with wild-cards and a 'q'
                          quality parameter.
 - quality():           Determines the quality ('q') of a mime-type when
                          compared against a list of media-ranges.
 - quality_parsed():    Just like quality() except the second parameter must be
                          pre-parsed.
 - best_match():        Choose the mime-type with the highest quality ('q')
                          from a list of candidates.
)Úabsolute_import)Úreducez0.1.3zJoe Gregoriozjoe@bitworking.orgzMIT LicenseÚ c                ó–  € V P                  R4      p\        VR,           UUu. uF;  p\        VP                  R^4       Uu. uF  q3P                  4       NK  	  up4      NK=  	  upp4      pV^ ,          P                  4       pVR8X  d   RpVP                  R4      w  rgVP                  4       VP                  4       V3# u upi u uppi )a:  Parses a mime-type into its component parts.

Carves up a mime-type and returns a tuple of the (type, subtype, params)
where 'params' is a dictionary of all the parameters for the media range.
For example, the media range 'application/xhtml;q=0.5' would get parsed
into:

   ('application', 'xhtml', {'q', '0.5'})
Ú;:é   NNÚ=Ú*z*/*Ú/)ÚsplitÚdictÚtupleÚstrip)Ú	mime_typeÚpartsÚparamÚsÚparamsÚ	full_typeÚtypeÚsubtypes   &       Ú›/home/ubuntu/.hermes/installs/5f0a1ff4045d044e/environments/50f6b671e3f94b538e344231dfcb664f/venv/lib/python3.14/site-packages/googleapiclient/mimeparse.pyÚparse_mime_typer   #   s©   € ð �O‰O˜CÓ €EÜØFKÈBÆiÔPÁi¸UŒ 5§;¡;¨s°AÔ#6Ó7Ñ#6˜a—‘–	Ñ#6Ñ7Ö	8ÁiÒPó€Fð �a•—‘Ó €Ið �CÔØˆ	Ø—o‘o cÓ*�O€Tà�J‰J‹L˜'Ÿ-™-›/¨6Ð2Ð2ùò 8ùÓPs   £C
ÁC ÁC
Ã C
c                óè   € \        V 4      w  rpRV9  gV   VR,          '       dG   \        VR,          4      '       d/   \        VR,          4      ^8”  g   \        VR,          4      ^ 8  d   RVR&   WV3# )aË  Parse a media-range into its component parts.

Carves up a media range and returns a tuple of the (type, subtype,
params) where 'params' is a dictionary of all the parameters for the media
range.  For example, the media range 'application/*;q=0.5' would get parsed
into:

   ('application', '*', {'q', '0.5'})

In addition this function also guarantees that there is a value for 'q'
in the params dictionary, filling it in with a proper default if
necessary.
ÚqÚ1)r   Úfloat)Úranger   r   r   s   &   r   Úparse_media_ranger   ;   si   € ô .¨eÓ4Ñ€T�Fà�6ÔØ�c�{Œ{Ü�V˜C•[×!Ò!Ü�˜•Ó Ô!Ü�˜•Ó Ô!àˆˆs‰à˜6Ð"Ð"ó    c                óH  € Rp^ p\        V 4      w  rEpV Fø  w  rxp	Wt8H  ;'       g    VR8H  ;'       g    VR8H  p
W…8H  ;'       g    VR8H  ;'       g    VR8H  pV
'       g   KL  V'       g   KV  \        R VP                  4        UUu. uF'  w  rÍVR8w  g   K  WÉ9   g   K  WÙV,          8X  g   K%  ^NK)  	  upp^ 4      pWt8H  ;'       d    ^d;'       g    ^ pYøV8H  ;'       d    ^
;'       g    ^ ,          pWþ,          pWò8”  g   Kí  TpV	R,          pKú  	  V\        V4      3# u uppi )a›  Find the best match for a mime-type amongst parsed media-ranges.

Find the best match for a given mime-type against a list of media_ranges
that have already been parsed by parse_media_range(). Returns a tuple of
the fitness value and the value of the 'q' quality parameter of the best
match, or (-1, 0) if no match was found. Just as for quality_parsed(),
'parsed_ranges' must be a list of parsed media ranges.
r	   c                 ó   € W,           # ©N© )ÚxÚys   &&r   Ú<lambda>Ú,fitness_and_quality_parsed.<locals>.<lambda>i   s   € ˜QžUr   r   éÿÿÿÿ)r   r   Úitemsr   )r   Úparsed_rangesÚbest_fitnessÚ
best_fit_qÚtarget_typeÚtarget_subtypeÚtarget_paramsr   r   r   Ú
type_matchÚsubtype_matchÚkeyÚvalueÚparam_matchesÚfitnesss   &&              r   Úfitness_and_quality_parsedr6   V   sB  € ð €LØ€JÜ3DÀYÓ3OÑ0€[ -Û#0Ñˆ˜ØÑ(×MÐM¨D°C©K×MÐM¸;È#Ñ;Mˆ
àÑ%×PÐP¨°C©×PÐP¸>ÈSÑ;Pð 	÷ ‰:Ÿ-™-Ü"Ù"ð )6×(;Ñ(;Ô(=ôá(=™˜Ø˜c‘zô à&)¡mô à8=ÈÅÑ8L÷ �AÙ(=òð
 óˆMð Ñ*×3Ð3°×8Ð8°qˆGØ >Ñ1×9Ð9°r×>Ð>¸QÕ>ˆGØÕ$ˆGØÖ%Ø&�Ø# C�[’
ñ) $1ð, œ˜zÓ*Ð*Ð*ùós   ÂDÂDÂ
DÂ,Dc                ó&   € \        W4      ^,          # )a~  Find the best match for a mime-type amongst parsed media-ranges.

Find the best match for a given mime-type against a list of media_ranges
that have already been parsed by parse_media_range(). Returns the 'q'
quality parameter of the best match, 0 if no match was found. This function
bahaves the same as quality() except that 'parsed_ranges' must be a list of
parsed media ranges.
)r6   )r   r*   s   &&r   Úquality_parsedr8   {   s   € ô & iÓ?ÀÕBÐBr   c                ót   € VP                  R4       Uu. uF  p\        V4      NK  	  pp\        W4      # u upi )a3  Return the quality ('q') of a mime-type against a list of media-ranges.

Returns the quality 'q' of a mime-type when compared against the
media-ranges in ranges. For example:

>>> quality('text/html','text/*;q=0.3, text/html;q=0.7,
              text/html;level=1, text/html;level=2;q=0.4, */*;q=0.5')
0.7

Ú,)r   r   r8   )r   ÚrangesÚrr*   s   &&  r   Úqualityr=   ˆ   s:   € ð 4:·<±<ÀÔ3DÓEÑ3D¨aÔ& qÖ)Ñ3D€MÐEä˜)Ó3Ð3ùò Fs   ”5c                ój  € \        VP                  R4      4      pV Uu. uF  p\        V4      NK  	  pp. p^ pV  F(  pVP                  \	        Wt4      Wg34       V^,          pK*  	  VP                  4        VR,          ^ ,          ^,          ;'       d    VR,          ^,          ;'       g    R# u upi )a1  Return mime-type with the highest quality ('q') from list of candidates.

Takes a list of supported mime-types and finds the best match for all the
media-ranges listed in header. The value of header must be a string that
conforms to the format of the HTTP Accept: header. The value of 'supported'
is a list of mime-types. The list of supported mime-types should be sorted
in order of increasing desirability, in case of a situation where there is
a tie.

>>> best_match(['application/xbel+xml', 'text/xml'],
               'text/*;q=0.5,*/*; q=0.1')
'text/xml'
r:   r   r(   )Ú_filter_blankr   r   Úappendr6   Úsort)Ú	supportedÚheaderÚsplit_headerr<   Úparsed_headerÚweighted_matchesÚposr   s   &&      r   Ú
best_matchrH   ˜   s°   € ô ! §¡¨cÓ!2Ó3€LÙ3?Ó@±<¨aÔ& qÖ)±<€MÐ@ØÐØ
€CÛˆ	Ø×ÑÜ'¨	ÓAÀ3ÐRô	
ð 	ˆq�Šñ	 ð
 ×ÑÔà˜BÕ Õ" 1Õ%×AÐAÐ*:¸2Õ*>¸qÕ*A×GÐGÀRÐGùò As   ŸB0c              #   óX   "  € V  F  pVP                  4       '       g   K  Vx € K!  	  R # 5ir"   )r   )Úir   s   & r   r?   r?   ´   s   é € ÛˆØ�7‰7�9Œ9ØŒGó ùs   ‚* 
*N)Ú__doc__Ú
__future__r   Ú	functoolsr   Ú__version__Ú
__author__Ú	__email__Ú__license__Ú__credits__r   r   r6   r8   r=   rH   r?   r#   r   r   Ú<module>rS      sQ   ðñ
õ& 'å à€Ø€
Ø €	Ø€Ø€ò3ò0#ò6"+òJ
Cò4ò Hô8r   