o
    RDi[
                     @  s   d dl mZ d dlmZ erddlmZ d dlZd dlmZm	Z	 ddl
mZ G dd	 d	eZG d
d deZG dd deZG dd deZdS )    )annotations)TYPE_CHECKING   )SnowflakeConnectionN)ABCabstractmethod)CMD_TYPE_UPLOADc                   @  s,   e Zd ZdZedd Ze	dddZdS )	FileOperationParserBasezGThe interface of internal utility functions for file operation parsing.c                 C     d S N self
connectionr   r   h/var/www/Datamplify/venv/lib/python3.10/site-packages/snowflake/connector/direct_file_operation_utils.py__init__      z FileOperationParserBase.__init__Fc                 C  s   dS )zRConverts the file operation details into a SQL and returns the SQL parsing result.Nr   )r   stage_locationlocal_file_nametarget_directorycommand_typeoptionshas_source_from_streamr   r   r   parse_file_operation   s   z,FileOperationParserBase.parse_file_operationNF)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r	      s    
r	   c                   @  s*   e Zd ZdZedd ZedddZdS )	StreamDownloaderBasezKThe interface of internal utility functions for stream downloading of file.c                 C  r
   r   r   r   r   r   r   r   &   r   zStreamDownloaderBase.__init__Fc                 C  r
   r   r   r   ret
decompressr   r   r   download_as_stream*   r   z'StreamDownloaderBase.download_as_streamNr   )r   r   r   r   r   r   r#   r   r   r   r   r   #   s    
r   c                   @  s"   e Zd Zd	ddZ	d
ddZdS )FileOperationParserr   r   c                 C  s
   || _ d S r   )_connectionr   r   r   r   r   0   s   
zFileOperationParser.__init__Fc                 C  s   |pi }d dd | D }|tkr.|r"tj|\}}d| }d| d| }	|g}
ntd| | j }|j	|
|}|j
|	|dd	W  d
   S 1 sTw   Y  d
S )z[Parses a file operation by constructing SQL and getting the SQL parsing result from server. c                 s  s"    | ]\}}| d | V  qdS )=Nr   ).0kvr   r   r   	<genexpr>>   s     z;FileOperationParser.parse_file_operation.<locals>.<genexpr>zfile://zPUT z ? zunsupported command type: T)binding_paramsis_internalN)joinitemsr   ospathsplitNotImplementedErrorr%   cursor_process_params_qmarks_execute_helper)r   r   r   r   r   r   r   options_in_sqlunprefixed_local_file_namesqlparamsr4   processed_paramsr   r   r   r   3   s"   
$z(FileOperationParser.parse_file_operationN)r   r   r   )r   r   r   r   r   r   r   r   r   r$   /   s    

r$   c                   @  s   e Zd Zdd ZdddZdS )StreamDownloaderc                 C  r
   r   r   r   r   r   r   r   T   s   zStreamDownloader.__init__Fc                 C  s   t d)Nz'download_as_stream is not yet supported)r3   r    r   r   r   r#   W   s   z#StreamDownloader.download_as_streamNr   )r   r   r   r   r#   r   r   r   r   r<   S   s    r<   )
__future__r   typingr   r   r   r0   abcr   r   	constantsr   r	   r   r$   r<   r   r   r   r   <module>   s    $