
    ch-                    r    S r SSKJr  SSKrSSKrSSKrSSKJrJr  SSK	J
r
  SSKJr   " S S5      rS
S	 jrg)z6Class to store a key-value pair for the config system.    )annotationsN)AnyCallable)to_snake_caserepr_c                      \ rS rSrSrSrSrSSSSSSSS\SS4                         SS jjrSS	 jr	SS
 jr
\SS j5       rSSS jjrSS jr\SS j5       rSrg)ConfigOption   an  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                   Xl         Sn[        R                  " XR                   5      nUc  [        SU R                    S35      eUR	                  S5      UR	                  S5      sU l        U l        X l        X@l        XPl	        X0l
        X`l        Xl        SU l        SU l        [        R                   U l        Xl        Xl        Xl        U R                  (       a  SU l        Uc  SU R                   S	3nU R                  (       aE  U(       d  [        S
5      eU(       d  [        S5      eXl        [,        R.                  " U5      U l        U R3                  U5        g)av  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                  jC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\streamlit/config_option.py__init__ConfigOption.__init__b   s*   h  	* XX.=uTXXJ.CDEE"'++i"8%++f:Mdi&$$&$&7;)<<	" "DO'%1$2B2B1C1#E ??" !TUU# !UVV#2 $,OO4D$ED!{#    c                    [        U 5      $ Nr   r(   s    r+   __repr__ConfigOption.__repr__   s    T{r.   c                d    UR                   c  [        S5      eUR                   U l        Xl        U $ )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__ConfigOption.__call__   s;    " 'S  (//)r.   c                >    U R                   c  gU R                  5       $ )z$Get the value of this config option.N)r   r1   s    r+   valueConfigOption.value   s"     %!!##r.   c                  ^ U4S jU l         Uc  [        R                  U l        OX l        TU R                  :H  U l        U R                  (       a  U R                  [        R                  :w  a  U R                  5       (       a^  SSKJ	n  U" [        5      R                  [        R                  " SU R                   SU R                   SU R                   S35      5        gSSKJ	n  U" [        5      R!                  [        R                  " S	U R                   S
U R                   SU R"                   SU R                   S3	5      5        ggg)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                    > T $ r0    )r;   s   r+   <lambda>(ConfigOption.set_value.<locals>.<lambda>   s    Ur.   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.loggerrB   __name__errorr$   r%   r   r&   warningr#   )r(   r;   r   rB   s    `  r+   r'   ConfigOption.set_value   s4    + !-!@!@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                    U R                   (       d  g[        U R                  5      n[        R                  R	                  5       nX!:  $ )z/Returns true if expiration_date is in the past.F)r   _parse_yyyymmdd_strr#   datetimenow)r(   r#   rL   s      r+   rC   ConfigOption.is_expired*  s9    -d.B.BC##%$$r.   c                r    U R                   R                  SS5      nS[        U5      R                  5        3$ )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_varConfigOption.env_var3  s6     xxS)M$/557899r.   )r   r   r   r&   r   r#   r   r   r"   r   r   r   r   r!   r    r   r   )r   strr   
str | Noner   z
Any | Noner   rU   r   boolr   rW   r&   rV   r#   rV   r   rV   r)   r    r!   rW   r"   rW   returnNone)rX   rU   )r7   zCallable[[], Any]rX   r
   )rX   r   r0   )r;   r   r   rV   rX   rY   )rX   rW   )rE   
__module____qualname____firstlineno__r5   r   STREAMLIT_DEFINITIONrU   r,   r2   r8   propertyr;   r'   rC   rS   __static_attributes__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                h    S U R                  SS5       5       u  pn[        R                  " XU5      $ )Nc              3  8   #    U  H  n[        U5      v   M     g 7fr0   )int).0tokens     r+   	<genexpr>&_parse_yyyymmdd_str.<locals>.<genexpr>;  s     G0FuE

0Fs   -   )splitrK   )date_stryearmonthdays       r+   rJ   rJ   :  s/    GsA0FGDT#..r.   )rj   rU   rX   zdatetime.datetime)r5   
__future__r   rK   r   r$   typingr   r   streamlit.string_utilr   streamlit.utilr   r
   rJ   r?   r.   r+   <module>rr      s1    = "  	    /  [: [:|/r.   