
    Yi?                        S r SSKJr  SSKJrJrJrJrJrJ	r	J
r
Jr  SSKJrJr  \(       a  SSKJrJr  \" S\	\S\\S4   S	9r\S
\\   S\\\   \4   4S j5       r\S
\S\S\4   4S j5       rS
\\   S\\\   \	\S\\S4   4   4S jrS
\S\\   4S jrS
\\   S\4S jr    SS\	\S4   S\\S      S\\   S\S\S\	\S\4   4S jjrg)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TypeVarUnioncastoverload)	FileInputFilePathInput)	InputFileTelegramObject_Tr   N)boundobjreturnc                     g N r   s    @/app/.venv/lib/python3.13/site-packages/telegram/_utils/files.py	load_filer   *   s    >A    c                     g r   r   r   s    r   r   r   .   s    +.r   c           	          U c  g U R                  5       n[        U 5      nX!4$ ! [         a(    S[        [        [        S[
        [        4   U 5      4s $ f = f)zlIf the input is a file handle, read the data and name and return it. Otherwise, return
the input unchanged.
N)NNr   )readAttributeErrorr
   r	   bytesstrr   guess_file_name)r   contentsfilenames      r   r   r   2   se     {E88: s#H  ET%{C =>DDDEs   $ /AAc                     [        U S5      (       a>  [        U R                  [        5      (       d  [	        U R                  5      R                  $ g)z_If the input is a file handle, read name and return it. Otherwise, return
the input unchanged.
nameN)hasattr
isinstancer%   intr   r   s    r   r!   r!   E   s8     sFJsxx$=$=CHH~"""r   c                 b    U c  g[        U 5      n UR                  5       $ ! [         a     gf = f)zg
Checks if a given string is a file on local system.

Args:
    obj (:obj:`str`): The string to check.
F)r   is_file	Exception)r   paths     r   is_local_filer-   O   s8     {9D||~ s   ! 
..
file_inputr   tg_typer#   attach
local_modec                 <   SSK Jn  [        U [        5      (       a*  U R	                  S5      (       a  U(       d  [        S5      eU $ [        U [        [        45      (       aV  [        U 5      (       aD  [        U 5      nU(       a  UR                  5       R                  5       $ U" UR                  SS9X#S9$ U $ [        U [        5      (       a  U" XUS9$ [        U S5      (       a  U" [        [        U 5      X#S9$ U(       a  [        X5      (       a  U R                  $ U $ )	aq  
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` | :class:`~telegram.InputFile`            | 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<   `   s    R #*c""z'<'<Y'G'Gabb*sDk**$$
#D}}--//TYYDY1HTT*e$$vFFz6""b*-PP:j22!!!r   )NNFF)__doc__pathlibr   typingr   r   r   r   r   r	   r
   r   telegram._utils.typesr   r   r5   r   r   r   r    r   tupler   r!   boolr-   typer<   r   r   r   <module>rD      sc  &
  S S S :2Tuk3dBCD 
 A2e9 Ax}e';!< A 
 A 
 .2 .%b/ . 
 .	)	
8C=%{Ct CDDE& x} x. 4 & 15"=i!112=d+,-= sm= 	=
 = 3S !=r   