o
    Vh                     @   sX   d dl Zd dlZd dlZd dlZddlmZ G dd dejjZ	G dd dej
jZdS )    N   )
FoldedCasec                   @   s   e Zd Zdd ZdS )	RawPolicyc                 C   s8   | j tj|ddd d  }| d| | j  S )N        c                 S   s   dS )NT )liner   r   p/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/importlib_metadata/_adapters.py<lambda>   s    z RawPolicy.fold.<locals>.<lambda>)prefix	predicatez: )linesepjointextwrapindentlstrip
splitlines)selfnamevaluefoldedr   r   r   fold
   s   zRawPolicy.foldN)__name__
__module____qualname__r   r   r   r   r   r   	   s    r   c                       s~   e Zd ZdZeeeg dZ	 dej	j
f fddZdd Z fdd	Z fd
dZdd Z fddZedd Z  ZS )Messagea  
    Specialized Message subclass to handle metadata naturally.

    Reads values that may have newlines in them and converts the
    payload to the Description.

    >>> msg_text = textwrap.dedent('''
    ...     Name: Foo
    ...     Version: 3.0
    ...     License: blah
    ...             de-blah
    ...     <BLANKLINE>
    ...     First line of description.
    ...     Second line of description.
    ...     <BLANKLINE>
    ...     Fourth line!
    ...     ''').lstrip().replace('<BLANKLINE>', '')
    >>> msg = Message(email.message_from_string(msg_text))
    >>> msg['Description']
    'First line of description.\nSecond line of description.\n\nFourth line!\n'

    Message should render even if values contain newlines.

    >>> print(msg)
    Name: Foo
    Version: 3.0
    License: blah
            de-blah
    Description: First line of description.
            Second line of description.
    <BLANKLINE>
            Fourth line!
    <BLANKLINE>
    <BLANKLINE>
    )

ClassifierzObsoletes-DistPlatformzProject-URLzProvides-DistzProvides-ExtrazRequires-DistzRequires-ExternalzSupported-PlatformDynamicorigc                    s"   t  | }t|t| |S N)super__new__varsupdate)clsr   res	__class__r   r   r!   M   s   zMessage.__new__c                 O   s   |   | _d S r   )_repair_headers_headers)r   argskwargsr   r   r   __init__R   s   zMessage.__init__c                    s
   t   S r   )r    __iter__r   r&   r   r   r-   V   s   
zMessage.__iter__c                    s    t  |}|du rt||S )a"  
        Override parent behavior to typical dict behavior.

        ``email.message.Message`` will emit None values for missing
        keys. Typical mappings, including this ``Message``, will raise
        a key error for missing keys.

        Ref python/importlib_metadata#371.
        N)r    __getitem__KeyError)r   itemr%   r&   r   r   r/   Y   s   
zMessage.__getitem__c                    sH   dd   fddt | d D }| jr"|d|  f | d |S )Nc                 S   s&   d}| r
d| | vr| S t ||  S )zCorrect for RFC822 indentationr   
)r   dedent)r   r   r   r   r   redenti   s   z'Message._repair_headers.<locals>.redentc                    s   g | ]
\}}| |fqS r   r   ).0keyr   r4   r   r   
<listcomp>p   s    z+Message._repair_headers.<locals>.<listcomp>r)   Description )r"   _payloadappendget_payloadset_payload)r   headersr   r7   r   r(   h   s   
zMessage._repair_headersc                    s   t  jt dS )N)policy)r    	as_stringr   r.   r&   r   r   rA   v   s   zMessage.as_stringc                    s     fdd}t t|tt S )z[
        Convert PackageMetadata to a JSON-compatible format
        per PEP 0566.
        c                    sH   |  j v r
 | n |  }| dkrtd|}|  dd}||fS )NKeywordsz\s+-_)multiple_use_keysget_allresplitlowerreplace)r6   r   tkr.   r   r   	transform   s
   zMessage.json.<locals>.transform)dictmapr   )r   rL   r   r.   r   jsony   s   zMessage.json)r   r   r   __doc__setrN   r   rE   emailmessager   r!   r,   r-   r/   r(   rA   propertyrO   __classcell__r   r   r&   r   r      s"    $r   )email.messagerR   email.policyrG   r   _textr   r@   EmailPolicyr   rS   r   r   r   r   r   <module>   s    
