B
    è?F[Š  ã               @   s   G d d„ de ƒZdS )c               @   sr   e Zd ZdZdd„ Zdd„ Zeddd„ƒZed	d
„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZdd„ ZdS )ÚSchemaa"  
    Represents a DynamoDB schema.

    :ivar hash_key_name: The name of the hash key of the schema.
    :ivar hash_key_type: The DynamoDB type specification for the
        hash key of the schema.
    :ivar range_key_name: The name of the range key of the schema
        or None if no range key is defined.
    :ivar range_key_type: The DynamoDB type specification for the
        range key of the schema or None if no range key is defined.
    :ivar dict: The underlying Python dictionary that needs to be
        passed to Layer1 methods.
    c             C   s
   || _ d S )N)Ú_dict)ÚselfZschema_dict© r   ú3lib/python3.7/site-packages/boto/dynamodb/schema.pyÚ__init__(   s    zSchema.__init__c             C   s&   | j rd| j| j f }n
d| j }|S )NzSchema(%s:%s)z
Schema(%s))Úrange_key_nameÚhash_key_name)r   Úsr   r   r   Ú__repr__+   s    
zSchema.__repr__Nc             C   sF   d|d |d dœi}|dk	r4|d |d dœ|d< | dƒ}||_ |S )aÉ  Convenience method to create a schema object.

        Example usage::

            schema = Schema.create(hash_key=('foo', 'N'))
            schema2 = Schema.create(hash_key=('foo', 'N'),
                                    range_key=('bar', 'S'))

        :type hash_key: tuple
        :param hash_key: A tuple of (hash_key_name, hash_key_type)

        :type range_key: tuple
        :param hash_key: A tuple of (range_key_name, range_key_type)

        ÚHashKeyElementé    é   )ÚAttributeNameÚAttributeTypeNÚRangeKeyElement)r   )ÚclsZhash_keyZ	range_keyZreconstructedÚinstancer   r   r   Úcreate2   s    zSchema.createc             C   s   | j S )N)r   )r   r   r   r   ÚdictR   s    zSchema.dictc             C   s   | j d d S )Nr   r   )r   )r   r   r   r   r   V   s    zSchema.hash_key_namec             C   s   | j d d S )Nr   r   )r   )r   r   r   r   Úhash_key_typeZ   s    zSchema.hash_key_typec             C   s    d }d| j kr| j d d }|S )Nr   r   )r   )r   Únamer   r   r   r   ^   s    
zSchema.range_key_namec             C   s    d }d| j kr| j d d }|S )Nr   r   )r   )r   Útyper   r   r   Úrange_key_typee   s    
zSchema.range_key_typec             C   s0   | j |j ko.| j|jko.| j|jko.| j|jkS )N)r   r   r   r   )r   Úotherr   r   r   Ú__eq__l   s    zSchema.__eq__)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r
   Úclassmethodr   Úpropertyr   r   r   r   r   r   r   r   r   r   r      s   r   N)Úobjectr   r   r   r   r   Ú<module>   s    