grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a mÂÑi+#ã@sÀdZddlZddlZddlmZddlTddlmZdd„ZiZeƒed<dZ Z d Z Z d Z Zd ZZd ZZd ZZdZZdZZdZZdZZdZZdZZ dZ!Z"dZ#Z$dZ%Z&dZ'Z(dZ)Z*dZ+Z,dZ-Z.dZ/Z0dZ1Z2dZ3Z4dZ5Z6dZ7Z8ed d!ƒZ9Gd"d#„d#e:ƒZ;ge;_edj?Z@e>e@_AeBge@_CedjDZEdeE_Ae>geE_CedjFZGeHeG_Ae>eHgeG_CedjIZJeHeJ_Ae>eBgeJ_CedjKZLeHeL_Ae>eMeNgeL_CedjOZPeHeP_Ae>geP_CedjQZReBeR_Ae>eBgeR_CedjSZTeBeT_Ae>eHgeT_CedjUZVeBeV_Ae>eHgeV_CedjWZXeBeX_Ae>eHgeX_CedjYZZeBeZ_Ae>eHgeZ_Cedj[Z\eBe\_Ae>ge\_CGd$d%„d%e]ƒZ^d&d'„Z_Gd(d)„d)e]ƒZ`e a¡Zbd*d+„Zcd,d-„Zdd.d/„Zed0d1„Zfd2d3„ZgdS)4z Python bindings for libmagic éN)Ú namedtuple)Ú*)Ú find_librarycCstj tdƒ¡S)zc Loads the shared library through ctypes and returns a library L{ctypes.CDLL} instance Úmagic)ÚctypesZcdllZ LoadLibraryr©rrú)/usr/lib/python3.9/site-packages/magic.pyÚ_initsr réééééé é@é€éiiiiii i@i€iiiii i°?Ú FileMagic)Ú mime_typeÚencodingÚnamec@s eZdZdS)Ú magic_setN)Ú__name__Ú __module__Ú __qualname__rrrrr9src@s†eZdZdd„Zdd„Zedd„ƒZedd„ƒZd d „Zd d „Z d d„Z dd„Z dd„Z ddd„Z dd„Zdd„Zdd„Zdd„ZdS)ÚMagiccCs||_t|_dS©N)Ú_magic_tÚ_close)ÚselfÚmsrrrÚ__init__pszMagic.__init__cCs|jr| |j¡dS)zO Closes the magic database and deallocates any resources used. N)rr©rrrrÚclosetsz Magic.closecCsF|dur dSt|tƒr|Sz t|dƒWSty@t|ƒYS0dS©Nzutf-8)Ú isinstanceÚstrÚ TypeError)ÚsrrrZ__tostr{s   z Magic.__tostrcCsF|dur dSt|tƒr|Sz t|dƒWSty@t|ƒYS0dSr$)r%Úbytesr')ÚbrrrZ __tobytes†s   zMagic.__tobytescCst t|jt |¡ƒ¡S)zè Returns a textual description of the contents of the argument passed as a filename or None if an error occurred and the MAGIC_ERROR flag is set. A call to errno() will return the numeric error code. )rÚ _Magic__tostrÚ_filerÚ_Magic__tobytes©rÚfilenamerrrÚfile‘sz Magic.filecCst t|j|ƒ¡S)zï Returns a textual description of the contents of the argument passed as a file descriptor or None if an error occurred and the MAGIC_ERROR flag is set. A call to errno() will return the numeric error code. )rr+Ú _descriptorr)rÚfdrrrÚ descriptor™szMagic.descriptorcCst t|j|t|ƒƒ¡S)zæ Returns a textual description of the contents of the argument passed as a buffer or None if an error occurred and the MAGIC_ERROR flag is set. A call to errno() will return the numeric error code. )rr+Ú_bufferrÚlen)rÚbufrrrÚbuffer¡sz Magic.buffercCst t|jƒ¡S)zh Returns a textual explanation of the last error or None if there was no error. )rr+Ú_errorrr"rrrÚerror©sz Magic.errorcCs t|j|ƒS)a* Set flags on the magic object which determine how magic checking behaves; a bitwise OR of the flags described in libmagic(3), but without the MAGIC_ prefix. Returns -1 on systems that don't support utime(2) or utimes(2) when PRESERVE_ATIME is set. )Ú _setflagsr)rÚflagsrrrÚsetflags°s zMagic.setflagsNcCst|jt |¡ƒS)a  Must be called to load entries in the colon separated list of database files passed as argument or the default database file if no argument before any magic queries can be performed. Returns 0 on success and -1 on failure. )Ú_loadrrr-r.rrrÚload»sz Magic.loadcCst|jt |¡ƒS)aD Compile entries in the colon separated list of database files passed as argument or the default database file if no argument. The compiled files created are named from the basename(1) of each file argument with ".mgc" appended to it. Returns 0 on success and -1 on failure. )Ú_compilerrr-©rZdbsrrrÚcompileÅs z Magic.compilecCst|jt |¡ƒS©zÞ Check the validity of entries in the colon separated list of database files passed as argument or the default database file if no argument. Returns 0 on success and -1 on failure. )Ú_checkrrr-r@rrrÚcheckÐsz Magic.checkcCst|jt |¡ƒSrB)Ú_listrrr-r@rrrÚlistÚsz Magic.listcCs t|jƒS)a Returns a numeric error code. If return value is 0, an internal magic error occurred. If return value is non-zero, the value is an OS error code. Use the errno module or os.strerror() can be used to provide detailed error information. )Ú_errnorr"rrrÚerrnoäsz Magic.errno)N)rrrr!r#Ú staticmethodr+r-r0r3r7r9r<r>rArDrFrHrrrrros       rcCs tt|ƒƒS)zd Returns a magic object on success and None on failure. Flags argument as for setflags. )rÚ_open)r;rrrÚopenîsrKc@seZdZdd„Zdd„ZdS)Ú MagicDetectcCs4tttƒƒ|_|j ¡tttƒƒ|_|j ¡dSr)rrJÚ MAGIC_MIMEÚ mime_magicr>Ú MAGIC_NONEÚ none_magicr"rrrr!øs zMagicDetect.__init__cCs|j ¡|j ¡dSr)rNr#rPr"rrrÚ__del__þs zMagicDetect.__del__N)rrrr!rQrrrrrL÷srLcCs*ttddƒ}|dur&tƒ}ttd|ƒ|S)NZmagic_instance)ÚgetattrÚ threadlocalrLÚsetattr)ÚvrrrÚ _detect_makes   rVcCsDz| d¡\}}Wnty,t|ƒ‚Yn0t||| dd¡d�S)Nz; zcharset=Ú)rrr)ÚsplitÚ ValueErrorrÚreplace)Z mime_detectedZ type_detectedrZ mime_encodingrrrÚ_create_filemagic s  ÿr[cCs tƒ}t|j |¡|j |¡ƒS)zdDetect mime type, encoding and file type from a filename Returns a `FileMagic` namedtuple. )rVr[rNr0rP)r/ÚxrrrÚdetect_from_filenames  ÿr]cCs(| ¡}tƒ}t|j |¡|j |¡ƒS)zjDetect mime type, encoding and file type from file-like object Returns a `FileMagic` namedtuple. )ÚfilenorVr[rNr3rP)ZfobjZfile_descriptorr\rrrÚdetect_from_fobjs   ÿr_cCs tƒ}t|j |¡|j |¡ƒS)z_Detect mime type, encoding and file type from bytes Returns a `FileMagic` namedtuple. )rVr[rNr7rP)Z byte_contentr\rrrÚdetect_from_content+s  ÿr`)hÚ__doc__rÚ threadingÚ collectionsrZ ctypes.utilrr Z _librariesrOZNONEZ MAGIC_DEBUGÚDEBUGZ MAGIC_SYMLINKZSYMLINKZMAGIC_COMPRESSZCOMPRESSZ MAGIC_DEVICESZDEVICESZMAGIC_MIME_TYPEZ MIME_TYPEZMAGIC_CONTINUEZCONTINUEZ MAGIC_CHECKZCHECKZMAGIC_PRESERVE_ATIMEZPRESERVE_ATIMEZ MAGIC_RAWZRAWZ MAGIC_ERRORZERRORZMAGIC_MIME_ENCODINGZ MIME_ENCODINGrMZMIMEZ MAGIC_APPLEZAPPLEZMAGIC_NO_CHECK_COMPRESSZNO_CHECK_COMPRESSZMAGIC_NO_CHECK_TARZ NO_CHECK_TARZMAGIC_NO_CHECK_SOFTZ NO_CHECK_SOFTZMAGIC_NO_CHECK_APPTYPEZNO_CHECK_APPTYPEZMAGIC_NO_CHECK_ELFZ NO_CHECK_ELFZMAGIC_NO_CHECK_TEXTZ NO_CHECK_TEXTZMAGIC_NO_CHECK_CDFZ NO_CHECK_CDFZMAGIC_NO_CHECK_TOKENSZNO_CHECK_TOKENSZMAGIC_NO_CHECK_ENCODINGZNO_CHECK_ENCODINGZMAGIC_NO_CHECK_BUILTINZNO_CHECK_BUILTINrZ StructurerZ_fields_ZPOINTERZmagic_tZ magic_openrJZrestypeZc_intÚargtypesZ magic_closerZ magic_filer,Zc_char_pZmagic_descriptorr1Z magic_bufferr4Zc_void_pZc_size_tZ magic_errorr8Zmagic_setflagsr:Z magic_loadr=Z magic_compiler?Z magic_checkrCZ magic_listrEZ magic_errnorGÚobjectrrKrLÚlocalrSrVr[r]r_r`rrrrÚs¢