File: //usr/lib/python3/dist-packages/magic/__pycache__/__init__.cpython-310.pyc
o
�ܸ`�8 � @ sJ d Z ddlZddlZddlZddlZddlZddlZddlmZmZm Z m
Z
mZmZ e
ZG dd� de�ZG dd� d�Zi Zdd � ZdDdd�ZdDd
d�ZdDdd�ZddlmZ e�� Zej
Zdd� Zdd� Zdd� Zdd� Zej Z ee _!ege _"ej#Z#de#_!ege#_"ej$Z$ee$_!ege$_"ej%Z%ee%_!ege%_"ej&Z'ee'_!eege'_"ee'_(dd� Z&ej)Z*ee*_!ee
e ge*_"ee*_(dd� Z)ej+Z+ee+_!eege+_"ee+_(ej+Z,ee,_!eege,_"ee,_(dd � Z+ej-Z.ee._!eege._"ee._(d!d"� Z-ej/Z/ee/_!eege/_"ej0Z0ee0_!eege0_"ej1Z1ee1_!eege1_"d
Z2e3ed#��r?e3ed$��r?d%Z2ej4Z5ee5_!eeee �ge5_"ee5_(ej6Z7ee7_!eeee �ge7_"ee7_(d&d#� Z4d'd$� Z6d
Z8e3ed(��rZd%Z8ej9Z9ee9_!g e9_"d)d*� Z:dZ;dZ<d+Z=d,Z>d-Z?d.Z@d/ZAd.ZBd0ZCd1ZDd2ZEd3ZFd4ZGd5ZHd6ZId7ZJd8ZKd9ZLd:ZMd;ZNd<ZOd=ZPd>ZQdZRdZSd+ZTd?ZUd,ZVd@ZWdAZXdBdC� ZYeYeZ� � dS )Eai
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 s e Zd Z� fdd�Z� ZS )�MagicExceptionc s t t| ��|� || _d S �N)�super� Exception�__init__�message)�selfr
�� __class__� �0/usr/lib/python3/dist-packages/magic/__init__.pyr ! s
zMagicException.__init__)�__name__�
__module__�__qualname__r �
__classcell__r r r r r s r c @ sV e Zd ZdZ ddd�Zdd� Zdd � Zd
d� Zdd
� Zdd� Z dd� Z
dd� ZdS )�Magicz;
Magic is a wrapper around the libmagic C library.
FNc
C s� t | _|r| jtO _|r| jtO _|r| jtO _|r'| jtO _|r0| jtO _|r9| jtO _t| j�| _ t
�� | _t
| j |� |rWtrSt� dk rWtd��trvz | �td� W dS tyu } zW Y d}~dS d}~ww dS )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�er r r r + s4
���zMagic.__init__c C s� | j �A z!t|�tkrttkr|jddd�}tt| j|��W W d � S tyC } z| � |�W Y d}~W d � S d}~ww 1 sGw Y dS )z0
Identify the contents of `buf`
�utf-8�replace)�errorsN)
r% �type�str�bytes�encode�maybe_decode�magic_bufferr"