U
    3d                     @   s0   d dl mZ G dd deZG dd deZdS )    )Userc                   @   s4   e Zd ZdZdddZdd Zddd	Zd
d ZdS )	ResultSeta&  
    The ResultSet is used to pass results back from the Amazon services
    to the client. It is light wrapper around Python's :py:class:`list` class,
    with some additional methods for parsing XML results from AWS.
    Because I don't really want any dependencies on external libraries,
    I'm using the standard SAX parser that comes with Python. The good news is
    that it's quite fast and efficient but it makes some things rather
    difficult.

    You can pass in, as the marker_elem parameter, a list of tuples.
    Each tuple contains a string as the first element which represents
    the XML element that the resultset needs to be on the lookout for
    and a Python class as the second element of the tuple. Each time the
    specified element is found in the XML, a new instance of the class
    will be created and popped onto the stack.

    :ivar str next_token: A hash used to assist in paging through very long
        result sets. In most cases, passing this value to certain methods
        will give you another 'page' of results.
    Nc                 C   sh   t |  t|t r|| _ng | _d | _d | _d | _d | _d | _d | _	d | _
d | _d| _d | _d| _d S )NFT)list__init__
isinstancemarkersmarker
key_markernext_markernext_key_markernext_upload_id_markernext_version_id_markernext_generation_markerversion_id_markeris_truncated
next_tokenstatusselfZmarker_elem r   2/tmp/pip-unpacked-wheel-d7dsrkjd/boto/resultset.pyr   .   s    

zResultSet.__init__c                 C   sP   | j D ].}||d kr|d |}| | |  S q|dkrLt | _| jS d S )Nr      ZOwner)r   appendr   owner)r   nameattrs
connectiontobjr   r   r   startElement@   s    


zResultSet.startElementtruec                 C   s   ||krdS dS d S NTFr   r   valueZ
true_valuer   r   r   
to_booleanN   s    zResultSet.to_booleanc                 C   s  |dkr|  || _n|dkr*|| _n|dkr<|| _n|dkrN|| _n|dkr`|| _nn|dkrr|| _n\|dkr|| _nJ|dkr|| _n8|d	kr|| _	n&|d
kr|| _
n|dkr|| _n|dkrt|| _n|dkrt|| _n|dkr|| _n|dkr|  || _n|dkr8|  |d| _n|dkrN| | n|dkr`|| _nn|dkrx|| _|| _nV|dkrz| jt|7  _W n   Y nX n&|dkr|  |d| _nt| || d S )NZIsTruncatedMarkerZ	KeyMarkerZ
NextMarkerZNextKeyMarkerZVersionIdMarkerZNextVersionIdMarkerZNextGenerationMarkerZUploadIdMarkerZNextUploadIdMarkerZBucketZ
MaxUploadsZMaxItemsZPrefixreturn
StatusCodeSuccessZItemNameZ	NextToken	nextTokenBoxUsageIsValidTrue)r$   r   r   r	   r
   r   r   r   r   Zupload_id_markerr   ZbucketintZmax_uploadsZ	max_itemsprefixr   r   r   r)   	box_usagefloatsetattrr   r   r#   r   r   r   r   
endElementT   s^    

















zResultSet.endElement)N)r    )__name__
__module____qualname____doc__r   r   r$   r3   r   r   r   r   r      s
   

r   c                   @   s@   e Zd ZdddZdd Zdd Zdd	 ZdddZdd ZdS )BooleanResultNc                 C   s   d| _ d | _d | _d S )NT)r   
request_idr/   r   r   r   r   r      s    zBooleanResult.__init__c                 C   s   | j r
dS dS d S )Nr,   Falser   r   r   r   r   __repr__   s    zBooleanResult.__repr__c                 C   s   | j S Nr;   r<   r   r   r   __nonzero__   s    zBooleanResult.__nonzero__c                 C   s   d S r>   r   )r   r   r   r   r   r   r   r      s    zBooleanResult.startElementr    c                 C   s   ||krdS dS d S r!   r   r"   r   r   r   r$      s    zBooleanResult.to_booleanc                 C   s   |dkr|  || _nl|dkr.|  |d| _nT|dkrF|  |d| _n<|dkrV|| _n,|dkrf|| _n|dkrv|| _nt| || d S )	Nr&   r'   r(   r+   r,   Z	RequestIdZ	requestIdr*   )r$   r   r9   r1   r2   r   r   r   r3      s    zBooleanResult.endElement)N)r    )	r4   r5   r6   r   r=   r?   r   r$   r3   r   r   r   r   r8      s   

r8   N)Zboto.s3.userr   r   r   objectr8   r   r   r   r   <module>   s   p