B
    Ñš[x  ã               @   s4   d Z ddlZddlZddlmZ G dd„ deƒZdS )zImplementation of the DbDoc.é    Né   )ÚSTRING_TYPESc               @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚDbDoczÏRepresents a generic document in JSON format.

    Args:
        value (object): The value can be a JSON string or a dict.

    Raises:
        ValueError: If ``value`` type is not a basestring or dict.
    c             C   s@   t |tƒr|| _n*t |tƒr*t |¡| _ntd t|ƒ¡ƒ‚d S )NzUnable to handle type: {0})	Ú
isinstanceÚdictÚ__dict__r   ÚjsonÚloadsÚ
ValueErrorÚformatÚtype)ÚselfÚvalue© r   ú�C:\Users\HIRONO~1\AppData\Local\Temp\pip-install-ioykiiwb\mysql-connector-python-rf\mysql_connector_python_rf-2.2.2.data\purelib\mysqlx\dbdoc.pyÚ__init__)   s
    

zDbDoc.__init__c             C   s
   | j | S )N)r   )r   Úindexr   r   r   Ú__getitem__2   s    zDbDoc.__getitem__c             C   s
   | j  ¡ S )N)r   Úkeys)r   r   r   r   r   5   s    z
DbDoc.keysc             C   s$   d| j krt ¡ j| j d< | j d S )NÚ_id)r   ÚuuidÚuuid4Úhex)r   r   r   r   Ú	ensure_id8   s    
zDbDoc.ensure_idc             C   s   t  | j¡S )N)r   Údumpsr   )r   r   r   r   Ú__str__=   s    zDbDoc.__str__N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   r       s   	r   )r   r   r   Úcompatr   Úobjectr   r   r   r   r   Ú<module>   s   