ó
è?F[c           @   sV   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   Key(   t   SimpleResultSet(   t   BucketListResultSett   Bucketc           B   sh   e  Z d  „  Z d „  Z d „  Z d d d d „ Z d d „ Z d d e j	 d „ Z
 d e j	 d „ Z RS(   c         C   s   | |  _  | |  _ d S(   sH   Instantiate an anonymous file-based Bucket around a single key.
        N(   t   namet   contained_key(   t   selfR   R   (    (    s/   lib/python2.7/site-packages/boto/file/bucket.pyt   __init__   s    	c         C   s   t  t |  ƒ ƒ S(   N(   t   iterR   (   R   (    (    s/   lib/python2.7/site-packages/boto/file/bucket.pyt   __iter__%   s    c         C   s   d |  j  S(   Ns   anonymous bucket for file://(   R   (   R   (    (    s/   lib/python2.7/site-packages/boto/file/bucket.pyt   __str__(   s    c         C   s   t  j | ƒ d S(   s<  
        Deletes a key from the bucket.

        :type key_name: string
        :param key_name: The key name to delete

        :type version_id: string
        :param version_id: Unused in this subclass.

        :type mfa_token: tuple or list of strings
        :param mfa_token: Unused in this subclass.
        N(   t   ost   remove(   R   t   key_namet   headerst
   version_idt	   mfa_token(    (    s/   lib/python2.7/site-packages/boto/file/bucket.pyt
   delete_key+   s    c         K   s"   t  |  j |  j ƒ } t | g ƒ S(   sÛ   
        This method returns the single key around which this anonymous Bucket
        was instantiated.

        :rtype: SimpleResultSet
        :return: The result from file system listing the keys requested

        (   R    R   R   R   (   R   R   t   paramst   key(    (    s/   lib/python2.7/site-packages/boto/file/bucket.pyt   get_all_keys;   s    	c         C   sK   | d k r% t  |  j d d t  j ƒSt | d ƒ } t  |  j | | ƒ Sd S(   s  
        Check to see if a particular key exists within the bucket.
        Returns: An instance of a Key object or None

        :type key_name: string
        :param key_name: The name of the key to retrieve

        :type version_id: string
        :param version_id: Unused in this subclass.

        :type stream_type: integer
        :param stream_type: Type of the Key - Regular File or input/output Stream

        :rtype: :class:`boto.file.key.Key`
        :returns: A Key object from this bucket.
        t   -t   key_typet   rbN(   R    R   t   KEY_STREAM_READABLEt   open(   R   R   R   R   R   t   fp(    (    s/   lib/python2.7/site-packages/boto/file/bucket.pyt   get_keyG   s    c         C   s†   | d k r% t  |  j d d t  j ƒSt j j | ƒ } | r` t j j | ƒ r` t j | ƒ n  t | d ƒ } t  |  j | | ƒ Sd S(   sä   
        Creates a new key

        :type key_name: string
        :param key_name: The name of the key to create

        :rtype: :class:`boto.file.key.Key`
        :returns: An instance of the newly created key object
        R   R   t   wbN(	   R    R   t   KEY_STREAM_WRITABLER   t   patht   dirnamet   existst   makedirsR   (   R   R   R   t   dir_nameR   (    (    s/   lib/python2.7/site-packages/boto/file/bucket.pyt   new_key_   s    
N(   t   __name__t
   __module__R   R	   R
   t   NoneR   R   R    t   KEY_REGULAR_FILER   R#   (    (    (    s/   lib/python2.7/site-packages/boto/file/bucket.pyR      s   			(	   R   t   boto.file.keyR    t   boto.file.simpleresultsetR   t   boto.s3.bucketlistresultsetR   t   objectR   (    (    (    s/   lib/python2.7/site-packages/boto/file/bucket.pyt   <module>   s   