%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/xdg/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/xdg/__pycache__/Mime.cpython-312.pyc

�

�u�c�f��\�dZddlZddlZddlZddlZddlZddlmZddlZddl	m
Z
mZddlm
Z
dZiZdZdadZdaej(ddk\Zd�Zd3d	�ZGd
�de�ZGd�d
e�ZGd�de�ZGd�d�ZGd�de�ZGd�d�Z Gd�de�Z!edd�Z"edd�Z#edd�Z$edd�Z%edd�Z&edd �Z'edd!�Z(edd"�Z)edd#�Z*edd$�Z+d%a,d&�Z-d'�Z.d(�Z/d4d)�Z0d4d*�Z1d+�Z2d5d,�Z3d6d-�Z4d.�Z5erd/�Z6nd0�Z6da7d%a8d1�Z9d2�Z:y)7a�
This module is based on a rox module (LGPL):

http://cvs.sourceforge.net/viewcvs.py/rox/ROX-Lib2/python/rox/mime.py?rev=1.21&view=log

This module provides access to the shared MIME database.

types is a dictionary of all known MIME types, indexed by the type name, e.g.
types['application/x-python']

Applications can install information about MIME types by storing an
XML file as <MIME>/packages/<application>.xml and running the
update-mime-database command, which is provided by the freedesktop.org
shared mime database package.

See http://www.freedesktop.org/standards/shared-mime-info-spec/ for
information about the format of these files.

(based on version 0.13)
�N)�
BaseDirectory)�minidom�
XML_NAMESPACE)�defaultdictz5http://www.freedesktop.org/standards/shared-mime-info�c��dj|jD�cgc]}|j��c}�j�Scc}w)zGet text of XML node�)�join�
childNodes�	nodeValue�strip)�node�ns  �*/usr/lib/python3/dist-packages/xdg/Mime.py�_get_node_datar-s0��
�7�7����9�A�A�K�K�9�:�@�@�B�B��9s�Ac��t||�S)z�Get the MIMEtype object for the given type.
    
    This remains for backwards compatibility; calling MIMEtype now does
    the same thing.
    
    The name can either be passed as one part ('text/plain'), or as two
    ('text', 'plain').
    )�MIMEtype��media�subtypes  r�lookupr1s���E�7�#�#�c�T��eZdZdZd�fd�	Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Z�xZ
S)rz�Class holding data about a MIME type.
    
    Calling the class will return a cached instance, so there is only one 
    instance for each MIME type. The name can either be passed as one part
    ('text/plain'), or as two ('text', 'plain').
    c� ��|�d|vr|jdd�\}}d|vsJ�|j�}|j�}	t||fS#t$r5tt
|�|�}|j||�|t||f<|cYSwxYw)N�/�)�split�lower�types�KeyError�superr�__new__�_init)�clsrr�mtype�	__class__s    �rr"zMIMEtype.__new__Cs�����?�s�e�|�"�[�[��a�0�N�E�7��'�!�!�!����
���-�-�/��	��%��)�*�*���	��(�C�0��5�E��K�K��w�'�&+�E�5�'�"�#��L�		�s�
A�;B
�B
c�.�||_||_d|_y�N)rr�_comment)�selfrrs   rr#zMIMEtype._initUs����
������
rc���tjjd|j|jdz�}tj|�D]�}tj|�}|��|jjtd�D]g}|jtd�xsd}d|tjj vz}||j"dkDr|t%|�f|_|d	k(s�fy��y)
z>Loads comment for current language. Use get_comment() instead.�mime�.xmlN�comment�lang�enrr�)�os�pathr
rrr�load_data_pathsr�parse�documentElement�getElementsByTagNameNS�FREE_NS�getAttributeNSr�xdg�Locale�langsr)r)r*�resourcer3�docr.r/�goodnesss       r�_loadzMIMEtype._loadZs����7�7�<�<���
�
�D�L�L�6�4I�J��!�1�1�(�;�		)�D��-�-��%�C��{���.�.�E�E�g�y�Y�
)���-�-�m�V�D�L������
�
�(8�(8� 8�9���d�m�m�A�.�.�%-�~�g�/F�$G�D�M��q�=�&�
)�			)rc�|�|j�"dt|�f|_|j�|jdS)z;Returns comment for current language, loading it if needed.rr)r)�strr@�r*s r�get_commentzMIMEtype.get_commentis5���=�=� ���D�	�N�D�M��J�J�L��}�}�Q��rc�d�t�t|�}|tvrtt|�S|S)z:Returns the canonical MimeType object if this is an alias.)�update_cacherB�aliasesr)r*�ss  r�	canonicalzMIMEtype.canonicalqs+������I����<��'�!�*�%�%��rc�Z�t�td�tt|�D��S)z5Returns a set of Mime types which this inherits from.c3�2K�|]}t|����y�wr()r)�.0�ts  r�	<genexpr>z)MIMEtype.inherits_from.<locals>.<genexpr>|s����=��6�!�9�=�s�)rF�set�inheritancerBrCs r�
inherits_fromzMIMEtype.inherits_fromys!�����=�k�#�d�)�&<�=�=�=rc�:�|jdz|jzS)NrrrCs r�__str__zMIMEtype.__str__~s���z�z�C��$�,�,�.�.rc�<�d|j�d|j�d�S)Nz	MIMEtype(z, �)rrCs r�__repr__zMIMEtype.__repr__�s��%)�Z�Z����>�>rc�X�t|j�t|j�zSr()�hashrrrCs r�__hash__zMIMEtype.__hash__�s���D�J�J��$�t�|�|�"4�4�4rr()�__name__�
__module__�__qualname__�__doc__r"r#r@rDrIrQrSrVrY�
__classcell__)r&s@rrr<s5����
�$�
)� ��>�
/�?�5rrc��eZdZy)�UnknownMagicRuleFormatN)rZr[r\�rrr`r`�s��rr`c��eZdZdZy)�DiscardMagicRuleszGRaised when __NOMAGIC__ is found, and caught to discard previous rules.N)rZr[r\r]rarrrcrc�s��M�rrcc�b�eZdZdZd�Zejd�Zed��Z	d�Z
d�Zd�Zd�Z
y)	�	MagicRuleNc�J�||_||_||_||_||_yr(��start�value�mask�word�range)r*rhrirjrkrls      r�__init__zMagicRule.__init__�s%����
���
���	���	���
rs(?:~(\d+))?(?:\+(\d+))?\n$c�h�|j�}|jdd�\}}|rt|�nd}|jdd�\}}t|�}|dk(rt�tj
ddk\rtj
|ddd	�
�}n t|d�dzt|d�z}|dd}t|�|kr"||j�z
}t|�|kr�"|d|||d}}|jd�rAt|�|kr"||j�z
}t|�|kr�"|d|dz||dzd}}nd}|jj|�}|stt|���|j�\}	}
|	�t|	�nd}	|
�t|
�nd}
||||||	|
�fS)
zjRead a rule from the binary magics file. Returns a 2-tuple of
        the nesting depth and the MagicRule.�>rr�=s__NOMAGIC__
rNr1�big)�	byteorder��&)�readliner�intrc�sys�version_info�
from_bytes�ord�len�
startswith�rule_ending_re�matchr`�repr�groups)r$�f�line�
nest_depthrh�lenvaluerirj�endingrkrls           r�	from_filezMagicRule.from_file�s����z�z�|�� �:�:�d�A�.��
�D�(2�S��_��
��j�j��q�)���t��E�
���#�#�#�#����A��!�#��~�~�d�2�A�h�%�~�@�H��D��G��a���T�!�W��5�H��A�B�x���$�i�8�#��A�J�J�L� �D��$�i�8�#��9�H�o�t�H�I��t���?�?�4� ��d�)�x�'���
�
��$���d�)�x�'��a���
�+�T�(�1�*�+�->�$�D��D��#�#�)�)�$�/���)��d��4�4��m�m�o���e�!�-�s�4�y�A��$�0��E�
�q���3�u�e�T�4��?�?�?rc���|jt|j�z|jz}|jr$t||jj
��S|Sr()rhr{rirl�also�max�maxlen)r*�ls  rr�zMagicRule.maxlen�sG���J�J��T�Z�Z��(�4�:�:�5���9�9��q�$�)�)�*�*�,�-�-��rc�v�|j|�r(|jr|jj|�Syy)NT)�match0r�r~�r*�buffers  rr~zMagicRule.match�s0���;�;�v���y�y��y�y���v�.�.��rc���t|�}t|j�}t|j�D]�}|j|z}||z}||kry|jrjd}t|�D]Y}t
r|||z|j|z}	n*t
|||z�t
|j|�z}	|t|	�z
}�[n|||}||jk(s��yy)NFr	T)r{rirlrhrj�PY3rz�chr)
r*r�r�r��orH�e�test�i�cs
          rr�zMagicRule.match0�s���

�f�+���t�z�z�?���t�z�z�"�	�A��j�j��l�A���j�A���s���y�y����x��#�A��"�1�Q�3�K�$�)�)�A�,�6����q��s��,�s�4�9�9�Q�<�/@�@���C��F�N�D�#��a��{���T�Z�Z���#	rc��d|j�d|j�d|j�d|j�d|j�d�S)NzMagicRule(start=z, value=z, mask=z, word=z, range=rUrgrCs rrVzMagicRule.__repr__�s/��"&�*�*�"&�*�*�"&�)�)�"&�)�)�"&�*�*�.�	.r)rZr[r\r�rm�re�compiler}�classmethodr�r�r~r�rVrarrrere�sH���D�� �R�Z�Z� >�?�N��2@��2@�h���,.rrec�B�eZdZdZd�Zd�Zd�Zed��Zed��Z	y)�
MagicMatchAnyz�Match any of a set of magic rules.
    
    This has a similar interface to MagicRule objects (i.e. its match() and
    maxlen() methods), to allow for duck typing.
    c��||_yr()�rules)r*r�s  rrmzMagicMatchAny.__init__s	����
rc�@��t�fd�|jD��S)Nc3�@�K�|]}|j�����y�wr()r~)rL�rr�s  �rrNz&MagicMatchAny.match.<locals>.<genexpr>s�����7�q�1�7�7�6�?�7�s�)�anyr�r�s `rr~zMagicMatchAny.matchs����7�D�J�J�7�7�7rc�:�td�|jD��S)Nc3�<K�|]}|j����y�wr()r�)rLr�s  rrNz'MagicMatchAny.maxlen.<locals>.<genexpr>s����2�!�1�8�8�:�2�s�)r�r�rCs rr�zMagicMatchAny.maxlens���2�t�z�z�2�2�2rc��|jd�}|jdd�g}|rW|dk7rR	|jtj	|��|jd�}|r|jdd�|r|dk7r�Rg}d|i}|D]%\}}g}||j||f�|||dz<�'|j
|�S#t
$rY�ywxYw)z/Read a set of rules from the binary magic file.r����[r)�read�seek�appendrer�r`�from_rule_tree)	r$r�r��depths_rules�tree�
insert_points�depth�rule�subruless	         rr�zMagicMatchAny.from_file	s����&�&��)��	���r�1�
����A��I�
��#�#�I�$7�$7��$:�;��f�f�Q�i�A�����r�1�
��A��I����4��
�'�	.�K�E�4��H��%� �'�'��x�(8�9�%-�M�%��'�"�	.�
�!�!�$�'�'��*�
��
�s�$C�	C�Cc��g}|D].\}}|r|j|�|_|j|��0t|�dk(ryt|�dk(r|dS||�S)aFrom a nested list of (rule, subrules) pairs, build a MagicMatchAny
        instance, recursing down the tree.
        
        Where there's only one top-level rule, this is returned directly,
        to simplify the nested structure. Returns None if no rules were read.
        rNr)r�r�r�r{)r$r�r�r�r�s     rr�zMagicMatchAny.from_rule_tree#sk����"�	�N�D�(���.�.�x�8��	��L�L���	�
�u�:�q�=���u�:�q�=���8�O��5�z�rN)
rZr[r\r]rmr~r�r�r�r�rarrr�r��s>���
�8�3��(��(�2���rr�c�4�eZdZd�Zd�Zd�Zdd�Zdd�Zd�Zy)	�MagicDBc�,�tt�|_yr()r�list�bytyperCs rrmzMagicDB.__init__8s��#�D�)��rc�T�t|d�5}|j�}|dk7rtd��	|j�jd�}|sn�|ddk7s|ddd	k7rt	d
|��|ddjd�\}}t
|�}t|�}	tj|�}|���|j|j||f���	ddd�y#t$r4|jj|d�tj|�}Y�jwxYw#1swYyxYw)
z<Read a magic binary file, and add its rules to this MagicDB.�rbsMIME-Magic
zNot a MIME magic file�asciir�[���Nz]
zMalformed section headingr�:)�openru�IOError�decode�
ValueErrorrrvrr�r�rcr��popr�)	r*�fnamer�r��shead�pri�tnamer%r�s	         r�
merge_filezMagicDB.merge_file;s2��
�%��
�	7�!��:�:�<�D��(�(��5�6�6���
�
��+�+�G�4������8�s�?�e�B�C�j�E�&9�$�%@�%�H�H�"�1�R�[�.�.�s�3�
��U��#�h���u�
��6�(�2�2�1�5�D��<�����E�"�)�)�3��+�6�)��	7�	7��$)�6��K�K�O�O�E�4�0�(�2�2�1�5�D�6��%	7�	7�s0�B
D�C�0$D�:D�D�D�D�D'c�(�d}g|_|jj�D]G\}}|D]=\}}|jj|||f�t	||j��}�?�I||_|jj
d�d��y)z{Prepare the MagicDB for matching.
        
        This should be called after all rules have been merged into it.
        rc��|dS�Nrra��xs r�<lambda>z"MagicDB.finalise.<locals>.<lambda>fs
���1��rT��key�reverseN)�alltypesr��itemsr�r�r��sort)r*r�r%r�r�r�s      r�finalisezMagicDB.finaliseXs���
����
� �K�K�-�-�/�	4�L�E�5�"�
4�	��T��
�
�$�$�c�5�$�%7�8��V�T�[�[�]�3��
4�	4�
����
�
���~�t��<rNc�
�|�Hg}|D]-}|j|D]\}}|j|||f���/|jd���n|j}|D](\}	}
}|	|kDr�
|	|kry|j	|�s�&|
cSy)a]Do magic sniffing on some bytes.
        
        max_pri & min_pri can be used to specify the maximum & minimum priority
        rules to look for. possible can be a list of mimetypes to check, or None
        (the default) to check all mimetypes until one matches.
        
        Returns the MIMEtype found, or None if no entries match.
        Nc��|dSr�rar�s rr�z$MagicDB.match_data.<locals>.<lambda>vs
��Q�q�T�r)r�)r�r�r�r�r~)r*�data�max_pri�min_pri�possibler�mtr�r��priority�mimetypes           r�
match_datazMagicDB.match_datahs������E��
2��!%���R��2�I�C���L�L�#�r�4��1�2�
2�
�J�J�>�J�*��M�M�E�(-�	 �$�H�h���'�!���'�!���z�z�$����	 rc��t|d�5}|j|j�}ddd�|j|||�S#1swY�xYw)a�Read data from the file and do magic sniffing on it.
        
        max_pri & min_pri can be used to specify the maximum & minimum priority
        rules to look for. possible can be a list of mimetypes to check, or None
        (the default) to check all mimetypes until one matches.
        
        Returns the MIMEtype found, or None if no entries match. Raises IOError
        if the file can't be opened.
        r�N)r�r�r�r�)r*r3r�r�r�r��bufs       rr~z
MagicDB.match�sL���$��
�	&���&�&����%�C�	&����s�G�W�h�?�?�	&�	&�s�A�Ac�2�dt|j�zS)Nz<MagicDB (%d types)>)r{r�rCs rrVzMagicDB.__repr__�s��%��D�M�M�(:�:�:r)�drN)	rZr[r\rmr�r�r�r~rVrarrr�r�7s!��*�7�:=�  �8@�;rr�c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�GlobDBc�,�tt�|_y)z�Prepare the GlobDB. It can't actually be used until .finalise() is
        called, but merge_file() can be used to add data before that.
        N)rrO�allglobsrCs rrmzGlobDB.__init__�s��
$�C�(��
rc	��|j}t|�5}|D]�}|jd�r�|ddjd�}|dd\}}}t	|�}t|�}	t
|�dkDr|djd�}
nd}
|dk(r|j|	d���||	j||t|
�f���	ddd�y#1swYyxYw)	z3Loads name matching information from a globs2 file.�#Nr�r�r�,ra�__NOGLOBS__)
r�r�r|rrvrr{r��add�tuple)r*r3r�r�r��fields�weight�	type_name�patternr%�flagss           rr�zGlobDB.merge_file�s����=�=��
�$�Z�	E�1��
E���?�?�3�'���c�r�����-��-3�B�Q�Z�*��	�7��V����y�)���v�;��?�"�1�I�O�O�C�0�E��E��m�+��L�L���-�����#�#�V�W�e�E�l�$C�D�#
E�	E�	E�	E�s�B*C�Cc�d�tt�|_tt�|_g|_i|_i|_|jj�D�]7\}}|j�}|D�]\}}}d|v}|jd�rc|dd}d|vsZd|vsVd|vsR|r!|j|j||f�n.|j|j�j||f���d|vsd|vsd|vr]|rdntj}tjt!j"|�|�	�}|jj|||f���|r||f|j|<��||f|j
|j�<����:|jj%d
d���y)
zzPrepare the GlobDB for matching.
        
        This should be called after all files have been merged into it.
        �csz*.r1N�*r��?r)r�Tc�<�|dt|dj�fS)Nr1r)r{r�r�s rr�z!GlobDB.finalise.<locals>.<lambda>�s��Q�q�T�3�q��t�|�|�;L�4M�r)r�r�)rr��exts�
cased_exts�globs�literals�cased_literalsr�r�rIr|r�rr��Ir��fnmatch�	translater�)	r*r%r�r�r�r��cased�rest�re_flagss	         rr�zGlobDB.finalise�s���
 ��%��	�%�d�+�����
���
� ��� �M�M�/�/�1�	E�L�E�5��/�/�#�%�(-�E�$�f�g�u��E�M�E��!�!�$�'��q�r�{���t��s�d�{�c�T�k������-�4�4�e�V�_�E��	�	�$�*�*�,�/�6�6��v��G���w��#��.�C�7�N� %�1�2�4�4���*�*�W�%6�%6�w�%?�x�P���
�
�!�!�7�E�6�":�;��49�6�?�D�'�'��0�6;�V�_�D�M�M�'�-�-�/�2�1E�	E�:	
�
�
����*M��Orc�\�	t|j|��dS#t$rYywxYw)zTReturn the first match found for a given path, or None if no match
        is found.rN)�next�_match_path�
StopIteration�r*r3s  r�first_matchzGlobDB.first_match�s4��	���(�(��.�/��2�2���	��	�s��	+�+c�6�t|j|��S)z<Return a list of (MIMEtype, glob weight) pairs for the path.)r�rrs  r�all_matcheszGlobDB.all_matches�s���D�$�$�T�*�+�+rc#�dK�tjj|�}||jvr|j|��|j	�}||j
vr|j
|��|}	|j
d�}|dkrn/||dzd}||jvr|j|D]}|����F|}	|j
d�}|dkrn/||dzd}||jvr|j|D]}|����F|jD]\}}}	|j|�s�||	f��� y�w)z(Yields pairs of (mimetype, glob weight).r�.rN)r2r3�basenamer�rr��findr�r�r�r~)
r*r3�leaf�lleaf�ext�p�res�regex�	mime_typer�s
          rrzGlobDB._match_path�sM�����w�w����%���4�&�&�&��%�%�d�+�+��
�
����D�M�M�!��-�-��&�&��������
�A��1�u�e��a�!�e�f�+�C��d�o�o�%��?�?�3�/��C��I����������
�A��1�u�e��a��c�d�)�C��d�i�i���9�9�S�>��C��I���+/�*�*�	*�&�U�I�v��{�{�4� � �&�)�)�	*�s�D$D0�'	D0N)	rZr[r\rmr�r�rr
rrarrr�r��s#��)�E�.(P�T�,�!*rr��text�plain�applicationzoctet-stream�inode�blockdevice�
chardevice�	directory�fifo�socket�symlink�door�
executableFc�*�daiatt�atjtjjdd��D]K}t|d�5}|D].}|j�jdd�\}}|t|<�0	ddd��Mt�atjtjjdd��D]}tj|��tj!�t#�atjtjjdd��D]}t$j|��t$j!�tjtjjdd��D]Z}t|d�5}|D]=}|j�jdd�\}}t|j'|��?	ddd��\y#1swY���xYw#1swY�txYw)	NTr,rGr�r�globs2�magic�
subclasses)�_cache_uptodaterGrrOrPrr4r2r3r
r�r
rr�r�r�r�r�r$r�)r3r�r��aliasrI�sub�parents       r�_cache_databaser*s����O��G��c�"�K��-�-�b�g�g�l�l�6�9�.M�N�+��
�$��_�	+���
+��#'�:�:�<�#5�#5�d�A�#>� ��y�!*����
+�	+�	+�+�
�H�E��-�-�b�g�g�l�l�6�8�.L�M���
������	�N�N��
�I�E��-�-�b�g�g�l�l�6�7�.K�L���
������	�N�N���-�-�b�g�g�l�l�6�<�.P�Q�-��
�$��_�	-���
-��"�j�j�l�0�0��q�9���V��C� �$�$�V�,�
-�	-�	-�-�%	+�	+��&	-�	-�s�4G<�-AH	�<H	�	H	c�&�tst�yyr()r&r*rarrrFrF=s�����rc�@�t�tj|�S)z6Returns type of file by its name, or None if not known)rFr�r)r3s r�get_type_by_namer-As���N����T�"�"rc�D�t�tj|||�S)z:Returns type of file by its contents, or None if not known)rFr$r~)r3r�r�s   r�get_type_by_contentsr/Fs���N��;�;�t�W�g�.�.rc�D�t�tj|||�S)z0Returns type of the data, which should be bytes.)rFr$r�)r�r�r�s   r�get_type_by_datar1Ls���N����D�'�7�3�3rc�R�tj|�rtStj|�rtStj
|�rtStj|�rtStj|�rtStj|�rtStS)z.Match special filesystem objects to Mimetypes.)�stat�S_ISDIR�	inode_dir�S_ISCHR�
inode_char�S_ISBLK�inode_block�S_ISFIFO�
inode_fifo�S_ISLNK�
inode_symlink�S_ISSOCK�inode_socket�
inode_door)�st_modes r�_get_type_by_statrBRsn���|�|�G��Y�.�	
���g�	�z� 1�	
���g�	�{� 2�	
���w�	�
�!2�	
���g�	�}� 4�	
���w�	��!4��rc���t�	|rtj|�}ntj|�}tj|j�r[t||��}|st	|�}|s
t||��}|�.tj|j�dzrtSt
S|St|j�S#t	|�}|xst
cYSxYw)a�Returns type of file indicated by path.
    
    This function is *deprecated* - :func:`get_type2` is more accurate.
    
    :param path: pathname to check (need not exist)
    :param follow: when reading file, follow symbolic links
    :param name_pri: Priority to do name matches. 100=override magic
    
    This tries to use the contents of the file, and falls back to the name. It
    can also handle special filesystem objects like directories and sockets.
    )r�)r��I)rFr2r3�lstatr-r�S_ISREGrAr/�S_IMODE�app_exerB)r3�follow�name_pri�strMs     r�get_typerL\s����N��������B����$��B�
�|�|�B�J�J�� ��x�8���&�t�,�!��*�4��B�!��9��|�|�B�J�J�'�%�/������� ����,�,��!��T�"���y�D��s�-C�C!c��t�	|rtj|�ntj|�}tj|j�st|j�Sttj|�d�d��}|rS|dd}d}|ddD]\}}||krn|dz
}�|d|}t|�dk(r|ddS|D��cgc]\}}|��	}}}nd}	tj||��}	|	r|	S|r|ddStj"|j�dzrt$St'|�rt(StS#t$rt|�xstcYSwxYwcc}}w#t $rd}	Y��wxYw)	a�Find the MIMEtype of a file using the XDG recommended checking order.
    
    This first checks the filename, then uses file contents if the name doesn't
    give an unambiguous MIMEtype. It can also handle special filesystem objects
    like directories and sockets.
    
    :param path: file path to examine (need not exist)
    :param follow: whether to follow symlinks
    
    :rtype: :class:`MIMEtype`
    
    .. versionadded:: 1.0
    c��|dS)Nrrar�s rr�zget_type2.<locals>.<lambda>�s
��A�a�D�rTr�rrN)r�rD)rFr2r3rE�OSErrorr-�octet_streamrFrArB�sortedr�r
r{r$r~r�rGrH�is_text_filer)
r3rIrK�mtypes�
max_weightr�r��wr�rMs
          r�	get_type2rV�s���N�6�$�R�W�W�T�]�"�(�(�4�.���<�<��
�
�#� ����,�,�
�E�%�%�d�+�.�4�
P�F�
��A�Y�q�\�
�
���A�B�Z�	�E�B���:�~��
��F�A�	�������v�;�!���!�9�Q�<��#)�*�4�2�a�B�*��*�����K�K��x�K�0��	���	��a�y��|��	
���b�j�j�	!�E�	)���#�D�)�t�;�|�;��G�6���%�5��5�6��&+�������s)�,E
�E,�&E2�
E)�(E)�2F�?Fc��	t|d�}|5t|jd��cddd�S#t$rYywxYw#1swYyxYw)z�Guess whether a file contains text or binary data.
    
    Heuristic: binary if the first 32 bytes include ASCII control characters.
    This rule may change in future versions.
    
    .. versionadded:: 1.0
    r�F� N)r�r��_is_textr�)r3r�s  rrRrR�sV�����t���
�$�����r�
�#�$�$�������$�$�s�4�A�	A�A�Ac�(�td�|D��S)Nc3�XK�|]"}|dkxsd|cxkxrdkncxs|dk(���$y�w)rs�rX�Nra�rL�bs  rrNz_is_text.<locals>.<genexpr>�s-����N�A�q�C�x�?�3�!�?�d�?�?�a�4�i�?�N���(*�r��r�s rrYrY�s���N��N�N�N�Nrc�(�td�|D��S)Nc3�XK�|]"}|dkxsd|cxkxrdkncxs|dk(���$y�w)��� �Nrar^s  rrNz_is_text.<locals>.<genexpr>�s7����+� !��F�{�I�f��&:�F�&:�I�a�6�k�I�+�r`rarbs rrYrY�s!���+�%)�+�+�+�	+rc���t�tsYtt�at
jj�D]'\}}|D]\}}t|j|���)dat|S)aBRetrieve the set of filename extensions matching a given MIMEtype.
    
    Extensions are returned without a leading dot, e.g. 'py'. If no extensions
    are registered for the MIMEtype, returns an empty set.
    
    The extensions are stored in a cache the first time this is called.
    
    .. versionadded:: 1.0
    T)	rF�_mime2ext_cache_uptodaterrO�_mime2ext_cacher�r�r�r�)r�rrSr%�prios     r�get_extensionsrm�so���N�#�%�c�*�� �:�:�+�+�-�	0�K�C��%�
0���t���&�*�*�3�/�
0�	0�$(� ��8�$�$rc�.�|dz
}t|�5}|j�}ddd�tjj	dd�}tjj	||�}tj|�D].}	t|�5}|j�}ddd�k(s�.ydatjj	tj|�|�}t|d�5}|j�ddd�d}	tjtj|	|	tjd��r#tj|�td|	z��y#1swY��JxYw#1swY��xYw#Y��	xYw#1swY��xYw)	aCopy 'package_file' as ``~/.local/share/mime/packages/<application>.xml.``
    If package_file is None, install ``<app_dir>/<application>.xml``.
    If already installed, does nothing. May overwrite an existing
    file with the same name (if the contents are different)r-Nr,�packagesFrUzupdate-mime-databasez�The '%s' command returned an error code!
Make sure you have the freedesktop.org shared MIME package:
http://standards.freedesktop.org/shared-mime-info/)r�r�r2r3r
rr4r&�save_data_path�write�spawnlp�P_WAIT�unlink�	Exception)
r�package_filer��new_data�package_dirr=r��old_data�new_file�commands
          r�install_mime_infor|�so��
�6��K�	
�l�	��q��6�6�8����'�'�,�,�v�z�2�K��w�w�|�|�K��5�H�
�
*�
*�8�
4���	��a��
$�A��6�6�8��
$��x�����O��w�w�|�|�M�8�8��E�{�S�H�
�h��	���	������%�G�	�z�z�"�)�)�W�g�}�/K�/K�F�/S�T�
�	�	�(���G�IP�Q�R�	R�U�9���
$�
$��	�����s;�E*�F�E7�F�1F�*E4�7F	�<F�F�Fr()r�r)Tr�)T);r]r2r�r3rwr�r:r�
xdg.Locale�xml.domrr�collectionsrr8rr�r�r�r$rxr�rr�objectrr�r`rurcrer�r�r�rrPr9r7r5r;r?r=r@rHr&r*rFr-r/r1rBrLrVrRrYrkrjrmr|rarr�<module>r�s����*
�	��
����*�#�
A��
����������
�����a���C�	$�I5�v�I5�V	�Z�	�	�	�	�i.�i.�X;�F�;�z\;�\;�|v*�V�v*�r�f�g����m�^�4���W�m�,��
�G�\�
*�
��7�K�(�	�
�G�V�
$�
��g�x�(���w�	�*�
�
�G�V�
$�
�
���
-���� -�D�#�
/�4��#-�J5<�n$� �O�+��� ��%�,'Rr

Zerion Mini Shell 1.0