f)Hc@sdZddddddgZdZdd lZdd lZdd lZydd lmZWn"ek rdd l mZYnXdd l m Z m Z dZ d Zd ZdZdZGdddejZddeeeddZdddZddZd S(uInterface to the libbzip2 compression library. This module provides a file interface, classes for incremental (de)compression, and functions for one-shot (de)compression. uBZ2Fileu BZ2CompressoruBZ2Decompressoruopenucompressu decompressu%Nadeem Vawda iN(uRLock(u BZ2CompressoruBZ2Decompressoriiii cBsm|EeZdZdZdd8dddZddZedd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZddZd9ddZd9ddZd d!d"Zd:d$d%Zd;d&d'Zd(d)Zd<d*d+Zd=d,d-Zd.d/Zd0d1Zd2d3Zd d4d5Zd6d7Zd8S(>uBZ2Fileu@A file object providing transparent bzip2 (de)compression. A BZ2File can act as a wrapper for an existing file object, or refer directly to a named file on disk. Note that BZ2File provides a *binary* file interface - data read is returned as bytes, and data to be written should be given as bytes. uri cCst|_d|_d|_t|_d|_d|_ |dk rXt j dt nd|koodknst dn|dkrd}t}t|_d |_d|_ni|dkrd }t}t||_n?|dkrd }t}t||_nt dj|t|ttfrdtj|||_d|_||_n?t|dst|dr||_||_n tddS(uOpen a bzip2-compressed file. If filename is a str or bytes object, is 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 'r' for reading (default), 'w' for (over)writing, or 'a' for appending. These can equivalently be given as 'rb', 'wb', and 'ab'. buffering is ignored. Its use is deprecated. If mode is 'w' or 'a', compresslevel can be a number between 1 and 9 specifying the level of compression: 1 produces the least compression, and 9 (default) produces the most compression. If mode is 'r', the input file may be the concatenation of multiple compressed streams. iiu)Use of 'buffering' argument is deprecatedi u%compresslevel must be between 1 and 9uururbsuwuwbuauabuInvalid mode: {!r}ureaduwriteu1filename must be a str or bytes object, or a fileNFi(uururb(uwuwb(uauabT(uRLocku_lockuNoneu_fpuFalseu_closefpu _MODE_CLOSEDu_modeu_posu_sizeuwarningsuwarnuDeprecationWarningu ValueErroru _MODE_READuBZ2Decompressoru _decompressoru_bufferu_buffer_offsetu _MODE_WRITEu BZ2Compressoru _compressoruformatu isinstanceustrubytesubuiltinsuopenuTrueuhasattru TypeError(uselfufilenameumodeu bufferingu compresslevelu mode_code((u(/opt/alt/python33/lib64/python3.3/bz2.pyu__init__+sD                   uBZ2File.__init__cCs|j|jtkrdSzY|jttfkrAd|_n4|jtkru|jj |j j d|_ nWdz|j r|jj nWdd|_d|_ t|_d|_d|_XXWdQXdS(uFlush 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. NsiF(u_locku_modeu _MODE_CLOSEDu _MODE_READu_MODE_READ_EOFuNoneu _decompressoru _MODE_WRITEu_fpuwriteu _compressoruflushu_closefpucloseuFalseu_bufferu_buffer_offset(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyucloseis"       u BZ2File.closecCs |jtkS(uTrue if this file is closed.(u_modeu _MODE_CLOSED(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyuclosedsuBZ2File.closedcCs|j|jjS(u3Return the file descriptor for the underlying file.(u_check_not_closedu_fpufileno(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyufilenos uBZ2File.filenocCs|jo|jjS(u)Return whether the file supports seeking.(ureadableu_fpuseekable(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyuseekablesuBZ2File.seekablecCs|j|jttfkS(u/Return whether the file was opened for reading.(u_check_not_closedu_modeu _MODE_READu_MODE_READ_EOF(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyureadables uBZ2File.readablecCs|j|jtkS(u/Return whether the file was opened for writing.(u_check_not_closedu_modeu _MODE_WRITE(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyuwritables uBZ2File.writablecCs|jrtdndS(NuI/O operation on closed file(uclosedu ValueError(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyu_check_not_closeds uBZ2File._check_not_closedcCs5|jttfkr1|jtjdndS(NuFile not open for reading(u_modeu _MODE_READu_MODE_READ_EOFu_check_not_closeduiouUnsupportedOperation(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyu_check_can_reads uBZ2File._check_can_readcCs/|jtkr+|jtjdndS(NuFile not open for writing(u_modeu _MODE_WRITEu_check_not_closeduiouUnsupportedOperation(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyu_check_can_writes uBZ2File._check_can_writecCsV|jttfkr1|jtjdn|jjsRtjdndS(Nu3Seeking is only supported on files open for readingu3The underlying file object does not support seeking(u_modeu _MODE_READu_MODE_READ_EOFu_check_not_closeduiouUnsupportedOperationu_fpuseekable(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyu_check_can_seeks  uBZ2File._check_can_seekc Cs|jtkrdSx|jt|jkr |jjpI|jj t }|s|jj rwt|_|j |_ dStdn|jj rt|_y|jj||_Wqtk rt|_|j |_ dSYqXn|jj||_d|_qWdS(NuACompressed file ended before the end-of-stream marker was reachediFT(u_modeu_MODE_READ_EOFuFalseu_buffer_offsetulenu_bufferu _decompressoru unused_datau_fpureadu _BUFFER_SIZEueofu_posu_sizeuEOFErroruBZ2Decompressoru decompressuOSErroruTrue(uselfurawblock((u(/opt/alt/python33/lib64/python3.3/bz2.pyu _fill_buffers,           uBZ2File._fill_buffercCs|j|jd|_d|_g}xJ|jrt|rP|j|jn|jt|j7_d|_q+W|rdj|SdS(Nis(u_bufferu_buffer_offsetu _fill_bufferuappendu_posulenujoin(uselfu return_dataublocks((u(/opt/alt/python33/lib64/python3.3/bz2.pyu _read_alls  uBZ2File._read_allcCsC|j|}|t|jkrd|j|j|}||_|jt|7_|r`|SdS|j|jd|_d|_g}x|dkr+|jr+|t|jkr|jd|}||_n|j}d|_|r|j|n|jt|7_|t|8}qW|r?dj|SdS(Nis(u_buffer_offsetulenu_bufferu_posuNoneu _fill_bufferuappendujoin(uselfunu return_datauendudataublocks((u(/opt/alt/python33/lib64/python3.3/bz2.pyu _read_blocks*      uBZ2File._read_blockic CsB|j3|j|js$dS|j|jdSWdQXdS(uReturn buffered data without advancing the file position. Always returns at least one byte of data, unless at EOF. The exact number of bytes returned is unspecified. sN(u_locku_check_can_readu _fill_bufferu_bufferu_buffer_offset(uselfun((u(/opt/alt/python33/lib64/python3.3/bz2.pyupeeks    u BZ2File.peekic CsQ|jB|j|dkr$dS|dkr:|jS|j|SWdQXdS(uRead up to size uncompressed bytes from the file. If size is negative or omitted, read until EOF is reached. Returns b'' if the file is already at EOF. isN(u_locku_check_can_readu _read_allu _read_block(uselfusize((u(/opt/alt/python33/lib64/python3.3/bz2.pyureads     u BZ2File.readc Cs|j|j|dksE|jt|jkrI|j rIdS|dkr|j|j|j|}|jt|7_n(|j|jd}d|_d|_|jt|7_|SWdQXdS(uRead up to size uncompressed bytes, while trying to avoid making multiple reads from the underlying stream. Returns b'' if the file is at EOF. isN(u_locku_check_can_readu_buffer_offsetulenu_bufferu _fill_bufferu_pos(uselfusizeudata((u(/opt/alt/python33/lib64/python3.3/bz2.pyuread1s   %    u BZ2File.read1c Cs'|jtjj||SWdQXdS(u_Read up to len(b) bytes into b. Returns the number of bytes read (0 for EOF). N(u_lockuiouBufferedIOBaseureadinto(uselfub((u(/opt/alt/python33/lib64/python3.3/bz2.pyureadinto:s uBZ2File.readintoc Cst|ts<t|ds-tdn|j}n|j|j|dkr|jjd|j d}|dkr|j|j |}||_ |j t |7_ |Snt j j||SWdQXdS(u Read a line of uncompressed bytes from the file. The terminating newline (if present) is retained. If size is non-negative, no more than size bytes will be read (in which case the line may be incomplete). Returns b'' if already at EOF. u __index__uInteger argument expectedis iN(u isinstanceuintuhasattru TypeErroru __index__u_locku_check_can_readu_bufferufindu_buffer_offsetu_posulenuiouBufferedIOBaseureadline(uselfusizeuenduline((u(/opt/alt/python33/lib64/python3.3/bz2.pyureadlineBs     uBZ2File.readlinec Csct|ts<t|ds-tdn|j}n|jtjj||SWdQXdS(uRead a list of lines of uncompressed bytes from the file. size can be specified to control the number of lines read: no further lines will be read once the total size of the lines read so far equals or exceeds size. u __index__uInteger argument expectedN( u isinstanceuintuhasattru TypeErroru __index__u_lockuiouBufferedIOBaseu readlines(uselfusize((u(/opt/alt/python33/lib64/python3.3/bz2.pyu readlinesYs  uBZ2File.readlinesc Cs_|jP|j|jj|}|jj||jt|7_t|SWdQXdS(uWrite a byte string to the file. Returns the number of uncompressed bytes written, which is always len(data). Note that due to buffering, the file on disk may not reflect the data written until close() is called. N(u_locku_check_can_writeu _compressorucompressu_fpuwriteu_posulen(uselfudatau compressed((u(/opt/alt/python33/lib64/python3.3/bz2.pyuwritegs   u BZ2File.writec Cs'|jtjj||SWdQXdS(uWrite a sequence of byte strings to the file. Returns the number of uncompressed bytes written. seq can be any iterable yielding byte strings. Line separators are not added between the written byte strings. N(u_lockuiouBufferedIOBaseu writelines(uselfuseq((u(/opt/alt/python33/lib64/python3.3/bz2.pyu writelinesus uBZ2File.writelinescCsG|jjddt|_d|_t|_d|_d|_dS(Nis( u_fpuseeku _MODE_READu_modeu_posuBZ2Decompressoru _decompressoru_bufferu_buffer_offset(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyu_rewinds     uBZ2File._rewindc Cs|j|j|dkr#no|dkr?|j|}nS|dkr}|jdkrm|jddn|j|}ntdj|||jkr|jn ||j8}|j |dd|jSWdQXdS(uChange the file position. The new position is specified by offset, relative to the position indicated by whence. Values for whence are: 0: start of stream (default); offset must not be negative 1: current stream position 2: end of stream; offset must not be positive Returns the new file position. Note that seeking is emulated, so depending on the parameters, this operation may be extremely slow. iiiu return_datauInvalid value for whence: {}NF( u_locku_check_can_seeku_posu_sizeu _read_alluFalseu ValueErroruformatu_rewindu _read_block(uselfuoffsetuwhence((u(/opt/alt/python33/lib64/python3.3/bz2.pyuseeks        u BZ2File.seekcCs%|j|j|jSWdQXdS(u!Return the current file position.N(u_locku_check_not_closedu_pos(uself((u(/opt/alt/python33/lib64/python3.3/bz2.pyutells  u BZ2File.tellNTiiii( u__name__u __module__u __qualname__u__doc__uNoneu__init__ucloseupropertyuclosedufilenouseekableureadableuwritableu_check_not_closedu_check_can_readu_check_can_writeu_check_can_seeku _fill_bufferuTrueu _read_allu _read_blockupeekureaduread1ureadintoureadlineu readlinesuwriteu writelinesu_rewinduseekutell(u __locals__((u(/opt/alt/python33/lib64/python3.3/bz2.pyuBZ2File s4 >         #    *urbi cCsd|kr1d|krtd|fqnQ|d k rLtdn|d k rgtdn|d k rtdn|jdd}t||d|}d|krtj||||S|Sd S( uOpen a bzip2-compressed file in binary or text mode. The filename argument can be an actual filename (a str or bytes object), or an existing file object to read from or write to. The mode argument can be "r", "rb", "w", "wb", "a" or "ab" for binary mode, or "rt", "wt" or "at" for text mode. The default mode is "rb", and the default compresslevel is 9. For binary mode, this function is equivalent to the BZ2File constructor: BZ2File(filename, mode, compresslevel). In this case, the encoding, errors and newline arguments must not be provided. For text mode, a BZ2File object is created, and wrapped in an io.TextIOWrapper instance with the specified encoding, error handling behavior, and line ending(s). utubuInvalid mode: %ru0Argument 'encoding' not supported in binary modeu.Argument 'errors' not supported in binary modeu/Argument 'newline' not supported in binary modeuu compresslevelN(u ValueErroruNoneureplaceuBZ2Fileuiou TextIOWrapper(ufilenameumodeu compressleveluencodinguerrorsunewlineubz_modeu binary_file((u(/opt/alt/python33/lib64/python3.3/bz2.pyuopens      cCs#t|}|j||jS(uCompress a block of data. compresslevel, if given, must be a number between 1 and 9. For incremental compression, use a BZ2Compressor object instead. (u BZ2Compressorucompressuflush(udatau compresslevelucomp((u(/opt/alt/python33/lib64/python3.3/bz2.pyucompresss c Csg}xv|r~t}y|j|}Wntk rL|rEPnYnX|j||jsrtdn|j}q Wdj|S(ujDecompress a block of data. For incremental decompression, use a BZ2Decompressor object instead. uACompressed data ended before the end-of-stream marker was reacheds(uBZ2Decompressoru decompressuOSErroruappendueofu ValueErroru unused_dataujoin(udatauresultsudecompures((u(/opt/alt/python33/lib64/python3.3/bz2.pyu decompresss      (u__doc__u__all__u __author__ubuiltinsuiouwarningsu threadinguRLocku ImportErrorudummy_threadingu_bz2u BZ2CompressoruBZ2Decompressoru _MODE_CLOSEDu _MODE_READu_MODE_READ_EOFu _MODE_WRITEu _BUFFER_SIZEuBufferedIOBaseuBZ2FileuNoneuopenucompressu decompress(((u(/opt/alt/python33/lib64/python3.3/bz2.pyus,     '