KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache
System : Linux cs317.bluehost.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : andertr9 ( 1047)
PHP Version : 8.2.18
Disable Function : NONE
Directory :  /lib64/python2.7/site-packages/mercurial/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib64/python2.7/site-packages/mercurial/byterange.pyo
�
Hq�Qc@sUddlZddlZddlZddlZddlZdefd��YZdejfd��YZ	de
fd��YZdejfd	��YZ
dd
lmZmZmZmZmZmZmZddlZddlZddlZddlZdejfd��YZd
ejfd��YZdad�Zd�Zd�ZdS(i����Nt
RangeErrorcBseZdZRS(s6Error raised when an unsatisfiable range is requested.(t__name__t
__module__t__doc__(((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyRstHTTPRangeHandlercBs eZdZd�Zd�ZRS(s�Handler that enables HTTP Range headers.

    This was extremely simple. The Range header is a HTTP feature to
    begin with so all this class does is tell urllib2 that the
    "206 Partial Content" response from the HTTP server is what we
    expected.

    Example:
        import urllib2
        import byterange

        range_handler = range.HTTPRangeHandler()
        opener = urllib2.build_opener(range_handler)

        # install it
        urllib2.install_opener(opener)

        # create Request and set Range header
        req = urllib2.Request('http://www.python.org/')
        req.header['Range'] = 'bytes=30-50'
        f = urllib2.urlopen(req)
    cCs1tj|||j��}||_||_|S(N(turllibt
addinfourltget_full_urltcodetmsg(tselftreqtfpRR	thdrstr((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pythttp_error_2066s		cCstd��dS(NsRequested Range Not Satisfiable(R(R
RRRR	R
((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pythttp_error_416=s(RRRRR(((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyRs	tRangeableFileObjectcBsheZdZd�Zd�Zd�Zdd�Zdd�Zdd�Zd	�Z	d
�Z
d�ZRS(sFile object wrapper to enable raw range handling.
    This was implemented primarily for handling range
    specifications for file:// urls. This object effectively makes
    a file object look like it consists only of a range of bytes in
    the stream.

    Examples:
        # expose 10 bytes, starting at byte position 20, from
        # /etc/aliases.
        >>> fo = RangeableFileObject(file('/etc/passwd', 'r'), (20,30))
        # seek seeks within the range (to position 23 in this case)
        >>> fo.seek(3)
        # tell tells where your at _within the range_ (position 3 in
        # this case)
        >>> fo.tell()
        # read EOFs if an attempt is made to read past the last
        # byte in the range. the following will return only 7 bytes.
        >>> fo.read(30)
    cCs>||_t|�\|_|_d|_|j|j�dS(s}Create a RangeableFileObject.
        fo       -- a file like object. only the read() method need be
                    supported but supporting an optimized seek() is
                    preferable.
        rangetup -- a (firstbyte,lastbyte) tuple specifying the range
                    to work over.
        The file object provided is assumed to be at byte offset 0.
        iN(tfotrange_tuple_normalizet	firstbytetlastbytetrealpost_do_seek(R
Rtrangetup((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyt__init__Vs			cCst|j|�S(s�This effectively allows us to wrap at the instance level.
        Any attribute not found in _this_ object will be searched for
        in self.fo.  This includes methods.(tgetattrR(R
tname((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyt__getattr__dscCs|j|jS(s4Return the position within the range.
        This is different from fo.seek in that position 0 is the
        first byte position of the range tuple. For example, if
        this object was created with a range tuple of (500,899),
        tell() will return 0 when at byte position 500 of the file.
        (RR(R
((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyttelljsicCs�|dkr|j|}n7|dkr8|j|}n|dkrStd��n|jrw||jkrw|j}n|j||j�dS(seSeek within the byte range.
        Positioning is identical to that described under tell().
        iiis$seek from end of file not supported.N(RRtIOErrorRR(R
toffsettwhencet
realoffset((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pytseekssi����cCs:|j|�}|jj|�}|jt|�7_|S(s`Read within the range.
        This method will limit the size read based on the range.
        (t_calc_read_sizeRtreadRtlen(R
tsizetrslt((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyR$�scCs:|j|�}|jj|�}|jt|�7_|S(sfRead lines within the range.
        This method will limit the size read based on the range.
        (R#RtreadlineRR%(R
R&R'((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyR(�scCsX|jrT|dkrA|j||jkrQ|j|j}qQqT|j|j}n|S(sSHandles calculating the amount of data to read based on
        the range.
        i����(RR(R
R&((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyR#�s	cCs<t|jd|j�}||j|�|j|7_dS(s�Seek based on whether wrapped object supports seek().
        offset is relative to the current position (self.realpos).
        R"N(RRt_poor_mans_seekR(R
RR"((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyR�scCs}d}d}xj||krx|||kr8||}n|jj|�}t|�|krktd��n||7}qWdS(s�Seek by calling the wrapped file objects read() method.
        This is used for file like objects that do not have native
        seek support. The wrapped objects read() method is called
        to manually seek to the desired position.
        offset -- read this number of bytes from the wrapped
                  file object.
        raise RangeError if we encounter EOF before reaching the
        specified offset.
        iisRequested Range Not SatisfiableN(RR$R%R(R
Rtpostbufsizetbuf((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyR)�s

(RRRRRRR"R$R(R#RR)(((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyRAs									tFileRangeHandlercBseZdZd�ZRS(s~FileHandler subclass that adds Range support.
    This class handles Range headers exactly like an HTTP
    server would.
    c	Cs�ddl}ddl}|j�}|j�}tj|�}tj|�}|tj}|j	j
|tj�}	|j|�d}
|r�tj
|�\}}|s�tj|�|j�kr�tjd��q�nt|d�}|jjdd�}
t|
�}
|
r�|
\}}|dkr/|}n|dksS||ksS||krbtd��n||}t|||f�}n|jd|
p�d	||	f�}tj||d
|�S(Ni����isfile not on local hosttrbtRangetsRequested Range Not Satisfiables6Content-Type: %s
Content-Length: %d
Last-Modified: %s
s
text/plainsfile:(t	mimetypestemailtget_hosttget_selectorRturl2pathnametoststattST_SIZEtUtilst
formatdatetST_MTIMEt
guess_typet	splitporttsockett
gethostbynamet	get_namesturllib2tURLErrortopentheaderstgettNonetrange_header_to_tupleRRtmessage_from_stringR(R
RR1R2thosttfilet	localfiletstatsR&tmodifiedtmtypetportRtbrangetfbtlbRD((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pytopen_local_file�s8
!	$
(RRRRS(((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyR-�s(R=t	splitusertsplitpasswdt	splitattrtunquotetaddclosehookRtFTPRangeHandlercBseZd�Zd�ZRS(cCs�|j�}|s$tdd��nt|�\}}|dkrNtj}nt|�}t|�\}}|r�t|�\}}nd}t	|�}t	|p�d�}t	|p�d�}yt
j|�}Wn%t
jk
r�}t
j|��nXt|j��\}}|jd�}	tt	|	�}	|	d |	d}	}
|	ra|	dra|	d}	ny|j|||||	�}|
r�dp�d	}xM|D]E}
t|
�\}
}|
j�d
kr�|dkr�|j�}q�q�Wd}t|jjdd��}|r,|\}}|dkr,|}q,n|j|
||�\}}|r�|\}}|dkr�|dks}|dkr�td��n|}||}|dkr�td��q�q�||}t|d|f�}nd}tj|j��d}|r|d|7}n|dk	r;|dkr;|d|7}ntj |�}t!|||j��SWn%tj"k
r�}td|��nXdS(Ns	ftp errors
no host givenR0t/i����iitItDttypetatAtitdR/s@Requested Range Not Satisfiable due to unobtainable file length.sRequested Range Not SatisfiablesContent-Type: %s
sContent-Length: %d
(R^R_R`R[RaR\(#R3RR=RFtftplibtFTP_PORTtintRTRURWR>R?terrorRARBRVR4tsplittmaptconnect_ftptlowertupperRGRDREtretrfileRRR1R<RR2RHRt
all_errors(R
RRIROtusertpasswdR	tpathtattrstdirsRJtfwR]tattrtvaluetrestt	range_tupRQRRRtretrlenRDRN((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pytftp_open�sx



cCst|||||�}|S(N(t
ftpwrapper(R
RmRnRIRORqRr((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyRhDs(RRRxRh(((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyRY�s	ORycBseZdd�ZRS(c
Cs�|j�|dkr%d}d}nd|}d}y|jj|�Wn.tjk
ry|j�|jj|�nXd}|r�|r�y|jj|�Wn%tjk
r�}t	d|��nX|jj|�y#d|}|jj
||�}Wq�tjk
r�}t|�jd	�r]|j
||�\}}	t||d
f�}||	fSt|�jd�s�t	d|��q�q�Xn|s�|jjd�|r�d|}nd
}|jj
|�}nd|_t|djd�|j�|dfS(NRaR\sTYPE AisTYPE is	ftp errorsRETR t501R0t550sLIST tLISTR.(RaR\(tendtransfertftptvoidcmdRbRltinitRFtnlstt
error_permRtntransfercmdtstrt
startswithRkRtbusyRXtmakefile(
R
RJR]RutcmdtisdirtconntreasonRRw((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyRkMsJ
	





	N(RRRFRk(((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyRyHscCs�|dkrdStdkr:ddl}|jd�antj|�}|r�t|jdd��}|r�|dr�|d|ddf}n|SdS(s�Get a (firstbyte,lastbyte) tuple from a Range header value.

    Range headers have the form "bytes=<firstbyte>-<lastbyte>". This
    function pulls the firstbyte and lastbyte values and returns
    a (firstbyte,lastbyte) tuple. If lastbyte is not specified in
    the header value, it is returned as an empty string in the
    tuple.

    Return None if range_header is None
    Return () if range_header does not conform to the range spec
    pattern.

    i����Ns^bytes=(\d{1,})-(\d*)iii((RFt_rangeretretcompiletmatchRtgroup(trange_headerR�R�ttup((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyRG�scCsS|dkrdSt|�}|rO|drG|d|ddf}nd|SdS(s�Convert a range tuple to a Range header value.
    Return a string of the form "bytes=<firstbyte>-<lastbyte>" or None
    if no range is needed.
    iisbytes=%s-%sN(RFR(Rv((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pytrange_tuple_to_header�s
cCs�|dkrdS|d}|dkr/d}nt|�}y|d}Wntk
rbd}n1X|dkrxd}n|dkr�t|�}n||fdkr�dS||kr�td||f��n||fS(s6Normalize a (first_byte,last_byte) range tuple.
    Return a tuple whose first element is guaranteed to be an int
    and whose second element will be '' (meaning: the last byte) or
    an int. Finally, return None if the normalized tuple == (0,'')
    as that is equivalent to retrieving the entire file.
    iR0isInvalid byte range: %s-%sN(NR0(iR0(RFRdt
IndexErrorR(RvRQRR((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyR�s&
	

	( R6R7RRAtemail.UtilsR2RRtBaseHandlerRtobjectRtFileHandlerR-R=RTRURVRWRXRRbR>R1t
FTPHandlerRYRyRFR�RGR�R(((s9/usr/lib64/python2.7/site-packages/mercurial/byterange.pyt<module>s&#�,4T:		

Anon7 - 2021