U
    ARdV                     @   s.  U d Z ddlZddlZddlZddlZddlmZ ddlmZm	Z	m
Z
mZmZ ddlZddlmZ ddlmZmZmZmZmZ ddlmZ ddlmZ ed	d
Ze
eef ed< e Ze Ze
eef ed< da ee
eef  ed< dZ!dZ"dZ#e!feeeddddZ$eeddddZ%eedddZ&ee
eef dddZ'eeddddZ(ddd d!d ddded f
eee ee e)ee)ee ee ee e*e)ed"d#d$Z+eddd%d&Z,e(d'd( e+d)d*d e)d+ e+d,d-d.e)d+ e+d/d0e)d1e)d2d3d4Z-e+d5d6d.d7d8d9d: e+d;d<d0d e)d= e+d>d?d0d e)d= e+d@dAd0dBe.d= e+dCdDd0dEe/d= e+dFdGdHed+ e(dIdJ e+d9edKed2dLdMZ0e+dNedKed2dOdPZ1e+dQdRd d0e)d.dS e(dTdU e+dVdWd.e)d.dX e+dYdZd.e)d.dX e+d[d\d.e)d.dX e+d]d^d_ed.dX e(d`da e+dbdcd.e)d+ e+ddded e)d+ e+dfdgd.e)d+ e+dhdid.e)d+ e+djdkd.e)d+ e+dldmd e)d+ e(dndo e+dpdqg dr e+dsdtd_ed+ e+dued.dvej2ed2dwdxZ3e+dye)dKe)d2dzd{Z4e+d|d}d e)d+ e+d~dd0d.e)d= e+dee d2ddZ5e+ddde/d+ e+dd0dd e)d e+ddded+ e+ddd.e)d+ e+ddd.e)d+ e+ddde/d+ e+ddde/d+ e+ddd e)d+ e+ddd e)d+ e(dd e+ddded+ e+ddd.e)d+ e+de/dKe/d2ddZ6dgZ7e+dde7 dd e+dde7 dd e(dd e+ddd e)d0d e+ddd e)d0d e(dd e+dddd.d e(dd e+ddd.d.e)dd e+ddd.d.e)d.ddd e+ddd.d.e)dÍ e(ddŃ e+ddd e+ddd e+ddd e+ddd e+ddd e+ddd eedddӄZ8ee)dԜddքZ9ee)dԜdd؄Z:dd2ddڄZ;eeedddd܄Z<e
eef dݜdd߄Z=eeddddZ>eedddZ?eedddZ@eddZAeBdeCdgZDdee
eef  e
eef dddZEdd2ddZFdd2ddZGde	g df e	g e)f dddZHeHeFd.d eHeG dS )zLoads the configuration data.    N)OrderedDict)AnyCallableDictOptionalcast)Signal)config_utildevelopmentenv_util	file_utilutil)ConfigOption)StreamlitAPIExceptionz.Special test section just used for unit tests.)_test_section_descriptions_config_options_template_config_optionsz<user defined>z-command-line argument or environment variablezenvironment variable)keyvaluewhere_definedreturnc              	   C   s&   t  t  t| || W 5 Q R X dS )a  Set config option.

    Run `streamlit config show` in the terminal to see all available options.

    This is an internal API. The public `st.set_option` API is implemented
    in `set_user_option`.

    Parameters
    ----------
    key : str
        The config option key of the form "section.optionName". To see all
        available options, run `streamlit config show` on a terminal.

    value
        The new value to assign to this config option.

    where_defined : str
        Tells the config system where this was set.
    N)_config_lockget_config_options_set_option)r   r   r    r   4/tmp/pip-unpacked-wheel-b9et7o5g/streamlit/config.py
set_optionB   s    r   )r   r   r   c              
   C   sj   zt |  }W n4 tk
r@ } ztdj| d|W 5 d}~X Y nX |jrVt| | dS tdj| ddS )aU  Set config option.

    Currently, only the following config options can be set within the script itself:
        * client.caching
        * client.displayEnabled
        * deprecation.*

    Calling with any other options will raise StreamlitAPIException.

    Run `streamlit config show` in the terminal to see all available options.

    Parameters
    ----------
    key : str
        The config option key of the form "section.optionName". To see all
        available options, run `streamlit config show` on a terminal.

    value
        The new value to assign to this config option.

    z!Unrecognized config option: {key}r   Nz|{key} cannot be set on the fly. Set as command line option, e.g. streamlit run script.py --{key}, or in config.toml instead.)r   KeyErrorr   format
scriptabler   )r   r   optZker   r   r   set_user_option\   s     

r#   )r   r   c              
   C   s@   t 2 t }| |kr td|  ||  jW  5 Q R  S Q R X dS )aN  Return the current value of a given Streamlit config option.

    Run `streamlit config show` in the terminal to see all available options.

    Parameters
    ----------
    key : str
        The config option key of the form "section.optionName". To see all
        available options, run `streamlit config show` on a terminal.
    Config key "%s" not defined.N)r   r   RuntimeErrorr   r   config_optionsr   r   r   
get_option   s
    r(   )sectionr   c              
   C   sN   t @ t }i }| D ]}|j| kr|j||j< q|W  5 Q R  S Q R X dS )a  Get all of the config options for the given section.

    Run `streamlit config show` in the terminal to see all available options.

    Parameters
    ----------
    section : str
        The name of the config section to fetch options for.

    Returns
    -------
    Dict[str, Any]
        A dict mapping the names of the options in the given section (without
        the section name as a prefix) to their values.
    N)r   r   valuesr)   r   name)r)   r'   Zoptions_for_sectionoptionr   r   r   get_options_for_section   s    
r-   )r)   descriptionr   c                 C   s    | t kstd|  |t | < dS )z=Create a config section and store it globally in this module.z!Cannot define section "%s" twice.N)r   AssertionError)r)   r.   r   r   r   _create_section   s    
r0   FZvisible)r   r.   default_valr!   
visibility
deprecateddeprecation_textexpiration_datereplaced_bytype_	sensitiver   c                 C   sd   t | |||||||||	|
d}|jtksDtd|jdt f | tksXtd|  |t| < |S )a  Create a ConfigOption and store it globally in this module.

    There are two ways to create a ConfigOption:

        (1) Simple, constant config options are created as follows:

            _create_option('section.optionName',
                description = 'Put the description here.',
                default_val = 12345)

        (2) More complex, programmable config options use decorator syntax to
        resolve their values at runtime:

            @_create_option('section.optionName')
            def _section_option_name():
                """Put the description here."""
                return 12345

    To achieve this sugar, _create_option() returns a *callable object* of type
    ConfigObject, which then decorates the function.

    NOTE: ConfigObjects call their evaluation functions *every time* the option
    is requested. To prevent this, use the `streamlit.util.memoize` decorator as
    follows:

            @_create_option('section.memoizedOptionName')
            @util.memoize
            def _section_memoized_option_name():
                """Put the description here."""

                (This function is only called once.)
                """
                return 12345

    )
r.   r1   r!   r2   r3   r4   r5   r6   r7   r8   zSection "%s" must be one of %s.z, z Cannot define option "%s" twice.)r   r)   r   r/   joinkeysr   )r   r.   r1   r!   r2   r3   r4   r5   r6   r7   r8   r,   r   r   r   _create_option   s.    0r;   c                 C   s8   zt | = ttttf t| = W n tk
r2   Y nX dS )zVRemove a ConfigOption by key from the global store.

    Only for use in testing.
    N)r   r   r   strr   r   	Exceptionr   r   r   r   _delete_option   s
    r>   globalz2Global options that apply across all of Streamlit.zglobal.disableWatchdogWarninga|  
        By default, Streamlit checks if the Python watchdog module is available
        and, if not, prints a warning asking for you to install it. The watchdog
        module is not required, but highly recommended. It improves Streamlit's
        ability to detect changes to files in your filesystem.

        If you'd like to turn off this warning, set this to True.
        )r.   r1   r7   z#global.showWarningOnDirectExecutionzy
        If True, will show a warning when you run a Streamlit-enabled script
        via "python my_script.py".
        Tglobal.developmentModehidden)r2   r7   )r   c                   C   s"   t   o dtko dtko dtkS )zzAre we in development mode.

    This option defaults to True if and only if Streamlit wasn't installed
    normally.
    zsite-packageszdist-packagesZ__pypackages__)r   Zis_pex__file__r   r   r   r   _global_development_mode+  s    
rC   global.logLevelSLevel of logging: 'error', 'warning', 'info', or 'debug'.

    Default: 'info'
    z3global.logLevel has been replaced with logger.levelz
2020-11-30zlogger.level)r.   r3   r4   r5   r6   zglobal.unitTestzAre we in a unit test?)r.   r2   r1   r7   z"global.suppressDeprecationWarningsz/Hide deprecation warnings in the streamlit app.zglobal.minCachedMessageSizezNOnly cache ForwardMsgs that are greater than or equal to
        this minimum.g     @zglobal.maxCachedMessageAgezExpire cached ForwardMsgs whose age is greater than this
        value. A message's age is defined by how many times its script has
        finished running since the message has been accessed.   zglobal.dataFrameSerializationa   
        DataFrame serialization.

        Acceptable values:
        - 'legacy': Serialize DataFrames using Streamlit's custom format. Slow
          but battle-tested.
        - 'arrow': Serialize DataFrames using Apache Arrow. Much faster and versatile.Zarrowloggerz-Settings to customize Streamlit log messages.)r7   c                   C   s(   t drtt dS t dr dS dS dS )rE   rD   r@   debuginfoN)r(   r<   r   r   r   r   _logger_log_level{  s
    rJ   zlogger.messageFormatc                  C   s    t drddlm}  | S dS dS )a?  String format for logging messages. If logger.datetimeFormat is set,
    logger messages will default to `%(asctime)s.%(msecs)03d %(message)s`. See
    [Python's documentation](https://docs.python.org/2.6/library/logging.html#formatter-objects)
    for available attributes.

    Default: "%(asctime)s %(message)s"
    r@   r   DEFAULT_LOG_MESSAGEz%(asctime)s %(message)sN)r(   streamlit.loggerrL   rK   r   r   r   _logger_message_format  s    	rN   zlogger.enableRichay  
        Controls whether uncaught app exceptions are logged via the rich library.

        If True and if rich is installed, exception tracebacks will be logged with syntax highlighting and formatting.
        Rich tracebacks are easier to read and show more code than standard Python tracebacks.

        If set to False, the default Python traceback formatting will be used.)r.   r1   r2   r7   r!   clientz(Settings for scripts that use Streamlit.zclient.cachingzWhether to enable st.cache.)r.   r1   r7   r!   zclient.displayEnabledzJIf false, makes your Streamlit script not draw to a
        Streamlit app.zclient.showErrorDetailsa  
        Controls whether uncaught app exceptions and deprecation warnings
        are displayed in the browser. By default, this is set to True and
        Streamlit displays app exceptions and associated tracebacks, and
        deprecation warnings, in the browser.

        If set to False, an exception or deprecation warning will result in
        a generic message being shown in the browser, and exceptions, tracebacks,
        and deprecation warnings will be printed to the console only.zclient.toolbarModeaf  
        Change the visibility of items in the toolbar, options menu,
        and settings dialog (top right of the app).

        Allowed values:
        * "auto"      : Show the developer options if the app is accessed through
                        localhost and hide them otherwise.
        * "developer" : Show the developer options.
        * "viewer"    : Hide the developer options.
        * "minimal"   : Show only options set externally (e.g. through
                        Streamlit Community Cloud) or through st.set_page_config.
                        If there are no options left, hide the menu.
autorunnerz/Settings for how Streamlit executes your scriptzrunner.magicEnabledz
        Allows you to type a variable or string by itself in a single line of
        Python code to write it to the app.
        zrunner.installTracerz
        Install a Python tracer to allow you to stop or pause your script at
        any point and introspect it. As a side-effect, this slows down your
        script's execution.
        zrunner.fixMatplotlibzv
        Sets the MPLBACKEND environment variable to Agg inside Streamlit to
        prevent Python crashing.
        zrunner.postScriptGCz
        Run the Python Garbage Collector after each script execution. This
        can help avoid excess memory use in Streamlit apps, but could
        introduce delay in rerunning the app script for high-memory-use
        applications.
        zrunner.fastRerunsaZ  
        Handle script rerun requests immediately, rather than waiting for script
        execution to reach a yield point. This makes Streamlit much more
        responsive to user interaction, but it can lead to race conditions in
        apps that mutate session_state data outside of explicit session_state
        assignment statements.
    z&runner.enforceSerializableSessionStateaE  
        Raise an exception after adding unserializable data to Session State.
        Some execution environments may require serializing all data in Session
        State, so it may be useful to detect incompatibility during development,
        or when the execution environment will stop supporting it in the future.
    serverz!Settings for the Streamlit serverzserver.folderWatchBlacklistzList of folders that should not be watched for changes. This
    impacts both "Run on Save" and @st.cache.

    Relative paths will be taken as relative to the current working directory.

    Example: ['/home/user1/env', 'relative/path/to/folder']
    )r.   r1   zserver.fileWatcherTypea  
        Change the type of file watcher used by Streamlit, or turn it off
        completely.

        Allowed values:
        * "auto"     : Streamlit will attempt to use the watchdog module, and
                       falls back to polling if watchdog is not available.
        * "watchdog" : Force Streamlit to use the watchdog module.
        * "poll"     : Force Streamlit to always use polling.
        * "none"     : Streamlit will not watch files.
    zserver.cookieSecret)r7   r8   c                   C   s   t  S )zSymmetric key used to produce signed cookies. If deploying on multiple replicas, this should
    be set to the same value across all replicas to ensure they all share the same secret.

    Default: randomly generated secret key.
    )secretsZ	token_hexr   r   r   r   _server_cookie_secretL  s    rT   zserver.headlessc                   C   s*   t jrtdsdS tddk	r&dS dS )zIf false, will attempt to open a browser window on start.

    Default: false unless (1) we are on a Linux box where DISPLAY is unset, or
    (2) we are running in the Streamlit Atom plugin.
    ZDISPLAYTZ%IS_RUNNING_IN_STREAMLIT_EDITOR_PLUGINNF)r   ZIS_LINUX_OR_BSDosgetenvr   r   r   r   _server_headlessW  s
    rW   zserver.runOnSavezO
        Automatically rerun script when the file is modified on disk.
        zserver.allowRunOnSavezJ
        Allows users to automatically rerun when app is updated.
        zserver.addressc                   C   s   dS )a  The address where the server will listen for client and browser
    connections. Use this if you want to bind the server to a specific address.
    If set, the server will only be accessible from this address, and not from
    any aliases (like localhost).

    Default: (unset)
    Nr   r   r   r   r   _server_address}  s    	rX   server.portzG
        The port where the server will listen for browser connections.i5!  zserver.scriptHealthCheckEnableda  
    Flag for enabling the script health check endpoint. It used for checking if
    a script loads successfully. On success, the endpoint will return a 200
    HTTP status code. On failure, the endpoint will return a 503 HTTP status code.

    Note: This is an experimental Streamlit internal API. The API is subject
    to change anytime so this should be used at your own risk
    )r2   r.   r1   r7   zserver.baseUrlPathzR
        The base path for the URL where Streamlit should be served from.
         server.enableCORSa  
    Enables support for Cross-Origin Resource Sharing (CORS) protection, for added security.

    Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is on and
    `server.enableCORS` is off at the same time, we will prioritize `server.enableXsrfProtection`.
    server.enableXsrfProtectiona*  
        Enables support for Cross-Site Request Forgery (XSRF) protection, for added security.

        Due to conflicts between CORS and XSRF, if `server.enableXsrfProtection` is on and
        `server.enableCORS` is off at the same time, we will prioritize `server.enableXsrfProtection`.
        zserver.maxUploadSizezT
        Max size, in megabytes, for files uploaded with the file_uploader.
           zserver.maxMessageSizezd
        Max size, in megabytes, of messages that can be sent via the WebSocket connection.
        z!server.enableWebsocketCompressionz<
        Enables support for websocket compression.
        zserver.enableStaticServingz`
        Enable serving files from a `static` directory in the running app's directory.
        Zbrowserz(Configuration of non-UI browser options.zbrowser.serverAddressa;  
        Internet address where users should point their browsers in order to
        connect to the app. Can be IP address or DNS name and path.

        This is used to:
        - Set the correct URL for CORS and XSRF protection purposes.
        - Show the URL on the terminal
        - Open the browser
        	localhostzbrowser.gatherUsageStatsz@
        Whether to send usage statistics to Streamlit.
        browser.serverPortc                   C   s   t tdS )a  Port where users should point their browsers in order to connect to the
    app.

    This is used to:
    - Set the correct URL for CORS and XSRF protection purposes.
    - Show the URL on the terminal
    - Open the browser

    Default: whatever value is set in server.port.
    rY   )intr(   r   r   r   r   _browser_server_port  s    ra   zDO NOT USE THIS OPTION IN A PRODUCTION ENVIRONMENT. It has not gone through security audits or performance tests. For the production environment, we recommend performing SSL termination by the load balancer or the reverse proxy.zserver.sslCertFilez
        Server certificate file for connecting via HTTPS.
        Must be set at the same time as "server.sslKeyFile".

        z	
        )r.   zserver.sslKeyFilez
        Cryptographic key file for connecting via HTTPS.
        Must be set at the same time as "server.sslCertFile".

        uiz6Configuration of UI elements displayed in the browser.zui.hideTopBarz
    Flag to hide most of the UI elements found at the top of a Streamlit app.

    NOTE: This does *not* hide the hamburger menu in the top-right of an app.
    )r.   r1   r7   r2   zui.hideSidebarNavz3Flag to hide the sidebar page navigation component.Zmapboxz2Mapbox configuration that is being used by DeckGL.zmapbox.tokenzConfigure Streamlit to use a custom Mapbox
                token for elements like st.pydeck_chart and st.map.
                To get a token for yourself, create an account at
                https://mapbox.com. It's free (for moderate usage levels)!)r.   r1   r8   deprecationz3Configuration to show or hide deprecation warnings.z$deprecation.showfileUploaderEncodingzOSet to false to disable the deprecation warning for the file uploader encoding.z
2021-01-06)r.   r1   r!   r7   r5   zdeprecation.showImageFormatzOSet to false to disable the deprecation warning for the image format parameter.z3The format parameter for st.image has been removed.z
2021-03-24)r.   r1   r!   r7   r3   r4   r5   zdeprecation.showPyplotGlobalUsezUSet to false to disable the deprecation warning for using the global pyplot instance.)r.   r1   r!   r7   Zthemez9Settings to define a custom theme for your Streamlit app.z
theme.basez^The preset Streamlit theme that your custom theme inherits from.
    One of "light" or "dark".ztheme.primaryColorz.Primary accent color for interactive elements.ztheme.backgroundColorz+Background color for the main content area.ztheme.secondaryBackgroundColorzCBackground color used for the sidebar and most interactive widgets.ztheme.textColorzColor used for almost all text.z
theme.fontzx
      Font family for all text in the app, except code blocks. One of "sans serif",
      "serif", or "monospace".
    c              
   C   s@   t 2 t }| |kr td|  ||  jW  5 Q R  S Q R X dS )zIndicate where (e.g. in which file) this option was defined.

    Parameters
    ----------
    key : str
        The config option key of the form "section.optionName"

    r$   N)r   r   r%   r   r&   r   r   r   get_where_defined  s
    	rd   )option_namer   c                 C   s   t | tjkS )zCheck if a given option has not been set by the user.

    Parameters
    ----------
    option_name : str
        The option to check


    Returns
    -------
    bool
        True if the option has not been set by the user.

    )rd   r   DEFAULT_DEFINITIONre   r   r   r   	_is_unset  s    rh   c                 C   s   t | tjtjfkS )zCheck if a given option was actually defined by the user.

    Parameters
    ----------
    option_name : str
        The option to check


    Returns
    -------
    bool
        True if the option has been set by the user.

    )rd   r   rf   ZSTREAMLIT_DEFINITIONrg   r   r   r   is_manually_set  s    ri   c                	   C   s.   t   ttttttf t W 5 Q R X dS )z)Print all config options to the terminal.N)	r   r	   show_configr   r   r   r<   r   r   r   r   r   r   rj     s
     rj   c                 C   sT   t dk	std| t kr@ddlm} |t}|d|  d nt |  || dS )a  Set a config option by key / value pair.

    This function assumes that the _config_options dictionary has already been
    populated and thus should only be used within this file and by tests.

    Parameters
    ----------
    key : str
        The key of the option, like "logger.level".
    value
        The value of the option.
    where_defined : str
        Tells the config system where this was set.

    Nz0_config_options should always be populated here.r   
get_logger"zg" is not a valid config option. If you previously had this config option set, it may have been removed.)r   r/   rM   rl   __name__warning	set_value)r   r   r   rl   LOGGERr   r   r   r     s    
r   )r'   c                 C   sB   |   D ]4\}}|jsqtj|j}|dkr0qt||t qdS )z{Update the config system by parsing the environment variable.

    This should only be called from get_config_options.
    N)itemsr8   rU   environgetenv_varr   _DEFINED_BY_ENV_VAR)r'   opt_nameopt_valZenv_var_valuer   r   r   %_update_config_with_sensitive_env_var  s    ry   )raw_tomlr   r   c                 C   sP   t | }| D ]8\}}| D ]&\}}t|}t| d| || q"qdS )a)  Update the config system by parsing this string.

    This should only be called from get_config_options.

    Parameters
    ----------
    raw_toml : str
        The TOML file to parse to update the config values.
    where_defined : str
        Tells the config system where this was set.

    .N)tomlloadsrr   _maybe_read_env_variabler   )rz   r   Zparsed_config_filer)   optionsr+   r   r   r   r   _update_config_with_toml  s
    
r   )r   r   c                 C   sh   t | trd| drd| tdd }tj|}|dkr\ddlm} |t	}|
d|  nt|S | S )aU  If value is "env:foo", return value of environment variable "foo".

    If value is not in the shape above, returns the value right back.

    Parameters
    ----------
    value : any
        The value to check

    Returns
    -------
    any
        Either returns value right back, or the value of the environment
        variable.

    zenv:Nr   rk   z!No environment variable called %s)
isinstancer<   
startswithlenrU   rs   rt   rM   rl   rn   error_maybe_convert_to_number)r   var_nameru   rl   rq   r   r   r   r~   .  s    r~   )vr   c                 C   sD   z
t | W S  tk
r   Y nX z
t| W S  tk
r>   Y nX | S )z-Convert v to int or float, or leave it as is.)r`   r=   float)r   r   r   r   r   P  s    

r   z'Emitted when the config file is parsed.)doczconfig.toml)options_from_flagsr   c                 C   s   |si }t }|r| s|S t t r6| s6t W  5 Q R  S t }tta tD ]>}tj|sZqHt	|ddd}|
 }W 5 Q R X t|| qHtt  | D ]\}}t||t q|rt|t rddlm}	 |	t}
|
d t  t W  5 Q R  S Q R X dS )a  Create and return a dict mapping config option names to their values,
    returning a cached dict if possible.

    Config option values are sourced from the following locations. Values
    set in locations further down the list overwrite those set earlier.
      1. default values defined in this file
      2. the global `~/.streamlit/config.toml` file
      3. per-project `$CWD/.streamlit/config.toml` files
      4. environment variables such as `STREAMLIT_SERVER_PORT`
      5. command line flags passed to `streamlit run`

    Parameters
    ----------
    force_reparse : bool
        Force config files to be parsed so that we pick up any changes to them.

    options_from_flags : Optional[Dict[str, any]
        Config options that we received via CLI flag.

    Returns
    -------
    Dict[str, ConfigOption]
        An ordered dict that maps config option names to their values.
    rzutf-8)encodingr   rk   z{An update to the [server] config option section was detected. To have these changes be reflected, please restart streamlit.N)r   r   copydeepcopyr   CONFIG_FILENAMESrU   pathexistsopenreadr   ry   rr   r   _DEFINED_BY_FLAGr	   Zserver_option_changedrM   rl   rn   ro   _on_config_parsedsend)Zforce_reparser   r'   Zold_optionsfilenameinputfile_contentsrw   rx   rl   rq   r   r   r   r   i  s<    
 r   c                  C   sb   ddl m}  | t}tdr<tds,tdtds<tdtdr^td	rTtdr^|d
 d S )Nr   rk   r@   rY   z>server.port does not work when global.developmentMode is true.r_   zEbrowser.serverPort does not work when global.developmentMode is true.r\   r[   a  
Warning: the config option 'server.enableCORS=false' is not compatible with 'server.enableXsrfProtection=true'.
As a result, 'server.enableCORS' is being overridden to 'true'.

More information:
In order to protect against CSRF attacks, we send a cookie with each request.
To do so, we must specify allowable origins, which places a restriction on
cross-origin resource sharing.

If cross origin resource sharing is required, please disable server.enableXsrfProtection.
            )rM   rl   rn   r(   rh   r/   ro   )rl   rq   r   r   r   _check_conflicts  s     	
r   c                   C   s   t dt_d S )Nr@   )r(   r
   Zis_development_moder   r   r   r   _set_development_mode  s    r   )funcr   c                    sH   fddfdd} fdd|s.t s>tjdd n  |S )	aS  Wait for the config file to be parsed then call func.

    If the config file has already been parsed, just calls func immediately
    unless force_connect is set.

    Parameters
    ----------
    func : Callable[[], None]
        A function to run on config parse.

    force_connect : bool
        Wait until the next config file parse to run func, even if config files
        have already been parsed.

    lock : bool
        If set, grab _config_lock before running func.

    Returns
    -------
    Callable[[], bool]
        A function that the caller can use to deregister func.
    c                    s     S Nr   )_)func_with_lockr   r   <lambda>      z"on_config_parsed.<locals>.<lambda>c                      s
   t  S r   )r   
disconnectr   )receiverr   r   r     s    z$on_config_parsed.<locals>.disconnectc                	      s&   rt     W 5 Q R X n   d S r   )r   r   )r   lockr   r   r     s    z(on_config_parsed.<locals>.func_with_lockF)Zweak)r   r   connect)r   Zforce_connectr   r   r   )r   r   r   r   r   on_config_parsed  s    r   )r   )FN)FF)I__doc__r   rU   rS   	threadingcollectionsr   typingr   r   r   r   r   r|   Zblinkerr   Z	streamlitr	   r
   r   r   r   Zstreamlit.config_optionr   Zstreamlit.errorsr   r   r<   __annotations__RLockr   r   r   Z_USER_DEFINEDr   rv   r   r#   r(   r-   r0   booltyper;   r>   rC   r   r`   rJ   rN   memoizerT   rW   rX   ra   Z_SSL_PRODUCTION_WARNINGrd   rh   ri   rj   r   ry   r   r~   r   r   Zget_streamlit_file_pathZget_project_streamlit_file_pathr   r   r   r   r   r   r   r   r   <module>   s(  '
H
	




		



	
	
			
	




	
	!"
   
N(   

7