KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21573/root/usr/lib/python2.4/site-packages/urlgrabber/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21573/root/usr/lib/python2.4/site-packages/urlgrabber/byterange.pyo
mò
AÝrMc@s˜dkZdkZdkZdkZdkZdZydklZWn"e	j
oZ
dklZnXdefd„ƒYZdei
fd„ƒYZdefd„ƒYZdfd	„ƒYZd
eifd„ƒYZdklZlZlZlZlZlZlZdkZdkZdkZdkZdkZdkZd
eifd„ƒYZ dei!fd„ƒYZ!da"d„Z#d„Z$d„Z%dS(N(sStringIOt
RangeErrorcBstZdZRS(s6Error raised when an unsatisfiable range is requested.(t__name__t
__module__t__doc__(((t8/usr/lib/python2.4/site-packages/urlgrabber/byterange.pyR#stHTTPRangeHandlercBs tZdZd„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" reponse 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)
    cCs1ti|||iƒƒ}||_||_|S(N(	turllibt
addinfourltfpthdrstreqtget_full_urltrtcodetmsg(tselfR
RR
RR	R((Rthttp_error_206?s		cCstdƒ‚dS(NsRequested Range Not Satisfiable(R(RR
RR
RR	((Rthttp_error_416Fs(RRRRR(((RR's	tHTTPSRangeHandlercBs tZdZd„Zd„ZRS(s! Range Header support for HTTPS. cCs|i|||||ƒS(N(RRR
RR
RR	(RR
RR
RR	((Rthttps_error_206MscCs|i|||||ƒdS(N(Rthttps_error_416R
RR
RR	(RR
RR
RR	((RRPs(RRRRR(((RRJs	tRangeableFileObjectcBshtZdZd„Zd„Zd„Zdd„Zdd„Zdd„Zd	„Z	d
„Z
d„ZRS(s"File object wrapper to enable raw range handling.
    This was implemented primarilary 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|_|i|iƒdS(sCreate 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(tfoRtrange_tuple_normalizetrangetupt	firstbytetlastbytetrealpost_do_seek(RRR((Rt__init__hs
		cCs4t|i|ƒot|i|ƒSnt|‚dS(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.N(thasattrRRtnametgetattrtAttributeError(RR((Rt__getattr__vscCs|i|iS(s5Return 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.
        N(RRR(R((Rttell~sicCs˜|djo|i|}n<|djo|i|}n|djotdƒ‚n|io||ijo
|i}n|i||iƒdS(seSeek within the byte range.
        Positioning is identical to that described under tell().
        iiis$seek from end of file not supported.N(	twhenceRRtoffsett
realoffsetRtIOErrorRR(RR%R$R&((Rtseek‡s



iÿÿÿÿcCs:|i|ƒ}|ii|ƒ}|it|ƒ7_|S(s`Read within the range.
        This method will limit the size read based on the range.
        N(Rt_calc_read_sizetsizeRtreadtrsltRtlen(RR*R,((RR+šs
cCs:|i|ƒ}|ii|ƒ}|it|ƒ7_|S(sfRead lines within the range.
        This method will limit the size read based on the range.
        N(RR)R*RtreadlineR,RR-(RR*R,((RR.£s
cCs^|ioP|djo/|i||ijo|i|i}qVqZ|i|i}n|S(sSHandles calculating the amount of data to read based on
        the range.
        iÿÿÿÿN(RRR*R(RR*((RR)¬s

cCsNt|idƒp|i|ƒn|ii|i|ƒ|i|7_dS(sSeek based on whether wrapped object supports seek().
        offset is relative to the current position (self.realpos).
        R(N(RRRt_poor_mans_seekR%R(R(RR%((RR¸scCsƒd}d}xp||job|||jo||}n|ii|ƒ}t|ƒ|jotdƒ‚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(	tpostbufsizeR%RRR+tbufR-R(RR%R0R1R2((RR/Ãs	
(RRRRR"R#R(R+R.R)RR/(((RRSs								tFileRangeHandlercBstZdZd„ZRS(s~FileHandler subclass that adds Range support.
    This class handles Range headers exactly like an HTTP
    server would.
    cCsÈdk}dk}|iƒ}|iƒ}ti|ƒ}
t
i|
ƒ}|ti
}ti|tiƒ}|i|ƒd}|oOti|ƒ\}}|pti|ƒ|iƒjotidƒ‚qÔnt|
dƒ}|ii ddƒ}t#|ƒ}|o}|\}	}
|
djo
|}
n|	djp|	|jp
|
|jot&dƒ‚n|
|	}t'||	|
fƒ}n|i(t)d|pd||fƒƒ}ti*||d	|ƒS(
Nisfile not on local hosttrbtRangetsRequested Range Not Satisfiables6Content-Type: %s
Content-Length: %d
Last-modified: %s
s
text/plainsfile:(+t	mimetypest	mimetoolsR
tget_hostthosttget_selectortfileRturl2pathnamet	localfiletoststattstatstST_SIZER*trfc822t
formatdatetST_MTIMEtmodifiedt
guess_typetmtypet	splitporttporttsockett
gethostbynameRt	get_namesturllib2tURLErrortopenRtheaderstgettNonetbrangetrange_header_to_tupletfbtlbRRtMessagetStringIOR(RR
R8RTRHR<RJR*RARVR>R7R:RWRRFRQ((Rtopen_local_fileÜs6		
#

'
)(RRRRZ(((RR3×s(s	splitports	splituserssplitpasswds	splitattrsunquotesaddclosehooks
addinfourltFTPRangeHandlercBstZd„Zd„ZRS(NcCsÆ|iƒ}|p
td‚nt|ƒ\}}|djo
ti}n
t	|ƒ}t
|ƒ\}}|ot|ƒ\}}
nd}
t|ƒ}t|pdƒ}t|
pdƒ}
yti|ƒ}Wn'tij
o}ti|ƒ‚nXt|iƒƒ\}}|idƒ}tt|ƒ}|d |d}}|o|do|d}ny#|i||
|||ƒ}|odpd	}
xP|D]H}t|ƒ\}}|i#ƒd
jo|djo|i$ƒ}
q¡q¡Wd}t&|i'i(ddƒƒ}	|	o'|	\}}|djo
|}q<n|i,||
|ƒ\}}|	o—|	\}}|djo[|djp
|djot/dƒ‚n|}||}|djot/dƒ‚qñqõ||}t0|d|fƒ}nd}t1i2|i3ƒƒd}|o|d|7}n|dj	o|djo|d|7}nt5|ƒ}t7i8|ƒ}t9|||i3ƒƒSWn4ti:j
o%}td|ft;i<ƒd‚nXdS(Ns	ftp errors
no host givenR6t/iÿÿÿÿiitItDttypetatAtitdR5s@Requested Range Not Satisfiable due to unobtainable file length.sRequested Range Not SatisfiablesContent-Type: %s
sContent-Length: %d
i(s	ftp errors
no host given(R`RaRbR]RcR^(=R
R9R:R'RIRJRStftplibtFTP_PORTtintt	splitusertusertsplitpasswdtpasswdtunquoteRKRLterrorRRNROt	splitattrR;tpathtattrstsplittdirstmapR<Rtconnect_ftptfwR_tattrtvaluetlowertuppertrestRURQRRt	range_tupRVRWtretrfileRtretrlenRRR7RGRRHRYtsfR8RXRt
all_errorstsystexc_info(RR
RRyRHRoR<RJRWRzR_RqRtRjRR:RhRnR|RuRVRvRQR}((Rtftp_opens|


 




cCst|||||ƒ}|S(N(t
ftpwrapperRhRjR:RJRqRt(RRhRjR:RJRqRt((RRsZs(RRRRs(((RR[s	NR‚cBstZdd„ZRS(Nc
Cs1|iƒ|djod}d}nd|}d}y|ii|ƒWn0tij
o!|i	ƒ|ii|ƒnXd}	|o.|o&y|ii
|ƒWn4tij
o%}td|ftiƒd‚nX|ii|ƒy#d	|}|ii||ƒ}	Wq¹tij
o’}t|ƒd
 djo;|i||ƒ\}}t||dfƒ}||fSqµt|ƒd
 d
jo td|ftiƒd‚qµq¹Xn|	pA|iidƒ|od|}nd}|ii|ƒ}	nd|_t|	didƒ|iƒ|	dfS(NRcR^sTYPE AisTYPE is	ftp errorisRETR it501R6t550sLIST tLISTR4(RcR^(RtendtransferR_tcmdtisdirtftptvoidcmdRdR~tinitRStconnR<tnlstt
error_permtreasonR'RR€tntransfercmdRytstrR{RR|Rtbusytaddclosehooktmakefile(
RR<R_RyRˆR‡RRR|RŒ((RR{csF


!
)	(RRRSR{(((RR‚^scCs¦|djodSntdjodk}|idƒanti|ƒ}|oNt|iddƒƒ}|o'|do|d|ddf}n|SnfS(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.
    
    Ns^bytes=(\d{1,})-(\d*)iii(	trange_headerRSt_rangeretretcompiletmatchRtgroupttup(R•R›R—R™((RRU“s


	cCs_|djodSnt|ƒ}|o3|do|d|ddf}nd|SndS(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(RzRSR(Rz((Rtrange_tuple_to_header®s
cCsì|djodSn|d}|djo
d}n
t|ƒ}y|d}Wntj
o
d}n6X|djo
d}n|djot|ƒ}n||fdjodSn||jotd||fƒ‚n||fS(s7Normalize 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 equivelant to retrieving the entire file.
    iR6isInvalid byte range: %s-%sN(NR6(iR6(RzRSRVRfRWt
IndexErrorR(RzRVRW((RRºs(







(&R?R@RRNRCRStDEBUGt	cStringIORYtImportErrorRR'RtBaseHandlerRRRtFileHandlerR3RIRgRiRmRkR“RRdRKRR7R8t
FTPHandlerR[R‚R–RURœR(RkR8RRœRRIRgRRR3RmR7RdR@R“RCRRNRRRžR‚RRKRYRURRiR[R?((Rt?s6					#	„+1						S4		

Anon7 - 2021