o
    ðýðc#
  ã                   @   sp   d dl mZmZmZ d dlmZ d dlmZmZm	Z	m
Z
 g d¢Zdedefdd„Zd	edeeef fd
d„ZdS )é    )ÚHeaderÚdecode_headerÚmake_header)ÚMessage)ÚAnyÚDictÚListÚUnion))zMetadata-VersionF)ÚNameF)ÚVersionF)ÚDynamicT)ÚPlatformT)zSupported-PlatformT)ÚSummaryF)ÚDescriptionF)zDescription-Content-TypeF)ÚKeywordsF)z	Home-pageF)zDownload-URLF)ÚAuthorF)zAuthor-emailF)Ú
MaintainerF)zMaintainer-emailF)ÚLicenseF)Ú
ClassifierT)zRequires-DistT)zRequires-PythonF)zRequires-ExternalT)zProject-URLT)zProvides-ExtraT)zProvides-DistT)zObsoletes-DistTÚfieldÚreturnc                 C   s   |   ¡  dd¡S )Nú-Ú_)ÚlowerÚreplace)r   © r   úI/opt/certbot/lib/python3.10/site-packages/pip/_internal/metadata/_json.pyÚ	json_name%   s   r   Úmsgc                    s¸   dt ttf dtfdd„‰ i }tD ]>\}}|| vrqt|ƒ}|r-‡ fdd„|  |¡D ƒ}nˆ |  |¡ƒ}|dkrKd|v rGd	d„ | d¡D ƒ}n| ¡ }|||< q|  ¡ }|rZ||d
< |S )z;Convert a Message object into a JSON-compatible dictionary.Úhr   c              	   S   st   t | tƒr6g }t| ƒD ]$\}}|dkr(z	| d¡ d}W n ty'   d}Y nw | ||f¡ qtt|ƒƒS t| ƒS )Nzunknown-8bitzutf-8Úlatin1)Ú
isinstancer   r   ÚdecodeÚUnicodeDecodeErrorÚappendÚstrr   )r   ÚchunksÚbytesÚencodingr   r   r   Úsanitise_header,   s   

þz$msg_to_json.<locals>.sanitise_headerc                    s   g | ]}ˆ |ƒ‘qS r   r   ©Ú.0Úv©r)   r   r   Ú
<listcomp>B   s    ÿzmsg_to_json.<locals>.<listcomp>Úkeywordsú,c                 S   s   g | ]}|  ¡ ‘qS r   )Ústripr*   r   r   r   r.   K   s    Údescription)	r	   r   r%   ÚMETADATA_FIELDSr   Úget_allÚgetÚsplitÚget_payload)r   Úresultr   ÚmultiÚkeyÚvalueÚpayloadr   r-   r   Úmsg_to_json)   s(   
ÿ
r=   N)Úemail.headerr   r   r   Úemail.messager   Útypingr   r   r   r	   r3   r%   r   r=   r   r   r   r   Ú<module>   s   