%PDF- %PDF-
Mini Shell

Mini Shell

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

�

!��bt:���dZddlZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZe
ZGd�de�ZGd�d�ZiZd�Zd9d
�Zd9d�Zd9d�Zd
dlmZej2�ZejZd�Zd�Zd�Z	ddlm Z d�Z!d�Z#ejHZ$ee$_%ege$_&ejNZ'de'_%ege'_&ejPZ(ee(_%ege(_&ejRZ)ee)_%ege)_&ejTZ+ee+_%eege+_&ee+_,d�Z*ejZZ.ee._%ee
e	ge._&ee._,d�Z-ej^Z/ee/_%eege/_&ee/_,ej^Z0ee0_%eege0_&ee0_,d�Z/ejbZ2ee2_%eege2_&ee2_,d�Z1ejfZ3ee3_%eege3_&ejhZ4ee4_%eege4_&ejjZ5ee5_%eege5_&d	Z6e7ed�r_e7ed�rVdZ6ejpZ9ee9_%eeee	�ge9_&ee9_,ejtZ;ee;_%eeee	�ge;_&ee;_,d�Z8d�Z:d	Z<e7ed�rdZ<ejzZ=ee=_%ge=_&d �Z>dZ?d
Z@d!ZAd"ZBd#ZCd$ZDd%ZEd$ZFd&ZGd'ZHd(ZId)ZJd*ZKd+ZLd,ZMd-ZNd.ZOd/ZPd0ZQd1ZRd2ZSd3ZTd4ZUdZVd
ZWd!ZXd5ZYd"ZZd6Z[d7Z\d8�Z]e]e^��y#e"$rd�Z!Y��qwxYw):ai
magic is a wrapper around the libmagic file identification library.

See README for more information.

Usage:

>>> import magic
>>> magic.from_file("testdata/test.pdf")
'PDF document, version 1.2'
>>> magic.from_file("testdata/test.pdf", mime=True)
'application/pdf'
>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
'PDF document, version 1.2'
>>>

�N)�c_char_p�c_int�c_size_t�c_void_p�byref�POINTERc���eZdZ�fd�Z�xZS)�MagicExceptionc�:��tt|�|�||_y�N)�super�	Exception�__init__�message)�selfr�	__class__s  ��0/usr/lib/python3/dist-packages/magic/__init__.pyrzMagicException.__init__!s���
�i��'��0����)�__name__�
__module__�__qualname__r�
__classcell__)rs@rr
r
 s
����rr
c�F�eZdZdZ		dd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zy)�Magicz;
    Magic is a wrapper around the libmagic C library.
    Nc��t|_|r|xjtzc_|r|xjtzc_|r|xjtzc_|r|xjt
zc_|r|xjtzc_|r|xjtzc_t|j�|_	tj�|_t|j|�|rtr
t�dkrt!d��t"r	|j%t&d�yy#t($r
}Yd}~yd}~wwxYw)a
        Create a new libmagic wrapper.

        mime - if True, mimetypes are returned instead of textual descriptions
        mime_encoding - if True, codec is returned
        magic_file - use a mime database other than the system default
        keep_going - don't stop at the first match, keep going
        uncompress - Try to look inside compressed files.
        raw - Do not try to decode "non-printable" chars.
        extension - Print a slash-separated list of valid extensions for the file type found.
        iz<MAGIC_EXTENSION is not supported in this version of libmagic�@N)�
MAGIC_NONE�flags�MAGIC_MIME_TYPE�MAGIC_MIME_ENCODING�MAGIC_CONTINUE�MAGIC_COMPRESS�	MAGIC_RAW�MAGIC_EXTENSION�
magic_open�cookie�	threading�Lock�lock�
magic_load�_has_version�version�NotImplementedError�
_has_param�setparam�MAGIC_PARAM_NAME_MAXr
)	r�mime�
magic_file�
mime_encoding�
keep_going�
uncompress�raw�	extension�es	         rrzMagic.__init__+s��� ��
���J�J�/�)�J���J�J�-�-�J���J�J�.�(�J���J�J�.�(�J���J�J�)�#�J���J�J�/�)�J� ����,����N�N�$��	��4�;�;�
�+��l�g�i�#�o�%�&d�e�e��
��
�
�2�B�7���"�
���
�s�D6�6	E	�E	c�J�|j5	t|�tk(r ttk7r|j	dd��}tt
|j|��cddd�S#t$r$}|j|�cYd}~cddd�Sd}~wwxYw#1swYyxYw)z0
        Identify the contents of `buf`
        �utf-8�replace)�errorsN)
r)�type�str�bytes�encode�maybe_decode�magic_bufferr&r
�
_handle509Bug)r�bufr8s   r�from_bufferzMagic.from_buffer^s����Y�Y�
	-�	
-�
��9��#��u���*�*�W�Y�*�?�C�#�L����c�$B�C�
	-�
	-��"�
-��)�)�!�,�,�
	-�
	-��
-��
	-�
	-�s5�B�AA)�)	B�2B�B�B�B�B�B"c�(�t|�5	ddd�|j5	tt|j|��cddd�S#1swY�?xYw#t
$r$}|j
|�cYd}~cddd�Sd}~wwxYw#1swYyxYwr)�
_real_openr)rAr2r&r
rC)r�filenamer8s   r�	from_filezMagic.from_filens���
��
!�	��	��Y�Y�	-�
-�#�J�t�{�{�H�$E�F�	-�	-�	�	��"�
-��)�)�!�,�,�		-�	-��
-��	-�	-�s?�A�B�A�A�	B�!B�1B�2B�B�B�Bc���|j5	tt|j|��cddd�S#t$r$}|j|�cYd}~cddd�Sd}~wwxYw#1swYyxYwr)r)rA�magic_descriptorr&r
rC)r�fdr8s   r�from_descriptorzMagic.from_descriptorysi��
�Y�Y�	-�
-�#�$4�T�[�[�"�$E�F�	-�	-��"�
-��)�)�!�,�,�		-�	-��
-��	-�	-�s2�A'�7�	A$�A�A$�A'�A$�$A'�'A0c�F�|j�|jtzry|�)Nzapplication/octet-stream)rrr)rr8s  rrCzMagic._handle509Bug�s!��
�9�9��$�*�*��">�-��Grc�0�t|j||�Sr)�magic_setparamr&)r�param�vals   rr/zMagic.setparam�s���d�k�k�5�#�6�6rc�.�t|j|�Sr)�magic_getparamr&)rrQs  r�getparamzMagic.getparam�s���d�k�k�5�1�1rc�~�t|d�r1|jr$trt|j�d|_yyyy)Nr&)�hasattrr&�magic_close)rs r�__del__z
Magic.__del__�s4���4��"�t�{�{�{�����$��D�K�8C�{�"r)FNFFFFF)rrr�__doc__rrErIrMrCr/rUrY�rrrr&s:���CH�JO�1�f-� 	-�-��7�2�
rrc�^�tj|�}|�t|��x}t|<|S)N)r1)�
_instances�getr)r1�is  r�_get_magic_typer`�s.�����t��A��y�$�$�/�/��J�t���HrFc�:�t|�}|j|�S)z�"
    Accepts a filename and returns the detected filetype.  Return
    value is the mimetype if mime=True, otherwise a human readable
    name.

    >>> magic.from_file("testdata/test.pdf", mime=True)
    'application/pdf'
    )r`rI)rHr1�ms   rrIrI�s��	���A��;�;�x� � rc�:�t|�}|j|�S)z�
    Accepts a binary string and returns the detected filetype.  Return
    value is the mimetype if mime=True, otherwise a human readable
    name.

    >>> magic.from_buffer(open("testdata/test.pdf").read(1024))
    'PDF document, version 1.2'
    )r`rE)�bufferr1rbs   rrErE�s��	���A��=�=�� � rc�:�t|�}|j|�S)a
    Accepts a file descriptor and returns the detected filetype.  Return
    value is the mimetype if mime=True, otherwise a human readable
    name.

    >>> f = open("testdata/test.pdf")
    >>> magic.from_descriptor(f.fileno())
    'PDF document, version 1.2'
    )r`rM)rLr1rbs   rrMrM�s��	���A����R� � r�)�loaderc�<�|�t|d�}t|��|S)Nr��magic_errorr
��result�func�args�errs    r�errorcheck_nullrp�s%��
�~��$�q�'�"���S�!�!��
rc�B�|dk(rt|d�}t|��|S)N���rrirks    r�errorcheck_negative_oners�s'��
��|��$�q�'�"���S�!�!��
rc�D�ttk(r|S|jdd�S)Nr:�backslashreplace)r>r?�decode)�ss rrArA�s"��
�e�|����x�x��!3�4�4r)�PathLikec�F�t|t�r|j�S|Sr)�
isinstancerx�
__fspath__�rHs r�unpathr}�s ���h��)��&�&�(�(��Orc��|Srr[r|s rr}r}�s���rc���|�yt|�}tjddkxrt|t�xs(tjddk\xrt|t
�}|r|j
dd�S|S)Nr��r:�surrogateescape)r}�sys�version_inforz�unicoder>r@)rH�
is_unicodes  r�coerce_filenamer��s�������h��H��"�"�1�%��*�/��H�g�.�-��"�"�1�%��*�,��X�s�+������w�(9�:�:��rc�,�t|t|��Sr)�_magic_filer��r&rHs  rr2r2(����v��x�8�9�9rc�.�t||t|��Sr)�
_magic_buffer�len)r&rDs  rrBrB2s�����c�#�h�/�/rc��t||�Sr)�_magic_descriptor)r&rLs  rrKrKAs���V�R�(�(rc�,�t|t|��Sr)�_magic_loadr�r�s  rr*r*Kr�rrPrTTc�f�tstd��t|�}t||t	|��S)Nzmagic_setparam not implemented)r.r-r�_magic_setparamr)r&rQrR�vs    rrPrPis-���!�"B�C�C���
�A��6�5�%��(�3�3rc�|�tstd��t�}t||t	|��|j
S)Nzmagic_getparam not implemented)r.r-r�_magic_getparamr�value)r&rQrRs   rrTrTps2���!�"B�C�C�
�*�C��F�E�5��:�.��9�9�r�
magic_versionc�8�tstd��t�S)Nzmagic_version not implemented)r+r-r�r[rrr,r,�s���!�"A�B�B��?�rr����ii� r��iii i@i�iiiiir���c�^�
�ddl�
ddl}ddlm}�
fd�}gd�}|D]}||j|�||<�|jd�}t
dg�}|jj�D]<\}}	|j|�s�||vr||vr�!|||	k7rtd|z���8|	||<�>y)Nr)�compatc������fd�}|S)Nc�@���jdt��|i|��S)Nz�Using compatibility mode with libmagic's python binding. See https://github.com/ahupp/python-magic/blob/master/COMPAT.md for details.)�warn�PendingDeprecationWarning)rn�kwargs�fn�warningss  ��r�_z3_add_compat.<locals>.deprecation_wrapper.<locals>._�s*����M�M�_�)�
+�
�t�&�v�&�&rr[)r�r�r�s` �r�deprecation_wrapperz(_add_compat.<locals>.deprecation_wrapper�s���	'��r)�detect_from_filename�detect_from_content�detect_from_fobj�openz	^[A-Z_]+$�
MAGIC_MIMEzinconsistent value for )
r��re�magicr��__dict__�compile�set�items�matchr)�	to_moduler�r�r�r��fname�is_const_re�allowed_inconsistent�namer�r�s          @r�_add_compatr��s������	�
�B��G��.�v���u�/E�F�	�%��G��*�*�[�)�K���~�.�����,�,�.�
(���e����T�"��y� ��/�/���T�?�e�+�#�$=��$D�E�E��"'�	�$��
(r)F)_rZr��glob�ctypes�ctypes.utilr'�loggingrrrrrrr�rGrr
rr]r`rIrErM�rg�load_lib�libmagic�magic_trprsrA�osrxr}�ImportErrorr�r%�restype�argtypesrXrj�magic_errnor2r��errcheckrBr�rKr�r*r��magic_setflags�magic_check�
magic_compiler.rWrPr�rTr�r+r�r,r�MAGIC_DEBUG�
MAGIC_SYMLINKr"�
MAGIC_DEVICESrr r�r$r!�MAGIC_CHECK�MAGIC_PRESERVE_ATIMEr#�MAGIC_ERROR�MAGIC_NO_CHECK_COMPRESS�MAGIC_NO_CHECK_TAR�MAGIC_NO_CHECK_SOFT�MAGIC_NO_CHECK_APPTYPE�MAGIC_NO_CHECK_ELF�MAGIC_NO_CHECK_ASCII�MAGIC_NO_CHECK_TROFF�MAGIC_NO_CHECK_FORTRAN�MAGIC_NO_CHECK_TOKENS�MAGIC_PARAM_INDIR_MAXr0�MAGIC_PARAM_ELF_PHNUM_MAX�MAGIC_PARAM_ELF_SHNUM_MAX�MAGIC_PARAM_ELF_NOTES_MAX�MAGIC_PARAM_REGEX_MAX�MAGIC_PARAM_BYTES_MAXr��globalsr[rr�<module>r�s����$��
����F�F��
��Y��v�v�r�
�
�
!�
!�!���6�?�?���
�/�/����5�	����*�
 �
 �
��
���g�
���"�"������y����"�"������y����"�"������y����!�!�������*���&���:��%�%�
� �
��!�8�X�6�
��(�
��0��,�,��#���$�e�,���+����-�-��$���%�u�-���,���)��!�!�������*���.���:��(�(�����"�E�*����"�"�������*����&�&�
��
��!�8�,�
��
�
�
�8�%�&�7�8�=M�+N��J��-�-�O�#�O�� '����0A�B�O��6�O���-�-�O�#�O�� '����0A�B�O��6�O��4����
�8�_�%��L��*�*�M�!�M���M����
����
����
������
����������	���"������!��������!�� ����������������#(�L�G�I���y����s�	K/�/K;�:K;

Zerion Mini Shell 1.0