
    Jbig
                         d Z ddlZddlmZmZ deeeef         eeeef         z  ez  deeeef         fdZdeeeef         eeeef         z  ez  deeeef         fdZ	dS )z
File upload utilities for the Honcho Python SDK.

This module provides shared functionality for handling file uploads across
both sync and async client implementations.
    N)BytesIOIOBasefilereturnc                    t          | t                    rrt          |           dk    r_| \  }}}t          |t                    rt	          |          }||_        |||fS t          |t                    r|||fS t          d          t          | t                    rCt          | dd          }|st          d          t          j
        |          d         pd}|| |fS dS )a  
    Normalize various file input formats to a standard tuple format.

    Args:
        file: File to normalize. Can be:
            - a file object (must have .name and .read())
            - a tuple (filename, bytes, content_type)
            - a tuple (filename, fileobj, content_type)

    Returns:
        A normalized tuple of (filename, fileobj, content_type)

    Raises:
        ValueError: If the file input format is not supported
       z1File content must be bytes or a file-like object.nameNz(File object must have a .name attribute.r   zapplication/octet-stream)
isinstancetuplelenbytesr   r	   r   
ValueErrorgetattr	mimetypes
guess_type)r   filenamefile_contentcontent_typefileobjs        R/DATA/AppData/hermes/venv/lib/python3.11/site-packages/honcho/utils/file_upload.pynormalize_file_inputr      s   & $ .3t99>>/3,,lE** 	Rl++G#GLg|44f-- 	RlL99PQQQ 
D&	!	! .4.. 	IGHHH +H55a8V<V$--. .    c                     t          |           }|d                             d           |d                                         }|d         ||d         fS )a  
    Prepare a file for upload by normalizing and reading its content.

    Args:
        file: File to prepare. Can be:
            - a file object (must have .name and .read())
            - a tuple (filename, bytes, content_type)
            - a tuple (filename, fileobj, content_type)

    Returns:
        A tuple of (filename, content_bytes, content_type) ready for API upload

    Raises:
        ValueError: If the file input format is not supported
       r      )r   seekread)r   normalized_filecontent_bytess      r   prepare_file_for_uploadr    3   sY    $ +400O AA#A&++--MAq/ABBr   )
__doc__r   ior   r   r   strr   r   r     r   r   <module>r%      s                $.
UC
 5fc)9#:
:V
C$.
3$. $. $. $.NC
UC
 5fc)9#:
:V
CC
3s?C C C C C Cr   