
    is                        d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
mZmZmZ ddlmZmZ erddlmZmZ  e
deedeedf         	          Zed
ee         deee         ef         fd            Zed
ededef         fd            Zd
ee         deee         eedeedf         f         fdZd
ee         defdZ	 	 	 	 ddeedf         dee	d                  dee         dededeedef         fdZdS )a  This module contains helper functions related to handling of files.

.. versionchanged:: 20.0
   Previously, the contents of this module were available through the (no longer existing)
   module ``telegram._utils.helpers``.

Warning:
    Contents of this module are intended to be used internally by the library and *not* by the
    user. Changes to this module are not considered breaking changes and may not be documented in
    the changelog.
    )Path)
IOTYPE_CHECKINGAnyOptionalTupleTypeTypeVarUnioncastoverload)	FileInputFilePathInput)	InputFileTelegramObject_Tr   N)boundobjreturnc                     d S N r   s    [/var/www/html/crypto-bot/backend/venv/lib/python3.11/site-packages/telegram/_utils/files.py	load_filer   *   s    >Ac    c                     d S r   r   r   s    r   r   r   .   s    +.3r   c           	      J   | dS 	 |                                  }n@# t          $ r3 dt          t          t          dt
          t          f         |           fcY S w xY wt          | d          r4t          | j	        t                    st          | j	                  j	        }nd}||fS )ztIf the input is a file handle, read the data and name and return it. Otherwise, return
    the input unchanged.
    N)NNr   name)readAttributeErrorr   r   bytesstrr   hasattr
isinstancer   int)r   contentsfilenames      r   r   r   2   s     {zE88:: E E ET%{C =>DDDDDDE sF Jsx$=$= >>&Xs    :AAc                 t    | dS t          |           }	 |                                S # t          $ r Y dS w xY w)zw
    Checks if a given string is a file on local system.

    Args:
        obj (:obj:`str`): The string to check.
    NF)r   is_file	Exception)r   paths     r   is_local_filer-   H   sN     {u99D||~~   uus   ) 
77F
file_inputr   tg_typer(   attach
local_modec                 r   ddl m} t          | t                    r(|                     d          r|st          d          | S t          | t          t          f          rjt          |           rYt          |           }|r&|                                	                                S  ||
                    d          ||          S | S t          | t                    r || ||          S t          | d          r! |t          t          |           ||          S |rt          | |          r| j        S | S )	a  
    Parses input for sending files:

    * For string input, if the input is an absolute path of a local file:

        * if ``local_mode`` is ``True``, adds the ``file://`` prefix. If the input is a relative
        path of a local file, computes the absolute path and adds the ``file://`` prefix.
        * if ``local_mode`` is ``False``, loads the file as binary data and builds an
          :class:`InputFile` from that

      Returns the input unchanged, otherwise.
    * :class:`pathlib.Path` objects are treated the same way as strings.
    * For IO and bytes input, returns an :class:`telegram.InputFile`.
    * If :attr:`tg_type` is specified and the input is of that type, returns the ``file_id``
      attribute.

    Args:
        file_input (:obj:`str` | :obj:`bytes` | :term:`file object` | Telegram media object): The
            input to parse.
        tg_type (:obj:`type`, optional): The Telegram media type the input can be. E.g.
            :class:`telegram.Animation`.
        filename (:obj:`str`, optional): The filename. Only relevant in case an
            :class:`telegram.InputFile` is returned.
        attach (:obj:`bool`, optional): Pass :obj:`True` if the parameter this file belongs to in
            the request to Telegram should point to the multipart data via an ``attach://`` URI.
            Defaults to `False`. Only relevant if an :class:`telegram.InputFile` is returned.
        local_mode (:obj:`bool`, optional): Pass :obj:`True` if the bot is running an api server
            in ``--local`` mode.

    Returns:
        :obj:`str` | :class:`telegram.InputFile` | :obj:`object`: The parsed input or the untouched
        :attr:`file_input`, in case it's no valid file input.
    r   )r   zfile://zBSpecified file input is a file URI, but local mode is not enabled.rb)mode)r(   r0   r    )telegramr   r%   r#   
startswith
ValueErrorr   r-   absoluteas_uriopenr"   r$   r   r   file_id)r.   r/   r(   r0   r1   r   r,   s          r   parse_file_inputr<   Y   sc   R #"""""*c"" z'<'<Y'G'G  	cabbb*sDk** $$ 	U
##D 0}}--///9TYYDY11HVTTTT*e$$ GyhvFFFFz6"" Qyb*--PPPP ":j'22 "!!r   )NNFF)__doc__pathlibr   typingr   r   r   r   r   r	   r
   r   r   r   telegram._utils.typesr   r   r5   r   r   r"   r#   r   r   boolr-   r<   r   r   r   <module>rB      s"  &
 
       ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` : : : : : : : : 322222222WTuk3dBCDDD 
 A2e9 Ax}e';!< A A A 
 A 
 .2 .%b/ . . . 
 .	)	
8C=%{Ct CDDE   ,x. 4    & 15"= =i!112=d+,-= sm= 	=
 = 3S != = = = = =r   