L iQKdZddlZddlZddlmZ ddlmZ ddl Z ddl Z ddl m Z  ddl Z dZiadZdZd Zd Zd Zd Zd Zd%dZGddZGddeZGddeZGddeZGddeZdZdZdZdZ dZ!GddejDZ#Gdd eZ$Gd!d"e#Z%Gd#d$eZ&y#e$r ddlmZYwxYw#e$rdZ YwxYw#e$rdZ YwxYw#e$rdZ YwxYw)&z/Classes and functions for managing compressors.N) LooseVersion)RLock) LZ4FrameFilezMLZ4 is not installed. Install it with pip: https://python-lz4.readthedocs.io/sZFxssBZs7zXZs]s"Mct|tstdj|t|tstdj||j |t |j drBt |j dr,t |j drt |j ds$tdj|j |tvr|std j||t|<y) zRegister a new compressor. Parameters ---------- compressor_name: str. The name of the compressor. compressor: CompressorWrapper An instance of a 'CompressorWrapper'. z/Compressor name should be a string, '{}' given.zHCompressor should implement the CompressorWrapper interface, '{}' given.Nreadwriteseektellz^Compressor 'fileobj_factory' attribute should implement the file object interface, '{}' given.z#Compressor '{}' already registered.) isinstancestr ValueErrorformatCompressorWrapperfileobj_factoryhasattr _COMPRESSORS)compressor_name compressorforces W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/joblib/compressor.pyregister_compressorr/s os + = D D_ U   j"3 4 %%+VJ%7  !!- J.. 7z117;z116:z116: ??Ev**@  ,&u>EEoVWW$.L!c&eZdZdZddZddZdZy)raA wrapper around a compressor file object. Attributes ---------- obj: a file-like object The object must implement the buffer interface and will be used internally to compress/decompress the data. prefix: bytestring A bytestring corresponding to the magic number that identifies the file format associated to the compressor. extension: str The file extension used to automatically select this compressor during a dump to a file. c.||_||_||_yN)rprefix extension)selfobjrrs r__init__zCompressorWrapper.__init__hs" "rNcR||j|dS|j|d|S0Returns an instance of a compressor file object.wb) compresslevelrrfileobjr&s rcompressor_filez!CompressorWrapper.compressor_filems3  ''6 6'']'S Src&|j|dSz2Returns an instance of a decompressor file object.rbr'rr)s rdecompressor_filez#CompressorWrapper.decompressor_filets##GT22r)rr)__name__ __module__ __qualname____doc__r!r*r/rrrrXs # T3rrc.eZdZeZdZdZdZddZdZ y)BZ2CompressorWrapperz.bz2cJttj|_yd|_yr)bz2BZ2Filerrs rr!zBZ2CompressorWrapper.__init__}s ?#&;;D #'D rc&t tdy)Nz;bz2 module is not compiled on your python standard library.)r9rr;s r_check_versionsz$BZ2CompressorWrapper._check_versionss ;M  rNcr|j||j|dS|j|d|Sr#r=rr(s rr*z$BZ2CompressorWrapper.compressor_files?   ''6 6'']'S SrcJ|j|j|d}|Sr,r?r.s rr/z&BZ2CompressorWrapper.decompressor_files% &&w5rr) r1r2r3 _BZ2_PREFIXrrr!r=r*r/r5rrr7r7ys! FI(  Trr7c2eZdZeZdZdZdZdZddZ dZ y) LZMACompressorWrapperz.lzma FORMAT_ALONEct5tj|_tt|j|_yd|_yr)lzmaLZMAFilergetattr_lzma_format_name _lzma_formatr;s rr!zLZMACompressorWrapper.__init__s1  #'==D 'd.D.D ED #'D rc&t tdy)NzO>O'P P''d&7&7 ( rc.tj|dSr,)rFrGr.s rr/z'LZMACompressorWrapper.decompressor_files}}Wd++rr) r1r2r3 _LZMA_PREFIXrrrIr!r=r*r/r5rrrCrCs& FI&( ,rrCceZdZeZdZdZy)XZCompressorWrapperz.xz FORMAT_XZN)r1r2r3 _XZ_PREFIXrrrIr5rrrQrQs FI#rrQc.eZdZeZdZdZdZddZdZ y)LZ4CompressorWrapperz.lz4c6t t|_yd|_yr)lz4rrr;s rr!zLZ4CompressorWrapper.__init__s ?#/D #'D rcttttj}|j dr|dd}t |t dkrtty)Nvz0.19)rWrLZ4_NOT_INSTALLED_ERROR __version__ startswithr)r lz4_versions rr=z$LZ4CompressorWrapper._check_versionssX ;45 5oo  ! !# &%ab/K  $|F'; ;45 5 = 2.7. If filename is a str or bytes object, it gives the name of the file to be opened. Otherwise, it should be a file object, which will be used to read or write the compressed data. mode can be 'rb' for reading (default) or 'wb' for (over)writing If mode is 'wb', compresslevel can be a number between 1 and 9 specifying the level of compression: 1 produces the least compression, and 9 produces the most compression. 3 is the default. ct|_d|_d|_t|_d|_d|_||_t|tr d|cxkrdksntdj||dk(r>t|_tj|j |_d|_d|_nm|d k(rZt(|_tj*|jtj,|j tj.d|_ntd |t|t2r#t5j6|||_d |_yt9|d s t9|d r||_yt;d)NFrrZ zS'compresslevel' must be an integer between 1 and 9. You provided 'compresslevel={}'r-rr%zInvalid mode: Trr z1filename must be a str or bytes object, or a file)r_lock_fp_closefp _MODE_CLOSED_mode_pos_sizer&r intrr _MODE_READzlib decompressobjwbits _decompressor_buffer_buffer_offset _MODE_WRITE compressobjDEFLATED DEF_MEM_LEVEL _compressorr ioopenr TypeError)rfilenamemoder&s rr!zBinaryZlibFile.__init__s;W  !   *--a=6MA6MCCI6-CX  4<#DJ!%!3!3DJJ!?D DL"#D  T\$DJ#//""DMM4::t?Q?QST D 49: : h $wwx.DH DM Xv &'(G*DDHOP PrcP|j5|jtk(r dddy |jttfvrd|_nM|jt k(r:|jj|jjd|_ |jr|jjd|_d|_ t|_d|_ d|_ dddy#d|_d|_ t|_d|_ d|_wxYw# |jr|jjd|_d|_ t|_d|_ d|_w#d|_d|_ t|_d|_ d|_wxYwxYw#1swYyxYw)zFlush and close the file. May be called more than once without error. Once the file is closed, any other operation on it will raise a ValueError. NFrr)rjrnrmrr_MODE_READ_EOFrvryrkr r}flushrlcloserwrxr;s rrzBinaryZlibFile.close(s[ ZZ ,zz\) , , ,::*n!==)-D&ZZ;.HHNN4#3#3#9#9#;<'+D$,}}(#DH$)DM!-DJ#&DL*+D'% , , $DH$)DM!-DJ#&DL*+D',}}(#DH$)DM!-DJ#&DL*+D' $DH$)DM!-DJ#&DL*+D'% , ,sMFA-D&C1'F1)DFF&E-(F-)F FFF%c(|jtk(S)zTrue if this file is closed.)rnrmr;s rclosedzBinaryZlibFile.closedBszz\))rcV|j|jjS)z3Return the file descriptor for the underlying file.)_check_not_closedrkfilenor;s rrzBinaryZlibFile.filenoGs  xx  rcZ|jxr|jjS)z)Return whether the file supports seeking.)readablerkseekabler;s rrzBinaryZlibFile.seekableLs }}6488#4#4#66rcR|j|jttfvS)z/Return whether the file was opened for reading.)rrnrrrr;s rrzBinaryZlibFile.readablePs"  zzj.999rcH|j|jtk(S)z/Return whether the file was opened for writing.)rrnryr;s rwritablezBinaryZlibFile.writableUs  zz[((rc|jr?t|jdd}d}||dj|z }|dz }t |y)NnamezI/O operation on closed filez {}.)rrHrkrr)rfnamemsgs rrz BinaryZlibFile._check_not_closed\sQ ;;DHHfd3E0C u||E** 3JCS/ ! rc~|jttfvr%|jt j dy)NzFile not open for reading)rnrrrrr~UnsupportedOperationr;s r_check_can_readzBinaryZlibFile._check_can_reades6 ::j.9 9  " " $))*EF F :rct|jtk7r%|jtjdy)NzFile not open for writing)rnryrr~rr;s r_check_can_writezBinaryZlibFile._check_can_writejs1 :: $  " " $))*EF F %rc|jttfvr%|jt j d|j jst j dy)Nz3Seeking is only supported on files open for readingz3The underlying file object does not support seeking)rnrrrrr~rrkrr;s r_check_can_seekzBinaryZlibFile._check_can_seekosb ::j.9 9  " " $))E xx  "))E #rc|jtk(ry|jt|jk(r |j j xs|jjt}|st |j j||_d|_|jt|jk(ry#t$rt|_|j|_ YywxYw)NFrT)rnrrxlenrwrv unused_datarkr _BUFFER_SIZEEOFError decompressrorp)rrawblocks r _fill_bufferzBinaryZlibFile._fill_buffer{s :: '!!S%66 G--99XTXX]]<=X"N  $11<NNuN5f, 6!KLL ! $))#   V  7993   s B=CCc~|j5|j|jcdddS#1swYyxYw)z!Return the current file position.N)rjrror;s rr zBinaryZlibFile.tells1 ZZ   " " $99   s3<N)r-rd)T)rh)r)r1r2r3r4rs MAX_WBITSrur!rpropertyrrrrrrrrrrrrrrr rr r r5rrrfrfs. NNE$QL,4**! 7: )"G G , $ $8 .7& (TrrfceZdZdZy)ZlibCompressorWrappercFtj|ttdy)Nz.zr rr)rr!rf _ZLIB_PREFIXr;s rr!zZlibCompressorWrapper.__init__!s"" n\T # rNr1r2r3r!r5rrrr  rrceZdZdZdZy)BinaryGzipFilea A file object providing transparent gzip (de)compression. If filename is a str or bytes object, it gives the name of the file to be opened. Otherwise, it should be a file object, which will be used to read or write the compressed data. mode can be 'rb' for reading (default) or 'wb' for (over)writing If mode is 'wb', compresslevel can be a number between 1 and 9 specifying the level of compression: 1 produces the least compression, and 9 produces the most compression. 3 is the default. N)r1r2r3r4rur5rrrr's  ErrceZdZdZy)GzipCompressorWrappercFtj|ttdy)Nz.gzr)rr!r _GZIP_PREFIXr;s rr!zGzipCompressorWrapper.__init__9s"" n\U # rNrr5rrrr8rrr)F)'r4r~rsjoblib.backportsr threadingr ImportErrordummy_threadingr9rW lz4.framerrFr[r _ZFILE_PREFIXrrrArSrOrbrrr7rCrQrUrmrrrryrrrfrrrr5rrrs\5 )&& T      $  ! &/R33B,>,-,@$/$ 3,3F    uR&&up  - ^" - ]&%&  C  C  DsDB:C CC%: CC CCC"!C"%C/.C/