HEX
Server: Apache
System: Linux sh-pro142.hostgator.com.br 5.14.0-162.23.1.9991722448259.nf.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 31 18:11:45 UTC 2024 x86_64
User: okform09 (1324)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //usr/libexec/oracle-cloud-agent/plugins/osms/mimeparse.pyc
a

[��ff�@shddlZdZdZdZdZdZGdd�de�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZdS)�Nz1.6.0zJoe Gregoriozjoe@bitworking.orgzMIT License�c@seZdZdS)�MimeTypeParseExceptionN)�__name__�
__module__�__qualname__�rr�m/sparta/input/_build_configuration/image_build+validate/lib/bmcenv/lib64/python3.9/site-packages/mimeparse.pyr
srcCsht�|�\}}|dkrd}d|vr,|�d�nd}|r@t|�dkrNtd�|���|\}}|��|��|fS)anParses 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'})

    :rtype: (str,str,dict)
    �*z*/*�/N�zCan't parse type "{}")�cgi�parse_header�split�lenr�format�strip)�	mime_type�	full_type�params�
type_parts�type�subtyperrr�parse_mime_types�rcCszt|�\}}}|�d|�dd��z2|drJdt|d�krHdksRnd|d<Wntynd|d<Yn0|||fS)aParse 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.

    :rtype: (str,str,dict)
    �q�QNr��1)r�
setdefault�pop�float�
ValueError)�rangerrrrrr�parse_media_range*s&r"c
s�d}d}t|�\}}}|D]�\}}�||dfvp6|dk}	||dfvpJ|dk}
|	r|
r||kr`dpbd}|||krrdptd7}t�fdd�|��D��}||7}|t|�dd	��7}||kr|}�d}qt|�|fS)
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.

    :rtype: (float,int)
    ���rr	�d�
cs0g|](\}}|dkr|�vr|�|krd�qS)rrr)�.0�key�value�rrr�
<listcomp>ks�z.quality_and_fitness_parsed.<locals>.<listcomp>rr)r"�sum�itemsr�get)
r�
parsed_ranges�best_fitness�
best_fit_q�target_type�target_subtype�
target_paramsrr�
type_match�
subtype_match�fitness�
param_matchesrr)r�quality_and_fitness_parsedEs.����
r8cCst||�dS)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
    behaves the same as quality() except that 'parsed_ranges' must be a list of
    parsed media ranges.

    :rtype: float
    r)r8)rr.rrr�quality_parsed{sr9cCsdd�|�d�D�}t||�S)a]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

    :rtype: float
    cSsg|]}t|��qSr�r"�r&�rrrrr*��zquality.<locals>.<listcomp>�,)rr9)r�rangesr.rrr�quality�sr@cCstt|�d��}dd�|D�}g}d}|D]"}|�t||�||f�|d7}q(|��|dddrp|ddprdS)	ajReturn 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'

    :rtype: str
    r>cSsg|]}t|��qSrr:r;rrrr*�r=zbest_match.<locals>.<listcomp>rrr#rr)�
_filter_blankr�appendr8�sort)�	supported�header�split_header�
parsed_header�weighted_matches�posrrrr�
best_match�s�
rJccs|D]}|��r|VqdS)z'Return all non-empty items in the list.N)r)�i�srrrrA�srA)r�__version__�
__author__�	__email__�__license__�__credits__r rrr"r8r9r@rJrArrrr�<module>s6