Your IP : 3.139.98.201
�
�/�g�$���dZddlZddlZddlZddgZdZejeed���d�Zej d ��j
ZGd
�de��Z
d�Zd
�Zd�Zd�Zd�Zd�Zddgfd�Zdd�Zgfd�Zd�Zd�Zd�Zedkre��dSdS)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|vr
d|dfSdS)N�linenor)�r�)�entrys �./opt/alt/python311/lib64/python3.11/mailcap.py�lineno_sort_keyrs!���5����%��/�!�!��t�z[^\xa1-\U0010FFFF\w@+=:,./-]c��eZdZdZdS)�UnsafeMailcapInputz)Warning raised when refusing unsafe inputN)�__name__�
__module__�__qualname__�__doc__rrr
rrs������3�3�3�3rrc�2�i}d}t��D]�} t|d��}n#t$rY� wxYw|5t||��\}}ddd��n#1swxYwY|���D]\}}||vr|||<�|||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
rrs���D�
�F�#�%�%�.�.�� ��g�s�#�#�B�B��� � � ��H� ����
� <� <�/��F�;�;��H�f� <� <� <� <� <� <� <� <� <� <� <���� <� <� <� <�"�.�.�*�*� .� .�J�C���$�;�;�!��S� � � ��I��-��S� � � .�
�Ks�'�
4�4�A�A � A c���dtjvr2tjd}|�tj��}n,dtjvrtjd}nd}|dzdddg}|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
rr9sp���R�Z����*�Z�(���=�=���,�,����R�Z����:�f�%�D�D��D��;�&��"�$<�>���Orc�b�tjdtd��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)rr�_s r
�readmailcapfiler4Ks6���M�F�$�a�)�)�)��r�4�(�(�G�D�!��Krc��i} |���}|s�n+|ddks|���dkr�>|}|dd�dkr3|���}|sd}|dd�|z}|dd�dk�3t|��\}}|r|s��|�
||d <|dz
}|�d
��}t t|����D]}||���||<� d
�|�����}||vr||�|��n|g||<��C||fS)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) rr r�line�nextliner!�fields�types�js r
rrSsw���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!�:��<�rc���g}dt|��}}||kr4t|||��\}}|�|��|dz}||k�4t|��dkrdS|d|d|dd�}}}d|i}|D]g}|�d��}|dkr|}d} n;|d|����}||dzd����} ||vr�b| ||<�h||fS) 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.
rr
r/�NNN�view�=r7)r?�
parsefieldrB�findr<)
rCrE�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���;�rc��|}||kr&||}|dkrn|dkr|dz}n|dz}||k�&|||����|fS)z/Separate one key-value pair in a mailcap entry.�;�\r/r
)r<)rCrNrO�start�cs r
rLrL�sn��
�E�
�a�%�%���G����8�8��
�$�Y�Y��!��A�A��!��A��a�%�%���a��=��� � �!�#�#rrJz /dev/nullc�F�t|��r"d|�d�}tj|t��dSt |||��}|D][}d|vr5t|d||��}|�� |rt
j|��dkr�;t|||||��} | �| |fcS�\dS)aFind 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_unsafer0r1r�lookup�substr'�system)
r�MIMEtyper!�filename�plist�msg�entries�erZ�commands
r
rr�s����H�����\d�\d�\d�f���
�c�-�.�.�.��z��T�8�S�)�)�G�
� � ���Q�;�;���6��H�e�4�4�D��|���
�� �$���1�,�,����#���(�E�:�:�����A�:������:rc����g}||vr|||z}|�d��}|ddz}||vr|||z}���fd�|D��}t|t���}|S)Nr:rz/*c���g|]}�|v�|�� Srr)�.0rdr!s �r
�
<listcomp>zlookup.<locals>.<listcomp>�s���2�2�2������1���r)r!)r)�sortedr)rr_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��Nrc��d}dt|��}}||k�r,||}|dz}|dkr|dkr|||dz�}|dz}||z}n�||}|dz}|dkr||z}n�|dkr||z}n�|dkr7t|��r"d|�d �}tj|t��dS||z}n�|d
kr�|} ||kr#||dkr|dz}||kr||dk�|| |�}
|dz}t|
|��}t|��r%d|�d
|
�d�}tj|t��dS||z}n|dz|z}||k��,|S)Nr7rr
�%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[r0r1r� findparam)rPr_r`ra�resrNrOrXrbrW�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�Jrc��|���dz}t|��}|D].}|d|����|kr||d�cS�/dS)NrKr7)rAr?)rtrarO�ps r
rrrr�sd���:�:�<�<�#��D��D� � �A�
�����R�a�R�5�;�;�=�=�D� � ��Q�R�R�5�L�L�L�!�
�2rc�2�ddl}t��}|jdd�st|��dSt dt|j��d��D]�}|j||dz�}t|��dkrt
d��dS|d}|d}t||d|��\}}|st
dt���vt
d|��tj
|��}tj|��}|rt
d|����dS) Nrr
r/z"usage: mailcap [MIMEtype file] ...rJzNo viewer found forz
Executing:zExit status:)�sysr�argv�showr>r?�printr�typer'r^�waitstatus_to_exitcode) ryrrN�argsr_�filererd�stss r
rZrZs(���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�*�*�*��+�+rc��td��t��D]}td|z���t��|st��}td��t��t|��}|D]Y}t|��||}|D]=}t|��}|D]}td|z||���t���>�ZdS)NzMailcap files:� zMailcap entries:z %-15s)r|rrrj)r�fn�ckeysr}rcrd�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)rr'r0�re�__all__�_DEPRECATION_MSG�_deprecatedrr�compile�searchr[�Warningrrrr4rr=rLrr\r]rrrZr{rrr
�<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
?>