
    ȯei-                        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                  Y/var/www/html/glpi_dashboard/venv/lib/python3.12/site-packages/streamlit/config_option.py__init__zConfigOption.__init__e   sB   h  	* TXX.=uTXXJ.CDEE"'++i"8%++f:Mdi&$$&$&7;)<<	" "DO'%1$2B2B1C1#E ??" !TUU# !UVV#2D $,OO4D$ED!{#    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)zSet 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\5T5TT 78$**OOXXJ **+ ,##'#5#5"6 7
 88$,,OOXXJ **+ ,==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     xx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     GuE
Gs   -   )splitrE   )date_stryearmonthdays       r+   rD   rD   =  s3    GsA0FGD%T5#..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-   