%PDF- %PDF-
Direktori : /lib/python2.7/site-packages/salt/utils/ |
Current File : //lib/python2.7/site-packages/salt/utils/gzip_util.pyo |
� ���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l m Z d d l m Z d e j f d � � YZ d d d � Z d d d � Z d d � Z d � Z d d d � Z d S( up salt.utils.gzip ~~~~~~~~~~~~~~~ Helper module for handling gzip consistently between 2.7+ and 2.6- i ( t absolute_importt unicode_literalst print_functionN( t six( t BytesIOt GzipFilec B@ s/ e Z d d d d d � Z d � Z d � Z RS( i c C@ s t j j | | | | | � d S( N( t gzipR t __init__( t selft filenamet modet compresslevelt fileobj( ( s8 /usr/lib/python2.7/site-packages/salt/utils/gzip_util.pyR s c C@ s | S( u+ Context management protocol. Returns self.( ( R ( ( s8 /usr/lib/python2.7/site-packages/salt/utils/gzip_util.pyt __enter__ s c G@ s | j � d S( u+ Context management protocol. Calls close()N( t close( R t args( ( s8 /usr/lib/python2.7/site-packages/salt/utils/gzip_util.pyt __exit__ s N( t __name__t __module__t NoneR R R ( ( ( s8 /usr/lib/python2.7/site-packages/salt/utils/gzip_util.pyR s u rbi c C@ s9 t t j d � r% t j | | | � St | | | � Sd S( Nu __enter__( t hasattrR R t open( R R R ( ( s8 /usr/lib/python2.7/site-packages/salt/utils/gzip_util.pyR $ s c C@ sS t t j d � r4 t j d d d | d | d | � St d d d | d | d | � S( Nu __enter__R u R R R ( R R R ( R R R ( ( s8 /usr/lib/python2.7/site-packages/salt/utils/gzip_util.pyt open_fileobj+ s c C@ sl t � } t | d | � �? } t j rI t | t � rI | j t � } n | j | � Wd QX| j � } | S( u@ Returns the data compressed at gzip level compression. u wbN( R R R t PY3t isinstancet bytest encodet __salt_system_encoding__t writet getvalue( t dataR t buft ogzt compressed( ( s8 /usr/lib/python2.7/site-packages/salt/utils/gzip_util.pyt compress6 s c C@ s8 t | � } t | d � � } | j � } | SWd QXd S( Nu rb( R R t read( R R t igzt unc( ( s8 /usr/lib/python2.7/site-packages/salt/utils/gzip_util.pyt uncompressC s i c c@ s y% t | � } | | k r$ t � n Wn t k rD t d � � n Xz� x� | | k r� t � } t | d | � �g } y | j | j | � � } WnA t k r� t j j j | d � } | j | j | � � } n XWd QX| j � VqK WWd y | j � Wn t k rn XXd S( u� Generator that reads chunk_size bytes at a time from a file/filehandle and yields the compressed result of each read. .. note:: Each chunk is compressed separately. They cannot be stitched together to form a compressed file. This function is designed to break up a file into compressed chunks for transport and decompression/reassembly on a remote host. u chunk_size must be an integeru wbu rbN( t intt ValueErrorR R R R# t AttributeErrort saltt utilst filest fopenR R ( t fh_R t chunk_sizet bytes_readR R ( ( s8 /usr/lib/python2.7/site-packages/salt/utils/gzip_util.pyt compress_fileJ s( " ( t __doc__t __future__R R R R t salt.utils.filesR* t salt.extR t salt.ext.sixR R R R R"