Ë
    úmxià-  ã                  ó€   — d Z ddlmZ ddlZddlZddlZddlmZmZ ddl	m
Z
 ddlmZ erddlmZ  G d„ d	«      Zdd
„Zy)z6Class to store a key-value pair for the config system.é    )ÚannotationsN)ÚTYPE_CHECKINGÚAny)Úto_snake_case©Úrepr_)ÚCallablec                  ó°   — e Zd ZdZdZdZddddddddeddf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zdd	„Z	e
dd
„«       Zddd„Zdd„Ze
dd„«       Zy)ÚConfigOptiona:  Stores a Streamlit configuration option.

    A configuration option, like 'browser.serverPort', which indicates which port
    to use when connecting to the proxy. There are two ways to create a
    ConfigOption:

    Simple ConfigOptions are created as follows:

        ConfigOption('browser.serverPort',
            description = 'Connect to the proxy at this port.',
            default_val = 8501)

    More complex config options resolve their values at runtime as follows:

        @ConfigOption('browser.serverPort')
        def _proxy_port():
            """Connect to the proxy at this port.

            Defaults to 8501.
            """
            return 8501

    NOTE: For complex config options, the function is called each time the
    option.value is evaluated!

    Attributes
    ----------
    key : str
        The fully qualified section.name
    value : any
        The value for this option. If this is a complex config option then
        the callback is called EACH TIME value is evaluated.
    section : str
        The section of this option. Example: 'global'.
    name : str
        See __init__.
    description : str
        See __init__.
    where_defined : str
        Indicates which file set this config option.
        ConfigOption.DEFAULT_DEFINITION means this file.
    is_default: bool
        True if the config value is equal to its default value.
    visibility : {"visible", "hidden"}
        See __init__.
    scriptable : bool
        See __init__.
    deprecated: bool
        See __init__.
    deprecation_text : str or None
        See __init__.
    expiration_date : str or None
        See __init__.
    replaced_by : str or None
        See __init__.
    sensitive : bool
        See __init__.
    env_var: str
        The name of the environment variable that can be used to set the option.
    z	<default>z<streamlit>NÚvisibleFc                ó¤  — || _         d}t        j                  || j                   «      }|€t        d| j                   › d�«      ‚|j	                  d«      |j	                  d«      c| _        | _        || _        || _        || _	        || _
        || _        |	| _        d| _        d| _        t        j                   | _        |
| _        || _        || _        | j                  rd| _        |€d| j                  › d	�}| j                  r;|st        d
«      ‚|st        d«      ‚|| _        t-        j.                  |«      | _        | j3                  |«       y)a†  Create a ConfigOption with the given name.

        Parameters
        ----------
        key : str
            Should be of the form "section.optionName"
            Examples: server.name, deprecation.v1_0_featureName
        description : str
            Like a comment for the config option.
        default_val : any
            The value for this config option.
        visibility : {"visible", "hidden"}
            Whether this option should be shown to users.
        scriptable : bool
            Whether this config option can be set within a user script.
        deprecated: bool
            Whether this config option is deprecated.
        deprecation_text : str or None
            Required if deprecated == True. Set this to a string explaining
            what to use instead.
        expiration_date : str or None
            Required if deprecated == True. set this to the date at which it
            will no longer be accepted. Format: 'YYYY-MM-DD'.
        replaced_by : str or None
            If this is option has been deprecated in favor or another option,
            set this to the path to the new option. Example:
            'server.runOnSave'. If this is set, the 'deprecated' option
            will automatically be set to True, and deprecation_text will have a
            meaningful default (unless you override it).
        type_ : one of str, int, float or bool
            Useful to cast the config params sent by cmd option parameter.
        sensitive: bool
            Sensitive configuration options cannot be set by CLI parameter.
        multiple: bool
            Whether this config option can have multiple values.
        zU(?P<section>\_?[a-z][a-zA-Z0-9]*(\.[a-z][a-zA-Z0-9]*)*)\.(?P<name>[a-z][a-zA-Z0-9]*)$NzKey "z" has invalid format.ÚsectionÚnameTzReplaced by ú.z1expiration_date is required for deprecated items.z2deprecation_text is required for deprecated items.)ÚkeyÚreÚmatchÚ
ValueErrorÚgroupr   r   ÚdescriptionÚ
visibilityÚ
scriptableÚdefault_valÚ
deprecatedÚreplaced_byÚ
is_defaultÚ_get_val_funcr   ÚDEFAULT_DEFINITIONÚwhere_definedÚtypeÚ	sensitiveÚmultipleÚexpiration_dateÚtextwrapÚdedentÚdeprecation_textÚ	set_value)Úselfr   r   r   r   r   r   r&   r#   r   Útype_r!   r"   Ú
key_formatr   s                  úN/home/htdocs/ttos/venv/lib/python3.12/site-packages/streamlit/config_option.pyÚ__init__zConfigOption.__init__e   sB  € ðh ˆŒðð 	ô* —‘˜ T§X¡XÓ.ˆØˆ=Ü˜u T§X¡X JÐ.CÐDÓEÐEØ"'§+¡+¨iÓ"8¸%¿+¹+ÀfÓ:MÐˆŒ�d”ià&ˆÔà$ˆŒØ$ˆŒØ&ˆÔØ$ˆŒØ&ˆÔØˆŒØ7;ˆÔÜ)×<Ñ<ˆÔØˆŒ	Ø"ˆŒØ ˆŒà×ÒØ"ˆDŒOØÐ'Ø%1°$×2BÑ2BÐ1CÀ1Ð#EÐ à�?Š?Ù"Ü Ð!TÓUÐUÙ#Ü Ð!UÓVÐVØ#2ˆDÔ Ü$,§O¡OÐ4DÓ$EˆDÔ!à�‰�{Õ#ó    c                ó   — t        | «      S ©Nr   ©r(   s    r+   Ú__repr__zConfigOption.__repr__Ñ   s   € Ü�T‹{Ðr-   c                ód   — |j                   €t        d«      ‚|j                   | _        || _        | S )aÛ  Assign a function to compute the value for this option.

        This method is called when ConfigOption is used as a decorator.

        Parameters
        ----------
        get_val_func : function
            A function which will be called to get the value of this parameter.
            We will use its docString as the description.

        Returns
        -------
        ConfigOption
            Returns self, which makes testing easier. See config_test.py.

        zAComplex config options require doc strings for their description.)Ú__doc__ÚRuntimeErrorr   r   )r(   Úget_val_funcs     r+   Ú__call__zConfigOption.__call__Ô   s=   € ð" ×ÑÐ'ÜØSóð ð (×/Ñ/ˆÔØ)ˆÔØˆr-   c                ó<   — | j                   €y| j                  «       S )z$Get the value of this config option.N)r   r0   s    r+   ÚvaluezConfigOption.valueí   s"   € ð ×ÑÐ%ØØ×!Ñ!Ó#Ð#r-   c                ó‚  ‡— ˆfd„| _         |€t        j                  | _        n|| _        ‰| j                  k(  | _        | j                  rõ| j                  t        j                  k7  r×| j                  «       r]ddlm	}  |t        «      j                  t        j                  d| j                  › d| j                  › d| j                  › d�«      «       yddlm	}  |t        «      j!                  t        j                  d	| j                  › d
| j                  › d| j"                  › d| j                  › d�	«      «       yyy)zæSet the value of this option.

        Parameters
        ----------
        value
            The new value for this parameter.
        where_defined : str
            New value to remember where this parameter was set.

        c                 ó   •— ‰ S r/   © )r8   s   €r+   ú<lambda>z(ConfigOption.set_value.<locals>.<lambda>ÿ   s   ø€  U€ r-   Nr   )Ú
get_loggeruº   
                    â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�
                    z. IS NO LONGER SUPPORTED.

                    z$

                    Please update u»   .
                    â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�
                    u»   s
                    â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�
                    z$ IS DEPRECATED.
                    z>

                    This option will be removed on or after z%.

                    Please update )r   r   r   r   r   r   r   Ú
is_expiredÚstreamlit.loggerr=   Ú__name__Úerrorr$   r%   r   r&   Úwarningr#   )r(   r8   r   r=   s    `  r+   r'   zConfigOption.set_valueô   s3  ø€ ó +ˆÔàÐ Ü!-×!@Ñ!@ˆDÕà!.ˆDÔà 4×#3Ñ#3Ñ3ˆŒà�?Š?˜t×1Ñ1´\×5TÑ5TÒTØ�‰Ô å7áœ8Ó$×*Ñ*Ü—O‘Oðà—X‘X�Jð à×*Ñ*Ð+ð ,#à#'×#5Ñ#5Ð"6ð 7ðó
õõ 8áœ8Ó$×,Ñ,Ü—O‘Oðà—X‘X�Jð Ø×*Ñ*Ð+ð ,=à=A×=QÑ=QÐ<Rð S#à#'×#5Ñ#5Ð"6ð 7ð	óõð-  Uˆ?r-   c                óŒ   — | j                   syt        | j                  «      }t        j                  j	                  «       }||kD  S )z/Returns true if expiration_date is in the past.F)r   Ú_parse_yyyymmdd_strr#   ÚdatetimeÚnow)r(   r#   rF   s      r+   r>   zConfigOption.is_expired-  s;   € à�ŠØä-¨d×.BÑ.BÓCˆÜ×Ñ×#Ñ#Ó%ˆØ�_Ñ$Ð$r-   c                ór   — | j                   j                  dd«      }dt        |«      j                  «       › �S )zLGet the name of the environment variable that can be used to set the option.r   Ú_Ú
STREAMLIT_)r   Úreplacer   Úupper)r(   r   s     r+   Úenv_varzConfigOption.env_var6  s6   € ð �x‰x×Ñ  SÓ)ˆØœM¨$Ó/×5Ñ5Ó7Ð8Ð9Ð9r-   )r   Ústrr   ú
str | Noner   z
Any | Noner   rM   r   Úboolr   rO   r&   rN   r#   rN   r   rN   r)   r    r!   rO   r"   rO   ÚreturnÚNone)rP   rM   )r5   zCallable[[], Any]rP   r   )rP   r   r/   )r8   r   r   rN   rP   rQ   )rP   rO   )r@   Ú
__module__Ú__qualname__r3   r   ÚSTREAMLIT_DEFINITIONrM   r,   r1   r6   Úpropertyr8   r'   r>   rL   r;   r-   r+   r   r      s  „ ñ;ð~ %Ðð )Ðð
 #'Ø"&Ø#Ø Ø Ø'+Ø&*Ø"&ØØØðj$àðj$ð  ðj$ð  ð	j$ð
 ðj$ð ðj$ð ðj$ð %ðj$ð $ðj$ð  ðj$ð ðj$ð ðj$ð ðj$ð 
ój$óXóð2 ò$ó ð$ô7ór%ð ò:ó ñ:r-   r   c                ój   — d„ | j                  dd«      D «       \  }}}t        j                  |||«      S )Nc              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr/   )Úint)Ú.0Útokens     r+   ú	<genexpr>z&_parse_yyyymmdd_str.<locals>.<genexpr>>  s   è ø€ ÒG uœ˜EŸ
ÑGùs   ‚ú-é   )ÚsplitrE   )Údate_strÚyearÚmonthÚdays       r+   rD   rD   =  s3   € ÙG°·±¸sÀAÓ0FÔGÑ€Dˆ%�Ü×Ñ˜T 5¨#Ó.Ð.r-   )r_   rM   rP   zdatetime.datetime)r3   Ú
__future__r   rE   r   r$   Útypingr   r   Ústreamlit.string_utilr   Ústreamlit.utilr   Úcollections.abcr	   r   rD   r;   r-   r+   ú<module>rh      s7   ðñ =å "ã Û 	Û ß %å /Ý  áÝ(÷[:ñ [:ô|/r-   