Ë
    úmxi_  ã                  óT  — U d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
mZmZ d dlmZmZ d dlmZ e
rd dlmZ dZd	ed
<   dZd	ed<   	 d	 	 	 	 	 dd„Zej0                  ddd„«       Zej0                  ddd„«       Zdd„Zdd„Zd d„Zd d„Zd!d„Zd"d„Z d#d„Z!d$d„Z"d%d„Z#d&d„Z$y)'é    )ÚannotationsN)ÚPath)ÚIOÚTYPE_CHECKINGÚAnyÚFinal)Úenv_utilÚerrors)Úis_binary_string)Ú	Generatorz
.streamlitr   ÚCONFIG_FOLDER_NAMEÚstaticÚAPP_STATIC_FOLDER_NAMEc                ó¦   — |dk(  rt        | «      rdnd}n|}|r$t        j                  | j                  |«      «      S t        j                  | «      S )a<  Coerce bytes to a BytesIO or a StringIO.

    Parameters
    ----------
    data : bytes
    encoding : str

    Returns
    -------
    BytesIO or StringIO
        If the file's data is in a well-known textual format (or if the encoding
        parameter is set), return a StringIO. Otherwise, return BytesIO.

    ÚautoNzutf-8)r   ÚioÚStringIOÚdecodeÚBytesIO)ÚdataÚencodingÚdata_encodings      úJ/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/file_util.pyÚget_encoded_file_datar   %   sK   € ð" �6Òô !1°Ô 6™¸G‰à ˆáÜ�{‰{˜4Ÿ;™; }Ó5Ó6Ð6ä�:‰:�dÓÐó    c              #  ó8  K  — t        | «      }t        j                  |«      j                  dk(  rt	        j
                  d|› d�«      ‚d}|r|dz  }t        t        j                  j                  t        | «      |«      5 }|–— ddd«       y# 1 sw Y   yxY w­w)a$  Opens a context to read this file relative to the streamlit path.

    For example:

    with streamlit_read('foo.txt') as foo:
        ...

    opens the file `.streamlit/foo.txt`

    path   - the path to write to (within the streamlit directory)
    binary - set to True for binary IO
    r   zRead zero byte file: "ú"ÚrÚbN)
Úget_streamlit_file_pathÚosÚstatÚst_sizer
   ÚErrorÚopenÚpathÚjoinr   )r&   ÚbinaryÚfilenameÚmodeÚhandles        r   Ústreamlit_readr,   D   sˆ   è ø€ ô ' tÓ,€HÜ	‡w�wˆxÓ× Ñ  AÒ%Ü�l‰lÐ3°H°:¸QÐ?Ó@Ð@à€DÙØ�‰ˆÜ	Œb�g‰g�l‰lÔ-¨tÓ4°dÓ	;ð ¸vØŠ÷÷ ñ üs   ‚A>BÂ BÂ	BÂBÂBc              #  ó  K  — d}|r|dz  }t        | «      } t        j                  t        j                  j	                  | «      d¬«       	 t        | |«      5 }|–— ddd«       y# 1 sw Y   yxY w# t        $ rŠ}dt        j                  j                  | «      › �g}|j                  t        j                  k(  r!t        j                  r|j                  d«       t        j                  dj                  |«      «      ‚d}~ww xY w­w)	a�  Opens a file for writing within the streamlit path, and
    ensuring that the path exists.

    For example:

        with streamlit_write('foo/bar.txt') as bar:
            ...

    opens the file .streamlit/foo/bar.txt for writing,
    creating any necessary directories along the way.

    path   - the path to write to (within the streamlit directory)
    binary - set to True for binary IO
    Úwr   T)Úexist_okNzUnable to write file: zSPython is limited to files below 2GB on OSX. See https://bugs.python.org/issue24658ú
)r    r!   Úmakedirsr&   Údirnamer%   ÚOSErrorÚabspathÚerrnoÚEINVALr	   Ú	IS_DARWINÚappendr
   r$   r'   )r&   r(   r*   r+   ÚeÚmsgs         r   Ústreamlit_writer;   ]   sÖ   è ø€ ð  €DÙØ�‰ˆÜ" 4Ó(€DÜ‡K�K”—‘—‘ Ó%°Õ5ð
+Ü�$˜Óð 	 ØŠL÷	÷ 	ñ 	ûäò +Ø'¬¯©¯©¸Ó(=Ð'>Ð?Ð@ˆØ�7‰7”e—l‘lÒ"¤x×'9Ò'9Ø�J‰Jð9ôô �l‰l˜4Ÿ9™9 S›>Ó*Ð*ûð+üsO   ‚A	DÁA2 ÁA&ÁA2 Á%DÁ&A/Á+A2 Á.DÁ/A2 Á2	DÁ;BD Ä DÄDc                 óü   — t         j                  j                  t         j                  j                  t        «      «      } t         j                  j                  t         j                  j                  | d«      «      S )z3Get the folder where static HTML/JS/CSS files live.r   )r!   r&   r2   ÚnormpathÚ__file__r'   )r2   s    r   Úget_static_dirr?      sG   € ä�g‰g�o‰oœbŸg™g×.Ñ.¬xÓ8Ó9€GÜ�7‰7×ÑœBŸG™GŸL™L¨°(Ó;Ó<Ð<r   c                óx   — t        | «      j                  t        z  }t        j                  j                  |«      S )z+Get the folder where app static files live.)r   Úparentr   r!   r&   r4   )Úmain_script_pathÚ
static_dirs     r   Úget_app_static_dirrD   …   s,   € äÐ&Ó'×.Ñ.Ô1GÑG€JÜ�7‰7�?‰?˜:Ó&Ð&r   c                 óz   — t        j                  «       }|€t        d«      ‚t        |t        z  t        | Ž z  «      S )zyReturn the full path to a file in ~/.streamlit.

    This doesn't guarantee that the file (or its directory) exists.
    zNo home directory.)r   ÚhomeÚRuntimeErrorÚstrr   )ÚfilepathrF   s     r   r    r    ‹   s:   € ô
 �9‰9‹;€DØ€|ÜÐ/Ó0Ð0äˆtÔ(Ñ(¬4°¨?Ñ:Ó;Ð;r   c                 ó\   — t        t        j                  «       t        z  t        | Ž z  «      S )z‚Return the full path to a filepath in ${CWD}/.streamlit.

    This doesn't guarantee that the file (or its directory) exists.
    )rH   r   Úcwdr   )rI   s    r   Úget_project_streamlit_file_pathrL   —   s$   € ô
 Œt�x‰x‹zÔ.Ñ.´°x°Ñ@ÓAÐAr   c           	     ó²   — t        t        t        j                  j	                  t        j                  j                  | «      «      «      t        z  |z  «      S )z©Return the full path to a file in the .streamlit folder relative to the
    main script's path.

    This doesn't guarantee that the file (or its directory) exists.
    )rH   r   r!   r&   r4   r2   r   )rB   r)   s     r   Ú#get_main_script_streamlit_file_pathrN   Ÿ   sD   € ô ÜŒR�W‰W�_‰_œRŸW™WŸ_™_Ð-=Ó>Ó?Ó@Ü
ñ	à
ñ	óð r   c                óÌ   — |j                  d«      s|j                  d«      r|dz  }n|dz  }ddl}t        j                  j	                  | «      dz   }|j                  ||«      S )zØTest whether a file is in some folder with globbing support.

    Parameters
    ----------
    filepath : str
        A file path.
    folderpath_glob: str
        A path to a folder that may include globbing.

    Ú*ú/z/*r   N)ÚendswithÚfnmatchr!   r&   r2   )rI   Úfolderpath_globrS   Úfile_dirs       r   Úfile_is_in_folder_globrV   ­   s_   € ð ×#Ñ# CÔ(Ø×#Ñ# CÔ(Ø˜sÑ"‰Oà˜tÑ#ˆOãä�w‰w�‰˜xÓ(¨3Ñ.€HØ�?‰?˜8 _Ó5Ð5r   c                óØ   — d}t        j                  | «      D ]O  \  }}}|D ]D  }t         j                  j                  ||«      }|t         j                  j	                  |«      z  }ŒF ŒQ |S )z(Return the size of a directory in bytes.r   )r!   Úwalkr&   r'   Úgetsize)Ú	directoryÚ
total_sizeÚdirpathÚ_Ú	filenamesÚfÚfps          r   Úget_directory_sizera   Æ   sh   € à€JÜ!#§¡¨Ó!3ò .Ñˆ��IØò 	.ˆAÜ—‘—‘˜g qÓ)ˆBØœ"Ÿ'™'Ÿ/™/¨"Ó-Ñ-‰Jñ	.ð.ð Ðr   c                ó&  ‡ — t         j                  j                  dd«      }t        |«      dk(  ry|j	                  t         j
                  «      D �cg c]!  }t         j                  j                  |«      ‘Œ# }}t        ˆ fd„|D «       «      S c c}w )aE  Test whether a filepath is in the same folder of a path specified in the PYTHONPATH env variable.


    Parameters
    ----------
    filepath : str
        An absolute file path.

    Returns
    -------
    boolean
        True if contained in PYTHONPATH, False otherwise. False if PYTHONPATH is not defined or empty.

    Ú
PYTHONPATHÚ r   Fc              3  óp   •K  — | ]-  }t        t        j                  j                  ‰«      |«      –— Œ/ y ­w)N)rV   r!   r&   r=   )Ú.0r&   rI   s     €r   ú	<genexpr>z%file_in_pythonpath.<locals>.<genexpr>ä   s/   øè ø€ ò àô 	œrŸw™w×/Ñ/°Ó9¸4×@ñùs   ƒ36)	r!   ÚenvironÚgetÚlenÚsplitÚpathsepr&   r4   Úany)rI   Ú
pythonpathr&   Úabsolute_pathss   `   r   Úfile_in_pythonpathrp   Ð   sw   ø€ ô —‘—‘ ¨bÓ1€JÜ
ˆ:ƒ˜!ÒØà8B×8HÑ8HÌÏÉÓ8TÖU°”b—g‘g—o‘o dÕ+ÐU€NÐUÜó à"ôó ð ùò Vs   Á&Bc                 ót   — t         j                  j                  t        j                  j                  | Ž «      S )zØReturn the normalized path of the joined path.

    Parameters
    ----------
    *args : str
        The path components to join.

    Returns
    -------
    str
        The normalized path of the joined path.
    )r!   r&   r=   r'   )Úargss    r   Únormalize_path_joinrs   ê   s&   € ô �7‰7×ÑœBŸG™GŸL™L¨$Ð/Ó0Ð0r   c                ó|   — t        t        j                  «       | «      }t        j                  j	                  |«      S )a  Return the full path to the main script directory.

    Parameters
    ----------
    main_script : str
        The main script path. The path can be an absolute path or a relative
        path.

    Returns
    -------
    str
        The full path to the main script directory.
    )rs   r!   Úgetcwdr&   r2   )Úmain_scriptrB   s     r   Úget_main_script_directoryrw   ú   s+   € ô +¬2¯9©9«;¸ÓDÐä�7‰7�?‰?Ð+Ó,Ð,r   )r   )r   Úbytesr   rH   Úreturnzio.StringIO | io.BytesIO)F)r&   rH   r(   Úboolry   zGenerator[IO[Any], None, None])ry   rH   )rB   rH   ry   rH   )rI   rH   ry   rH   )rB   rH   r)   rH   ry   rH   )rI   rH   rT   rH   ry   rz   )rZ   rH   ry   Úint)rI   rH   ry   rz   )rr   rH   ry   rH   )rv   rH   ry   rH   )%Ú
__future__r   Ú
contextlibr5   r   r!   Úpathlibr   Útypingr   r   r   r   Ú	streamlitr	   r
   Ústreamlit.string_utilr   Úcollections.abcr   r   Ú__annotations__r   r   Úcontextmanagerr,   r;   r?   rD   r    rL   rN   rV   ra   rp   rs   rw   © r   r   ú<module>r†      sÏ   ðö #ã Û Û 	Û 	Ý ß 0Ó 0ç &Ý 2áÝ)ð )Ð �EÓ (ð !)Ð ˜Ó (ð "(ðØ
ðØðàóð> ×Ñóó ðð0 ×Ñó+ó ð+óB=ó'ó	<óBóó6ó2óó41ô -r   