a
    é´«jÕ  ã                   @   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   ú[/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/importlib_metadata/_adapters.pyÚ<lambda>   ó    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ej	j
dœ‡ 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-PlatformZDynamic)Úorigc                    s"   t ƒ  | ¡}t|ƒ t|ƒ¡ |S ©N)ÚsuperÚ__new__ÚvarsÚupdate)Úclsr   Úres©Ú	__class__r   r   r!   N   s    zMessage.__new__c                 O   s   |   ¡ | _d S r   )Ú_repair_headersÚ_headers)r   ÚargsÚkwargsr   r   r   Ú__init__S   s    zMessage.__init__c                    s
   t ƒ  ¡ S r   )r    Ú__iter__©r   r&   r   r   r-   W   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/   Z   s    
zMessage.__getitem__c                    sH   dd„ ‰ ‡ fdd„t | ƒd D ƒ}| jrD| 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   Úredentj   s    z'Message._repair_headers.<locals>.redentc                    s   g | ]\}}|ˆ |ƒf‘qS r   r   )Ú.0Úkeyr   ©r4   r   r   Ú
<listcomp>q   r
   z+Message._repair_headers.<locals>.<listcomp>r)   ÚDescriptionÚ )r"   Ú_payloadÚappendÚget_payloadÚset_payload)r   Úheadersr   r7   r   r(   i   s    
zMessage._repair_headersc                    s   t ƒ jtƒ d�S )N)Úpolicy)r    Ú	as_stringr   r.   r&   r   r   rA   w   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r0t d|¡}|  ¡  dd¡}||fS )NZKeywordsz\s+ú-Ú_)Úmultiple_use_keysÚget_allÚreÚsplitÚlowerÚreplace)r6   r   Ztkr.   r   r   Ú	transform�   s
    zMessage.json.<locals>.transform)ÚdictÚmapr   )r   rJ   r   r.   r   Újsonz   s    zMessage.json)r   r   r   Ú__doc__ÚsetrL   r   rD   ÚemailÚmessager   r!   r,   r-   r/   r(   rA   ÚpropertyrM   Ú__classcell__r   r   r&   r   r      s   $þÿr   )Úemail.messagerP   Úemail.policyrF   r   Ú_textr   r@   ZEmailPolicyr   rQ   r   r   r   r   r   Ú<module>   s   