o
    EDi                     @   sX   d dl Z d dlmZmZ d dlmZmZmZ dd Zdd Z	dd	 Z
d
d Zdd ZdS )    N)islicetee)urlparseparse_qsunquotec                 c   s    t | ttfr+d}| |||  }|r)t|V  ||7 }| |||  }|sd S d S t| }tt||}|rF|V  tt||}|s8d S d S )Nr   )
isinstancelisttupleiterr   )seqniitemit r   W/var/www/Datamplify/venv/lib/python3.10/site-packages/clickhouse_driver/util/helpers.pychunks   s   
r   c                 C   s    t | \}}t|d  t||S )N)r   nextzip)iterableabr   r   r   pairwise   s   

r   c                 #   sb    | D ]}t |ttfstdt|q fdd| D }	 dd |D }t|s-d S |V  q )Nz7Unsupported column type: {}. list or tuple is expected.c                    s   g | ]}t | qS r   )r   .0columnr   r   r   
<listcomp>'       z!column_chunks.<locals>.<listcomp>Tc                 S   s   g | ]}t |g qS r   )r   r   r   r   r   r   +   r   )r   r   r	   	TypeErrorformattypeany)columnsr   r   gr   r   r   r   column_chunks   s   
r%   c                 C   sB   t | tr|   } | dv rdS | dv rdS td|  t| S )N)trueyesonyt1T)falsenooffr   f0FzString is not true/false: %r)r   strstriplower
ValueErrorbool)objr   r   r   asbool2   s   
r7   c           
   	   C   s  t | } i }i }| j}| jdur| j|d< | jddd}|r#||d< | jdur/t| j|d< | jdur;t| j|d< | jd	krDd
|d< h d}h d}t	| j
 D ]\}}|r]t|s^qS|d }|dkrz| }||v rs|||< qSt|||< qS|dkrt|||< qS|dkrt|||< qS|dkrt|||< qS|dkr|||< qS||v rt|||< qS|dkrt|||< qS|dkrt|||< qS|dkrzt|||< W qS ty   |d}	t|	d t|	d t|	d f||< Y qSw |dkrt|||< qS|dkr
t|||< qS|dkrt|||< qS|dkr#tt|||< qS|dv r-|||< qS|dkr7||d< qS|||< qS|rC||d< ||fS )a  
    Parses url into host and kwargs suitable for further Client construction.
    Return host and kwargs.

    For example::

        clickhouse://[user:password]@localhost:9000/default
        clickhouses://[user:password]@localhost:9440/default

    Three URL schemes are supported:

        * clickhouse:// creates a normal TCP socket connection
        * clickhouses:// creates a SSL wrapped TCP socket connection

    Any additional querystring arguments will be passed along to
    the Connection class's initializer.
    Nport/    databaseuserpasswordclickhousesTsecure>   lz4zstdlz4hc>   connect_timeoutsend_receive_timeoutsync_request_timeoutr   compression	use_numpyround_robinclient_namecompress_block_sizesettings_is_importanttcp_keepalive,   client_revisionverifycheck_hostnamessl_version)ca_certscipherskeyfilekeypasscertfileserver_hostname	alt_hostssettings)r   hostnamer8   pathreplaceusernamer   r>   schemer   queryitemslenr3   r7   floatintr4   splitgetattrssl)
urlr[   kwargshostr]   compression_algstimeoutsnamevaluepartsr   r   r   	parse_url>   s   















rq   )rh   	itertoolsr   r   urllib.parser   r   r   r   r   r%   r7   rq   r   r   r   r   <module>   s    