o
    !d                     @   sP   d Z ddlmZ dZG dd deZdd Zdd	 Zd
d ZG dd deZ	dS )z+Add S3 specific event streaming output arg.    )CustomArgumentz(Filename where the records will be savedc                   @   s   e Zd ZdS )DocSectionNotFoundErrorN)__name__
__module____qualname__ r   r   Busr/lib/python3.10/site-packages/awscli/customizations/s3events.pyr      s    r   c                 C   s   |  dt | dt d S )Nz3building-argument-table.s3api.select-object-contentz&doc-output.s3api.select-object-content)registeradd_event_stream_output_argZregister_lastreplace_event_stream_docs)Zevent_handlersr   r   r   register_event_stream_arg   s   r   c                 K   s$   t dtdd|jjd |d| d< d S )NoutfilestringTpayload)nameZ	help_textZcli_type_nameZpositional_arg
stream_keysession)S3SelectStreamOutputArgumentSTREAM_HELP_TEXTZoutput_shapeZserialization)Zargument_tableZoperation_modelr   kwargsr   r   r   r
   "   s   
r
   c                 K   sZ   | j }d}|dkr!z| }W n ty   td|  w |dks	|d |d d S )N z======
Output
======z7Could not find the "output" section for the command: %sz======
Output
======
zdThis command generates no output.  The selected object content is written to the specified outfile.
)docZ	pop_write
IndexErrorr   write)Zhelp_commandr   r   currentr   r   r   r   +   s   
	r   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )r   Tc                    s,   t t| jdi | || _d | _|| _d S )Nr   )superr   __init___stream_key_output_file_session)selfr   r   r   	__class__r   r   r   ?   s   
z%S3SelectStreamOutputArgument.__init__c                 C   s   || _ | jd| j d S )Nz!after-call.s3.SelectObjectContent)r   r   r	   	save_file)r    
parametersvaluer   r   r   add_to_paramsG   s   z*S3SelectStreamOutputArgument.add_to_paramsc                 K   st   | j |vrd S || j  }t| jd}|D ]}d|v r$||d d  qW d    n1 s/w   Y  || j = d S )NwbZRecordsZPayload)r   openr   r   )r    parsedr   Zevent_streamfpeventr   r   r   r#   L   s   

z&S3SelectStreamOutputArgument.save_file)r   r   r   Z_DOCUMENT_AS_REQUIREDr   r&   r#   __classcell__r   r   r!   r   r   <   s
    r   N)
__doc__Zawscli.argumentsr   r   	Exceptionr   r   r
   r   r   r   r   r   r   <module>   s   
	