Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
usr
/
lib
/
python2.7
/
site-packages
/
boto
/
file
/
File Content:
key.pyc
� �Wc @ sN d d l Z d d l Z d d l Z d d l m Z d e f d � � YZ d S( i����N( t StringIOt Keyc B s� e Z d Z d Z e e BZ d Z d e d � Z d � Z d d d e d � Z d e d d d d d � Z d d d e d d d d � Z d d d e d � Z d � Z d � Z RS( i i i c C s� | | _ | | _ | d k r3 d | _ d | _ n | | _ t j | � j | _ | | _ | | j k r� t j | _ d | _ n0 | | j k r� t j | _ d | _ n | | _ d S( Nt -s <STDIN>s <STDOUT>( t buckett full_patht Nonet namet sizet ost statt st_sizet key_typet KEY_STREAM_READABLEt syst stdint fpt KEY_STREAM_WRITABLEt stdout( t selfR R R R ( ( s1 /usr/lib/python2.7/site-packages/boto/file/key.pyt __init__% s c C s d | j S( Ns file://( R ( R ( ( s1 /usr/lib/python2.7/site-packages/boto/file/key.pyt __str__8 s i c C ss | j | j @r t d � � n. | j | j @r; | j } n t | j d � } z t j | | � Wd | j � Xd S( sT Retrieves a file from a Key :type fp: file :param fp: File pointer to put the data into :type headers: string :param: ignored in this subclass. :type cb: function :param cb: ignored in this subclass. :type cb: int :param num_cb: ignored in this subclass. s Stream is not readablet rbN( R R t BotoClientErrorR R t openR t shutilt copyfileobjt close( R R t headerst cbt num_cbt torrentt key_file( ( s1 /usr/lib/python2.7/site-packages/boto/file/key.pyt get_file; s c C s� | j | j @r t d � � nN | j | j @r; | j } n2 | r[ t j j | j � r[ d St | j d � } z t j | | � Wd | j � Xd S( s Store an object in a file using the name of the Key object as the key in file URI and the contents of the file pointed to by 'fp' as the contents. :type fp: file :param fp: the file whose contents to upload :type headers: dict :param headers: ignored in this subclass. :type replace: bool :param replace: If this parameter is False, the method will first check to see if an object exists in the bucket with the same key. If it does, it won't overwrite it. The default value is True which will overwrite the object. :type cb: function :param cb: ignored in this subclass. :type cb: int :param num_cb: ignored in this subclass. :type policy: :class:`boto.s3.acl.CannedACLStrings` :param policy: ignored in this subclass. :type md5: A tuple containing the hexdigest version of the MD5 checksum of the file as the first element and the Base64-encoded version of the plain checksum as the second element. This is the same format returned by the compute_md5 method. :param md5: ignored in this subclass. s Stream is not writableNt wb( R R R R R R t patht existsR R R R R ( R R R t replaceR R t policyt md5R ( ( s1 /usr/lib/python2.7/site-packages/boto/file/key.pyt set_contents_from_fileV s #c C s t j | j | � d S( s� Copy contents from the current file to the file pointed to by 'fp'. :type fp: File-like object :param fp: :type headers: dict :param headers: Unused in this subclass. :type cb: function :param cb: Unused in this subclass. :type cb: int :param num_cb: Unused in this subclass. :type torrent: bool :param torrent: Unused in this subclass. :type res_upload_handler: ResumableDownloadHandler :param res_download_handler: Unused in this subclass. :type response_headers: dict :param response_headers: Unused in this subclass. N( R R R ( R R R R R R t version_idt res_download_handlert response_headers( ( s1 /usr/lib/python2.7/site-packages/boto/file/key.pyt get_contents_to_file� s c C s t � } | j | � | j � S( s Retrieve file data from the Key, and return contents as a string. :type headers: dict :param headers: ignored in this subclass. :type cb: function :param cb: ignored in this subclass. :type cb: int :param num_cb: ignored in this subclass. :type cb: int :param num_cb: ignored in this subclass. :type torrent: bool :param torrent: ignored in this subclass. :rtype: string :returns: The contents of the file as a string ( R R+ t getvalue( R R R R R R ( ( s1 /usr/lib/python2.7/site-packages/boto/file/key.pyt get_contents_as_string� s c C s | j | j @S( N( R t KEY_STREAM( R ( ( s1 /usr/lib/python2.7/site-packages/boto/file/key.pyt is_stream� s c C s | j j � d S( s� Closes fp associated with underlying file. Caller should call this method when done with this class, to avoid using up OS resources (e.g., when iterating over a large number of files). N( R R ( R ( ( s1 /usr/lib/python2.7/site-packages/boto/file/key.pyR � s N( t __name__t __module__R R R. t KEY_REGULAR_FILER R R t FalseR t TrueR'