§
    (¶Õi™$  ã                   ó  — d Z ddlZddlZddlZddgZdZ ej        eed¬¦  «         d„ Z ej	        d	¦  «        j
        Z G d
„ de¦  «        Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zddg fd„Zdd„Zg fd„Zd„ Zd„ Zd„ Zedk    r e¦   «          dS dS )z%Mailcap file handling.  See RFC 1524.é    NÚgetcapsÚ	findmatchztThe {name} module is deprecated and will be removed in Python {remove}. See the mimetypes module for an alternative.)é   é   )Úremovec                 ó"   — d| v r
d| d         fS dS )NÚlinenor   )é   r   © )Úentrys    ú/usr/lib/python3.11/mailcap.pyÚlineno_sort_keyr      s!   € à�5ÐÐØ�%˜”/Ð!Ð!àˆtó    z[^\xa1-\U0010FFFF\w@+=:,./-]c                   ó   — e Zd ZdZdS )ÚUnsafeMailcapInputz)Warning raised when refusing unsafe inputN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r      s   € € € € € Ø3Ð3Ð3Ð3r   r   c                  ó2  — i } d}t          ¦   «         D ]ƒ}	 t          |d¦  «        }n# t          $ r Y Œ w xY w|5  t          ||¦  «        \  }}ddd¦  «         n# 1 swxY w Y   |                     ¦   «         D ]\  }}|| vr|| |<   Œ| |         |z   | |<   ŒŒ„| S )a   Return a dictionary containing the mailcap database.

    The dictionary maps a MIME type (in all lowercase, e.g. 'text/plain')
    to a list of dictionaries corresponding to mailcap entries.  The list
    collects all the entries for that MIME type from all available mailcap
    files.  Each dictionary contains key-value pairs for that MIME type,
    where the viewing command is stored with the key "view".

    r   ÚrN)ÚlistmailcapfilesÚopenÚOSErrorÚ_readmailcapfileÚitems)Úcapsr	   ÚmailcapÚfpÚmorecapsÚkeyÚvalues          r   r   r      s  € ð €DØ€FÝ#Ñ%Ô%ð .ð .ˆð	Ý�g˜sÑ#Ô#ˆBˆBøÝð 	ð 	ð 	ØˆHð	øøøàð 	<ð 	<Ý/°°FÑ;Ô;ÑˆH�fð	<ð 	<ð 	<ñ 	<ô 	<ð 	<ð 	<ð 	<ð 	<ð 	<ð 	<øøøð 	<ð 	<ð 	<ð 	<à"Ÿ.š.Ñ*Ô*ð 	.ð 	.‰JˆC�Ø˜$�;�;Ø!��S‘	�	à  œI¨Ñ-��S‘	�	ð		.ð
 €Ks   –'§
4³4¹AÁA	Á A	c                  óÞ   — dt           j        v r2t           j        d         } |                      t           j        ¦  «        }n,dt           j        v rt           j        d         }nd}|dz   dddg}|S )z7Return a list of all mailcap files found on the system.ÚMAILCAPSÚHOMEú.z	/.mailcapz/etc/mailcapz/usr/etc/mailcapz/usr/local/etc/mailcap)ÚosÚenvironÚsplitÚpathsep)ÚpathstrÚmailcapsÚhomes      r   r   r   9   sp   € ð •R”ZÐÐÝ”*˜ZÔ(ˆØ—=’=¥¤Ñ,Ô,ˆˆà•R”ZÐÐÝ”:˜fÔ%ˆDˆDð ˆDØ˜;Ñ&¨Ø"Ð$<ð>ˆà€Or   c                 ób   — t          j        dt          d¦  «         t          | d¦  «        \  }}|S )z?Read a mailcap file and return a dictionary keyed by MIME type.z2readmailcapfile is deprecated, use getcaps insteadé   N)ÚwarningsÚwarnÚDeprecationWarningr   )r   r   Ú_s      r   Úreadmailcapfiler4   K   s6   € å„MÐFÝ$ añ)ô )ð )å˜r 4Ñ(Ô(�G€Dˆ!Ø€Kr   c                 ó–  — i }	 |                       ¦   «         }|s�n+|d         dk    s|                     ¦   «         dk    rŒ>|}|dd…         dk    r3|                       ¦   «         }|sd}|dd…         |z   }|dd…         dk    °3t          |¦  «        \  }}|r|sŒ˜|�
||d	<   |dz  }|                     d
¦  «        }t	          t          |¦  «        ¦  «        D ]}||                              ¦   «         ||<   Œ d
                     |¦  «                             ¦   «         }||v r||                              |¦  «         n|g||<   �ŒC||fS )a�  Read a mailcap file and return a dictionary keyed by MIME type.

    Each MIME type is mapped to an entry consisting of a list of
    dictionaries; the list will contain more than one such dictionary
    if a given MIME type appears more than once in the mailcap file.
    Each dictionary contains key-value pairs for that MIME type, where
    the viewing command is stored with the key "view".
    r
   r   ú#Ú éþÿÿÿNz\
ú
r	   ú/)	ÚreadlineÚstripÚ	parseliner)   ÚrangeÚlenÚjoinÚlowerÚappend)	r   r	   r   ÚlineÚnextliner!   ÚfieldsÚtypesÚjs	            r   r   r   S   sw  € ð €Dð!Ø�{Š{‰}Œ}ˆØÐ‘Uà�Œ7�cŠ>ˆ>˜TŸZšZ™\œ\¨RÒ/Ð/ØØˆà�r�s�sŒm˜vÒ%Ð%Ø—{’{‘}”}ˆHØÐ,¨˜XØ˜˜˜”9˜xÑ'ˆDð �r�s�sŒm˜vÒ%Ð%õ
   ‘o”o‰ˆˆVØð 	˜ð 	ØØÐØ%ˆF�8ÑØ�a‰KˆFà—	’	˜#‘”ˆÝ•s˜5‘z”zÑ"Ô"ð 	(ð 	(ˆAØ˜Q”x—~’~Ñ'Ô'ˆE�!‰HˆHØ�hŠh�u‰oŒo×#Ò#Ñ%Ô%ˆà�$ˆ;ˆ;Ø�ŒI×Ò˜VÑ$Ô$Ð$Ð$à˜ˆD�‰Iñ9!ð: �ˆ<Ðr   c                 óÞ  — g }dt          | ¦  «        }}||k     r4t          | ||¦  «        \  }}|                     |¦  «         |dz   }||k     °4t          |¦  «        dk     rdS |d         |d         |dd…         }}}d|i}|D ]g}|                     d¦  «        }|dk     r|}d}	n;|d|…                              ¦   «         }||dz   d…                              ¦   «         }	||v rŒb|	||<   Œh||fS )	zÈParse one entry in a mailcap file and return a dictionary.

    The viewing command is stored as the value with the key "view",
    and the rest of the fields produce key-value pairs in the dict.
    r   r
   r/   ©NNNÚviewú=r7   )r?   Ú
parsefieldrB   Úfindr<   )
rC   rE   ÚiÚnÚfieldr!   rJ   ÚrestÚfkeyÚfvalues
             r   r=   r=   |   s   € ð €FØ�c�$‰iŒi€q€AØ
ˆaŠ%ˆ%Ý˜d A qÑ)Ô)‰ˆˆqØ�Š�eÑÔÐØˆa‰Cˆð ˆaŠ%ˆ%õ ˆ6�{„{�Q‚€ØˆzØ˜Q”i ¨¤¨F°1°2°2¬Jˆtˆ€CØ�dˆ^€FØð "ð "ˆØ�JŠJ�s‰OŒOˆØˆqŠ5ˆ5ØˆDØˆFˆFà˜˜!˜”9—?’?Ñ$Ô$ˆDØ˜1˜Q™3˜4˜4”[×&Ò&Ñ(Ô(ˆFØ�6ˆ>ˆ>àà!ˆF�4‰LˆLØ�ˆ;Ðr   c                 óš   — |}||k     r&| |         }|dk    rn|dk    r|dz   }n|dz   }||k     °&| ||…                               ¦   «         |fS )z/Separate one key-value pair in a mailcap entry.ú;ú\r/   r
   )r<   )rC   rN   rO   ÚstartÚcs        r   rL   rL   ›   sn   € à€EØ
ˆaŠ%ˆ%Ø�ŒGˆØ�Š8ˆ8ØØ�$ŠYˆYØ�!‘ˆAˆAà�!‘ˆAð ˆaŠ%ˆ%ð ��a�Œ=×ÒÑ Ô  !Ð#Ð#r   rJ   z	/dev/nullc                 óF  — t          |¦  «        r"d|›d�}t          j        |t          ¦  «         dS t	          | ||¦  «        }|D ][}d|v r5t          |d         ||¦  «        }|€Œ |rt          j        |¦  «        dk    rŒ;t          ||         |||¦  «        }	|	�|	|fc S Œ\dS )a  Find a match for a mailcap entry.

    Return a tuple containing the command line, and the mailcap entry
    used; (None, None) if no match is found.  This may invoke the
    'test' command of several matching entries before deciding which
    entry to use.

    z&Refusing to use mailcap with filename z . Use a safe temporary filename.rI   ÚtestNr   )Ú_find_unsafer0   r1   r   ÚlookupÚsubstr'   Úsystem)
r   ÚMIMEtyper!   ÚfilenameÚplistÚmsgÚentriesÚerZ   Úcommands
             r   r   r   «   sÙ   € õ �HÑÔð ð Ø\dÐ\dÐ\dÐfˆÝŒ�cÕ-Ñ.Ô.Ð.ØˆzÝ�T˜8 SÑ)Ô)€Gàð 	ð 	ˆØ�Qˆ;ˆ;Ý˜˜6œ H¨eÑ4Ô4ˆDØˆ|ØØð �œ	 $™œ¨1Ò,Ð,ØÝ˜˜#œ ¨(°EÑ:Ô:ˆØÐØ˜A�:ÐÐÐð àˆ:r   c                 óÔ   ‡— g }|| v r|| |         z   }|                      d¦  «        }|d         dz   }|| v r|| |         z   }‰�ˆfd„|D ¦   «         }t          |t          ¬¦  «        }|S )Nr:   r   z/*c                 ó   •— g | ]}‰|v ¯|‘Œ	S r   r   )Ú.0rd   r!   s     €r   ú
<listcomp>zlookup.<locals>.<listcomp>Ï   s   ø€ Ð2Ð2Ð2˜¨°¨¨�1¨¨¨r   )r!   )r)   Úsortedr   )r   r_   r!   rc   Ú	MIMEtypess     `  r   r\   r\   Æ   sŽ   ø€ Ø€GØ�4ÐÐØ˜D œNÑ*ˆØ—’˜sÑ#Ô#€IØ˜Œ|˜dÑ"€HØ�4ÐÐØ˜D œNÑ*ˆØ
€Ø2Ð2Ð2Ð2˜gÐ2Ñ2Ô2ˆÝ�W¥/Ð2Ñ2Ô2€GØ€Nr   c                 ó’  — d}dt          | ¦  «        }}||k     �r,| |         }|dz   }|dk    r|dk    r| ||dz   …         }|dz   }||z   }nô| |         }|dz   }|dk    r||z   }nÛ|dk    r||z   }nÏ|dk    r7t          |¦  «        r"d|›d	�}t          j        |t          ¦  «         d S ||z   }n’|d
k    r„|}	||k     r#| |         dk    r|dz   }||k     r| |         dk    °| |	|…         }
|dz   }t          |
|¦  «        }t          |¦  «        r%d|›d|
›d�}t          j        |t          ¦  «         d S ||z   }n|dz   |z   }||k     �°,|S )Nr7   r   r
   ú%rV   ÚsÚtz!Refusing to substitute MIME type z into a shell command.ú{ú}z!Refusing to substitute parameter z (z) into a shell command)r?   r[   r0   r1   r   Ú	findparam)rP   r_   r`   ra   ÚresrN   rO   rX   rb   rW   ÚnameÚparams               r   r]   r]   Ó   sÈ  € à
€CØ�c�%‰jŒj€q€AØ
ˆaŠ%‰%Ø�!ŒHˆ˜!˜A™#�aØ�Š8ˆ8Ø�DŠyˆyØ˜!˜A˜a™C˜%”L� a¨¡c !Ø˜‘'ˆCˆCà�a”ˆA˜a ™c˜!Ø�CŠxˆxØ˜A‘g��Ø�c’�Ø˜H‘n��Ø�c’�Ý Ñ)Ô)ð  ð  ØYaÐYaÐYaÐc�CÝ”M #Õ'9Ñ:Ô:Ð:Ø˜4Ø˜H‘n��Ø�c’�Ø�Ø˜!’e�e  a¤¨C¢ Ø˜!™�Að ˜!’e�e  a¤¨C¢ à˜U 1˜W”~�Ø�a‘C�Ý! $¨Ñ.Ô.�Ý Ñ&Ô&ð  ð  Ø]bÐ]bÐ]bÐdhÐdhÐdhÐi�CÝ”M #Õ'9Ñ:Ô:Ð:Ø˜4Ø˜E‘k��ð
 ˜C‘i !‘m�ðE ˆaŠ%‰%ðF €Jr   c                 ó´   — |                       ¦   «         dz   } t          | ¦  «        }|D ].}|d |…                               ¦   «         | k    r||d …         c S Œ/dS )NrK   r7   )rA   r?   )rt   ra   rO   Úps       r   rr   rr   ü   sd   € Ø�:Š:‰<Œ<˜#Ñ€DÝˆD‰	Œ	€AØð ð ˆØˆRˆaˆRŒ5�;Š;‰=Œ=˜DÒ Ð Ø�Q�R�R”5ˆLˆLˆLð !àˆ2r   c                  ó2  — dd l } t          ¦   «         }| j        dd …         st          |¦  «         d S t	          dt          | j        ¦  «        d¦  «        D ]À}| j        ||dz   …         }t          |¦  «        dk     rt          d¦  «          d S |d         }|d         }t          ||d|¦  «        \  }}|st          dt          ¦  «         Œvt          d|¦  «         t          j
        |¦  «        }t          j        |¦  «        }|rt          d|¦  «         ŒÁd S )	Nr   r
   r/   z"usage: mailcap [MIMEtype file] ...rJ   zNo viewer found forz
Executing:zExit status:)Úsysr   ÚargvÚshowr>   r?   Úprintr   Útyper'   r^   Úwaitstatus_to_exitcode)	ry   r   rN   Úargsr_   Úfilere   rd   Ústss	            r   rZ   rZ     s(  € Ø€J€J€JÝ‰9Œ9€DØŒ8�A�B�BŒ<ð ÝˆT‰
Œ
ˆ
ØˆÝ�1•c˜#œ(‘m”m QÑ'Ô'ð +ð +ˆØŒx˜˜!˜A™#˜ŒˆÝˆt‰9Œ9�qŠ=ˆ=ÝÐ6Ñ7Ô7Ð7ØˆFˆFØ˜”7ˆØ�AŒwˆÝ˜t X¨v°tÑ<Ô<‰
ˆ�Øð 	+ÝÐ'­Ñ.Ô.Ð.Ð.å�, Ñ(Ô(Ð(Ý”)˜GÑ$Ô$ˆCÝÔ+¨CÑ0Ô0ˆCØð +Ý�n cÑ*Ô*Ð*øð+ð +r   c                 ó¶  — t          d¦  «         t          ¦   «         D ]}t          d|z   ¦  «         Œt          ¦   «          | st          ¦   «         } t          d¦  «         t          ¦   «          t          | ¦  «        }|D ]Y}t          |¦  «         | |         }|D ]=}t          |¦  «        }|D ]}t          d|z  ||         ¦  «         Œt          ¦   «          Œ>ŒZd S )NzMailcap files:ú	zMailcap entries:z  %-15s)r|   r   r   rj   )r   ÚfnÚckeysr}   rc   rd   ÚkeysÚks           r   r{   r{     sñ   € Ý	Ð
ÑÔÐÝÑ Ô Ð2Ð2ˆ¥%¨¨r©	Ñ"2Ô"2Ð"2Ð"2Ý	�G„G€GØÐ!�™	œ	�Ý	Ð
ÑÔÐÝ	�G„G€GÝ�4‰LŒL€EØð ð ˆÝˆd‰ŒˆØ�t”*ˆØð 	ð 	ˆAÝ˜!‘9”9ˆDØð +ð +�Ý�i !‘m Q q¤TÑ*Ô*Ð*Ð*Ý‰GŒGˆGˆGð		ðð r   Ú__main__)N)r   r'   r0   ÚreÚ__all__Ú_DEPRECATION_MSGÚ_deprecatedr   r   ÚcompileÚsearchr[   ÚWarningr   r   r   r4   r   r=   rL   r   r\   r]   rr   rZ   r{   r   r   r   ú<module>r�      sœ  ðØ +Ð +à 	€	€	€	Ø €€€Ø 	€	€	€	à�[Ð
!€ð#Ð ð €Ô �XÐ/¸Ð @Ñ @Ô @Ð @ðð ð ð ˆrŒzÐ9Ñ:Ô:ÔA€ð4ð 4ð 4ð 4ð 4˜ñ 4ô 4ð 4ðð ð ð4ð ð ð$ð ð ð'ð 'ð 'ðRð ð ð>$ð $ð $ð  #)°;Àbð ð ð ð ð6ð ð ð ð ,.ð 'ð 'ð 'ð 'ðRð ð ð+ð +ð +ð.ð ð ð" ˆzÒÐØ€D�F„F€F€F€Fð Ðr   