
    ch                    ~   % S SK Jr  S SKrS SKrS SKrS SKrS SKJr  S SKJ	r	J
r
JrJr  S SKJrJr  S SKJr  \
(       a  S SKJr  SrS	\S
'   SrS	\S'    S     SS jjr\R0                  SSS jj5       r\R0                  SSS jj5       rSS jrSS jrS S jrS S jrS!S jrS"S jr S#S jr!S$S jr"S%S jr#S&S jr$g)'    )annotationsN)Path)IOTYPE_CHECKINGAnyFinal)env_utilerrors)is_binary_string)	Generatorz
.streamlitr   CONFIG_FOLDER_NAMEstaticAPP_STATIC_FOLDER_NAMEc                    US:X  a  [        U 5      (       a  SOSnOUnU(       a%  [        R                  " U R                  U5      5      $ [        R                  " U 5      $ )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      fC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\streamlit/file_util.pyget_encoded_file_datar   %   sN    " 6 !1 6 6G {{4;;}566::d    c              #  R  #    [        U 5      n[        R                  " U5      R                  S:X  a  [        R
                  " SU S35      eSnU(       a  US-  n[        [        R                  R                  [        U 5      U5       nUv   SSS5        g! , (       d  f       g= f7f)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	wwx  A%ll3H:Q?@@D	bggll-t4d	;v 
<	;	;s   BB'B	B'
B$ B'c              #  2  #    SnU(       a  US-  n[        U 5      n [        R                  " [        R                  R	                  U 5      SS9   [        X5       nUv   SSS5        g! , (       d  f       g= f! [         a  nS[        R                  R                  U 5       3/nUR                  [        R                  :X  a&  [        R                  (       a  UR                  S5        [        R                  " SR                  U5      5      eSnAff = f7f)	ak  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KK%5
+$L  +'(='>?@77ell"x'9'9JJ9 ll499S>**+sO   ADA9 A(A9 'D(
A62A9 5D6A9 9
DBDDDc                     [         R                  R                  [         R                  R                  [        5      5      n [         R                  R                  [         R                  R                  U S5      5      $ )z3Get the folder where static HTML/JS/CSS files live.r   )r!   r&   r2   normpath__file__r'   )r2   s    r   get_static_dirr?      sG    ggoobgg..x89G77BGGLL(;<<r   c                x    [        U 5      R                  [        -  n[        R                  R                  U5      $ )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GJ77??:&&r   c                 ~    [         R                  " 5       nUc  [        S5      e[        U[        -  [        U 6 -  5      $ )zqReturn 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:    
 99;D|/00t((4?:;;r   c                 ^    [        [        R                  " 5       [        -  [        U 6 -  5      $ )zzReturn 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$    
 txxz..x@AAr   c           	         [        [        [        R                  R	                  [        R                  R                  U 5      5      5      [        -  U-  5      $ )zReturn 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     RWW__RWW__-=>?@
	
	 r   c                    UR                  S5      (       d!  UR                  S5      (       a  US-  nOUS-  nSSKn[        R                  R	                  U 5      S-   nUR                  X15      $ )zTest 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      sc     ##C((##C((s"Ot#Owwx(3.H??855r   c                    Sn[         R                  " U 5       HP  u  p#nU HD  n[         R                  R                  X%5      nU[         R                  R	                  U5      -  nMF     MR     U$ )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      sZ    J!#!3IAg)B"''//"--J  "4 r   c                0  ^  [         R                  R                  SS5      n[        U5      S:X  a  gUR	                  [         R
                  5       Vs/ s H"  n[         R                  R                  U5      PM$     nn[        U 4S jU 5       5      $ s  snf )a!  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  v   >#    U  H.  n[        [        R                  R                  T5      U5      v   M0     g 7f)N)rV   r!   r&   r=   ).0r&   rI   s     r   	<genexpr>%file_in_pythonpath.<locals>.<genexpr>   s1      "D 	rww//94@@"s   69)	r!   environgetlensplitpathsepr&   r4   any)rI   
pythonpathr&   absolute_pathss   `   r   file_in_pythonpathrq      sz     b1J
:!8B8H8H8TU8Tbggood+8TNU "   Vs   )Bc                 v    [         R                  R                  [         R                  R                  " U 6 5      $ )zReturn 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_joinrt      s&     77BGGLL$/00r   c                ~    [        [        R                  " 5       U 5      n[        R                  R	                  U5      $ )zReturn 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.
)rt   r!   getcwdr&   r2   )main_scriptrB   s     r   get_main_script_directoryrx      s+     +299;D77??+,,r   )r   )r   bytesr   rH   returnzio.StringIO | io.BytesIO)F)r&   rH   r(   boolrz   zGenerator[IO[Any], None, None])rz   rH   )rB   rH   rz   rH   )rI   rH   rz   rH   )rB   rH   r)   rH   rz   rH   )rI   rH   rT   rH   rz   r{   )rZ   rH   rz   int)rI   rH   rz   r{   )rs   rH   rz   rH   )rw   rH   rz   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   rq   rt   rx    r   r   <module>r      s    #   	 	  0 0 & 2) ) E ( !)  ( "(
>  0 + +B='	<B6241 -r   