Ë
    òT•ju$  ã                   ó  — 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«        yy)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 y)NÚlinenor   )é   r   © )Úentrys    ú/usr/lib/python3.12/mailcap.pyÚlineno_sort_keyr      s   € à�5ÑØ�%˜‘/Ð!Ð!àó    z[^\xa1-\U0010FFFF\w@+=:,./-]c                   ó   — e Zd ZdZy)ÚUnsafeMailcapInputz)Warning raised when refusing unsafe inputN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r      s   „ Ú3r   r   c                  ó
  — i } d}t        «       D ]V  }	 t        |d«      }|5  t        ||«      \  }}ddd«       j	                  «       D ]  \  }}|| vr|| |<   Œ| |   |z   | |<   Œ ŒX | S # t        $ r Y Œfw xY w# 1 sw Y   ŒIxY w)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ð ñ 	<Ü/°°FÓ;ÑˆH�f÷	<à"Ÿ.™.Ó*ò 	.‰JˆC�Ø˜$‘;Ø!��S’	à  ™I¨Ñ-��S’	ñ		.ð.ð €Køô ò 	Ùð	ú÷	<ð 	<ús   “A*¡A9Á*	A6Á5A6Á9B	c                  óô   — dt         j                  v r4t         j                  d   } | j                  t         j                  «      }|S 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   sv   € ð ”R—Z‘ZÑÜ—*‘*˜ZÑ(ˆØ—=‘=¤§¡Ó,ˆð €Oð ”R—Z‘ZÑÜ—:‘:˜fÑ%‰Dð ˆDØ˜;Ñ&¨Ø"Ð$<ð>ˆà€Or   c                 óZ   — 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   s+   € ä‡M�MÐFÜ$ aô)ä˜r 4Ó(�G€Dˆ!Ø€Kr   c                 ó(  — i }| j                  «       x}rû|d   dk(  s|j                  «       dk(  rŒ.|}|dd dk(  r%| j                  «       }|sd}|dd |z   }|dd dk(  rŒ%t        |«      \  }}|r|sŒp|�
||d<   |d	z  }|j                  d
«      }t	        t        |«      «      D ]  }||   j                  «       ||<   Œ d
j                  |«      j                  «       }||v r||   j                  |«       n|g||<   | j                  «       x}rŒû||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   ú#Ú éþÿÿÿNz\
ú
r	   r
   ú/)	ÚreadlineÚstripÚ	parseliner)   ÚrangeÚlenÚjoinÚlowerÚappend)	r   r	   r   ÚlineÚnextliner!   ÚfieldsÚtypesÚjs	            r   r   r   S   s<  € ð €DØ—+‘+“-Ð
ˆ$Ð
à�‰7�cŠ>˜TŸZ™Z›\¨RÒ/ØØˆà�r�sˆm˜vÒ%Ø—{‘{“}ˆHÙ¨˜XØ˜˜�9˜xÑ'ˆDð �r�sˆm˜vÓ%ô
   “o‰ˆˆVÙ™ØØÐØ%ˆF�8ÑØ�a‰KˆFà—	‘	˜#“ˆÜ”s˜5“zÓ"ò 	(ˆAØ˜Q‘x—~‘~Ó'ˆE�!ŠHð	(à�h‰h�u‹o×#Ñ#Ó%ˆà�$‰;Ø�‰I×Ñ˜VÕ$à˜ˆD�‰Ið5 —+‘+“-Ð
ˆ$Ñ
ð6 �ˆ<Ðr   c                 óx  — g }dt        | «      }}||k  r,t        | ||«      \  }}|j                  |«       |dz   }||k  rŒ,t        |«      dk  ry|d   |d   |dd }}}d|i}|D ]P  }|j                  d«      }|dk  r|}d}	n)|d| j	                  «       }||dz   d j	                  «       }	||v rŒL|	||<   ŒR ||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=   z   s÷   € ð €FØŒc�$‹i€q€AØ
ˆaŠ%Ü˜d A qÓ)‰ˆˆqØ�‰�eÔØˆa‰Cˆð ˆa‹%ô ˆ6ƒ{�Q‚ØØ˜Q‘i ¨¡¨F°1°2¨Jˆtˆ€CØ�dˆ^€FØò "ˆØ�J‰J�s‹OˆØˆqŠ5ØˆDØ‰Fà˜˜!�9—?‘?Ó$ˆDØ˜1˜Q™3˜4�[×&Ñ&Ó(ˆFØ�6‰>àà!ˆF�4ŠLð"ð �ˆ;Ðr   c                 ó|   — |}||k  r!| |   }|dk(  rn|dk(  r|dz   }n|dz   }||k  rŒ!| || j                  «       |fS )z/Separate one key-value pair in a mailcap entry.ú;ú\r/   r
   )r<   )rC   rN   rO   ÚstartÚcs        r   rL   rL   ™   s_   € à€EØ
ˆaŠ%Ø�‰GˆØ�Š8ØØ�$ŠYØ�!‘‰Aà�!‘ˆAð ˆa‹%ð ��aˆ=×ÑÓ  !Ð#Ð#r   rJ   z	/dev/nullc                 ó  — t        |«      r!d|›d�}t        j                  |t        «       yt	        | ||«      }|D ]M  }d|v r.t        |d   ||«      }|€Œ|rt        j                  |«      dk7  rŒ5t        ||   |||«      }	|	€ŒI|	|fc S  y)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   Útestr   )Ú_find_unsafer0   r1   r   ÚlookupÚsubstr'   Úsystem)
r   ÚMIMEtyper!   ÚfilenameÚplistÚmsgÚentriesÚerZ   Úcommands
             r   r   r   ©   s¢   € ô �HÕÚ\dÐfˆÜ�‰�cÔ-Ô.ØÜ�T˜8 SÓ)€Gàò 	ˆØ�Q‰;Ü˜˜6™ H¨eÓ4ˆDØˆ|ØÙœŸ	™	 $›¨1Ò,ØÜ˜˜#™ ¨(°EÓ:ˆØÑØ˜A�:Òð	ð r   c                 óÄ   — g }|| v r|| |   z   }|j                  d«      }|d   dz   }|| v r|| |   z   }|�|D �cg c]	  }||v sŒ|‘Œ }}t        |t        ¬«      }|S c c}w )Nr:   r   z/*)r!   )r)   Úsortedr   )r   r_   r!   rc   Ú	MIMEtypesrd   s         r   r\   r\   Ä   sƒ   € Ø€GØ�4ÑØ˜D ™NÑ*ˆØ—‘˜sÓ#€IØ˜‰|˜dÑ"€HØ�4ÑØ˜D ™NÑ*ˆØ
€Ø%Ö2˜¨°ª’1Ð2ˆÐ2Ü�W¤/Ô2€GØ€Nùò 3s   º	AÁAc                 ó*  — d}dt        | «      }}||k  rþ| |   }|dz   }|dk7  r|dk(  r| ||dz    }|dz   }||z   }nÑ| |   }|dz   }|dk(  r||z   }n¼|dk(  r||z   }n±|dk(  r2t        |«      r!d|›d	�}t        j                  |t        «       y ||z   }nz|d
k(  rm|}	||k  r| |   dk7  r|dz   }||k  r	| |   dk7  rŒ| |	| }
|dz   }t        |
|«      }t        |«      r$d|›d|
›d�}t        j                  |t        «       y ||z   }n|dz   |z   }||k  rŒþ|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]   Ñ   se  € à
€CØŒc�%‹j€q€AØ
ˆaŠ%Ø�!‰Hˆ˜!˜A™#�aØ�Š8Ø�DŠyØ˜!˜A˜a™C�L� a¨¡c !Ø˜‘'‰Cà�a‘ˆA˜a ™c˜!Ø�CŠxØ˜A‘g‘Ø�c’Ø˜H‘n‘Ø�c’Ü Õ)ÚYaÐc�CÜ—M‘M #Ô'9Ô:ØØ˜H‘n‘Ø�c’Ø�Ø˜!’e  a¡¨C¢Ø˜!™�Að ˜!’e  a¡¨C£à˜U 1�~�Ø�a‘C�Ü! $¨Ó.�Ü Õ&Ú]bÒdhÐi�CÜ—M‘M #Ô'9Ô:ØØ˜E‘k‘ð
 ˜C‘i !‘m�ðE ˆa‹%ðF €Jr   c                 óˆ   — | j                  «       dz   } t        | «      }|D ]  }|d | j                  «       | k(  sŒ||d  c S  y)NrK   r7   )rA   r?   )rq   ra   rO   Úps       r   ro   ro   ú   sN   € Ø�:‰:‹<˜#Ñ€DÜˆD‹	€AØò ˆØˆRˆaˆ5�;‰;‹=˜DÓ Ø�Q�R�5ŠLðð r   c                  óà  — dd l } t        «       }| j                  dd  st        |«       y t	        dt        | j                  «      d«      D ]¢  }| j                  ||dz    }t        |«      dk  rt        d«        y |d   }|d   }t        ||d|«      \  }}|st        dt        «       Œ^t        d|«       t        j                  |«      }t        j                  |«      }|sŒ—t        d|«       Œ¤ y )	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)	rv   r   rN   Úargsr_   Úfilere   rd   Ústss	            r   rZ   rZ     sÖ   € ÛÜ‹9€DØ�8‰8�A�B‰<ÜˆTŒ
ØÜ�1”c˜#Ÿ(™(“m QÓ'ò +ˆØ�x‰x˜˜!˜A™#ˆˆÜˆt‹9�qŠ=ÜÐ6Ô7ÙØ˜‘7ˆØ�A‰wˆÜ˜t X¨v°tÓ<‰
ˆ�ÙÜÐ'¬Õ.ä�, Ô(Ü—)‘)˜GÓ$ˆCÜ×+Ñ+¨CÓ0ˆCÚÜ�n cÕ*ñ+r   c                 óX  — t        d«       t        «       D ]  }t        d|z   «       Œ t        «        | s
t        «       } t        d«       t        «        t        | «      }|D ]G  }t        |«       | |   }|D ]0  }t        |«      }|D ]  }t        d|z  ||   «       Œ t        «        Œ2 ŒI y )NzMailcap files:ú	zMailcap entries:z  %-15s)ry   r   r   rg   )r   ÚfnÚckeysrz   rc   rd   ÚkeysÚks           r   rx   rx     s¦   € Ü	Ð
ÔÜÓ Ò2ˆ¤%¨¨r©	Õ"2Ð2Ü	„GÙœ›	�Ü	Ð
ÔÜ	„GÜ�4‹L€EØò ˆÜˆdŒØ�t‘*ˆØò 	ˆAÜ˜!“9ˆDØò +�Ü�i !‘m Q q¡TÕ*ð+ä�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]   ro   rZ   rx   r   r   r   ú<module>r�      sÄ   ðÙ +ã 	Û Û 	à�[Ð
!€ð#Ð ð €× Ñ �XÐ/¸Õ @òð ˆr�z‰zÐ9Ó:×AÑA€ô4˜ô 4òò4ò$ò%òNò>$ð  #)°;Àbó ó6ð ,.ó 'òRò+ò.ð" ˆzÒÙ…Fð r   