
    1Vh
                     ,    d Z ddlZdZdZ G d d      Zy)z(Application-level experiment ID support.    N
experimentHTTP_TENSORBOARD_EXPERIMENT_IDc                       e Zd ZdZd Zd Zy)ExperimentIdMiddlewarea6  WSGI middleware extracting experiment IDs from URL to environment.

    Any request whose path matches `/experiment/SOME_EID[/...]` will have
    its first two path components stripped, and its experiment ID stored
    onto the WSGI environment with key taken from the `WSGI_ENVIRON_KEY`
    constant. All other requests will have paths unchanged and the
    experiment ID set to the empty string. It noops if the key taken from
    the `WSGI_ENVIRON_KEY` is already present in the environment.

    Instances of this class are WSGI applications (see PEP 3333).
    c                 z    || _         t        j                  dt        j                  t              z        | _        y)zInitializes an `ExperimentIdMiddleware`.

        Args:
          application: The WSGI application to wrap (see PEP 3333).
        z/%s/([^/]*)N)_applicationrecompileescape_EXPERIMENT_PATH_COMPONENT_pat)selfapplications     Q/home/dcms/DCMS/lib/python3.12/site-packages/tensorboard/backend/experiment_id.py__init__zExperimentIdMiddleware.__init__*   s0     ( JJRYY'ABB
	    c                 ~   t         |v r| j                  ||      S |j                  dd      }| j                  j	                  |      }|r7|j                  d      }||j                  d      d  }|j                  d      }nd}|}d}||t         <   ||d<   |j                  dd      |z   |d<   | j                  ||      S )N	PATH_INFO    r   SCRIPT_NAME)WSGI_ENVIRON_KEYr   getr   matchgroupend)r   environstart_responsepathmeidnew_pathroots           r   __call__zExperimentIdMiddleware.__call__7   s    w&$$Wn=={{;+IIOOD!''!*CAEE!HJ'H771:DCHD$' !'!(]B!?$!F  .99r   N)__name__
__module____qualname____doc__r   r$    r   r   r   r      s    

:r   r   )r(   r	   r   r   r   r)   r   r   <module>r*      s)    / 

 *  4 ,: ,:r   