L i-dZddlmZddlZddlZddlZddlmZmZddl m Z ddl m Z erddl mZGdd Zd d Zy) z6Class to store a key-value pair for the config system.) annotationsN) TYPE_CHECKINGAny) to_snake_caserepr_)Callablec eZdZdZdZdZddddddddeddf ddZddZdd Z e dd Z ddd Z dd Z e dd Zy) 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 z NvisibleFc ||_d} tj| |j}|td|jd|j d|j dc|_|_||_||_||_ ||_ ||_ | |_ d|_ d|_tj |_| |_| |_| |_|jrd|_ |d|jd }|jr;|s td |s td ||_t-j.||_|j3|y) aCreate 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
\_?[a-z][a-zA-Z0-9]*(\.[a-z][a-zA-Z0-9]*)*)\.(?P[a-z][a-zA-Z0-9]*)$NzKey "z" has invalid format.sectionnameTz Replaced by .z1expiration_date is required for deprecated items.z2deprecation_text is required for deprecated items.)keyrematch ValueErrorgrouprr description visibility scriptable default_val deprecated replaced_by is_default _get_val_funcr DEFAULT_DEFINITION where_definedtype sensitivemultipleexpiration_datetextwrapdedentdeprecation_text set_value)selfrrrrrrr&r#rtype_r!r" key_formatrs ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/config_option.py__init__zConfigOption.__init__esBh  *TXX. =uTXXJ.CDE E"'++i"8%++f:M di&$$&$&7;)<< "    "DO'%1$2B2B1C1#E ??" !TUU# !UVV#2D $,OO4D$ED ! {#ct|SNrr(s r+__repr__zConfigOption.__repr__s T{r-cd|j td|j|_||_|S)aAssign 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__ RuntimeErrorrr)r( get_val_funcs r+__call__zConfigOption.__call__s="    'S (//) r-c<|jy|jS)z$Get the value of this config option.N)rr0s r+valuezConfigOption.values"    %!!##r-c fd|_|tj|_n||_|jk(|_|j r|jtjk7r|jr]ddlm }|tjtjd|jd|jd|jdyddlm }|tj!tjd |jd |jd |j"d |jd yyy) 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. cSr/)r8sr+z(ConfigOption.set_value..sUr-Nr) get_loggeru ════════════════════════════════════════════════ z. IS NO LONGER SUPPORTED. z$ Please update u. ════════════════════════════════════════════════ us ════════════════════════════════════════════════ z$ IS DEPRECATED. z> This option will be removed on or after z%. Please update )rr rrrrr is_expiredstreamlit.loggerr=__name__errorr$r%rr&warningr#)r(r8rr=s ` r+r'zConfigOption.set_values3+  !-!@!@D !.D 4#3#33 ??t11\5T5TT 78$**OOXXJ**+,##'#5#5"67   88$,,OOXXJ**+,==A=Q=QzConfigOption.is_expired-s;-d.B.BC##%_$$r-cr|jjdd}dt|jS)zLGet the name of the environment variable that can be used to set the option.r_ STREAMLIT_)rreplacerupper)r(rs r+env_varzConfigOption.env_var6s6xxS)M$/557899r-)rstrr str | Nonerz Any | NonerrMrboolrrOr&rNr#rNrrNr)r r!rOr"rOreturnNone)rPrM)r5zCallable[[], Any]rPr )rPrr/)r8rrrNrPrQ)rPrO)r@ __module__ __qualname__r3rSTREAMLIT_DEFINITIONrMr,r1r6propertyr8r'r>rLr;r-r+r r s ;~%) #'"&#  '+&*"&j$ j$ j$ j$  j$  j$j$%j$$j$ j$j$j$j$ j$X2$$ 7r%::r-r cjd|jddD\}}}tj|||S)Nc32K|]}t|ywr/)int).0tokens r+ z&_parse_yyyymmdd_str..>sGuE Gs-)splitrE)date_stryearmonthdays r+rDrD=s3GsA0FGD%   T5# ..r-)r_rMrPzdatetime.datetime)r3 __future__rrErr$typingrrstreamlit.string_utilrstreamlit.utilrcollections.abcr r rDr;r-r+rhs7=" %/ ([:[:|/r-