
    1Vh                     >    d Z ddlZddlmZ dZd Zd Zd Zd Z	d	 Z
y)
zLoad plugin assets from disk.    N)tfpluginsc                     t         j                  j                  j                  t        j
                  j                  | |            S )z2Helper that returns if parent/item is a directory.)r   iogfileisdirospathjoin)parentitems     f/home/dcms/DCMS/lib/python3.12/site-packages/tensorboard/backend/event_processing/plugin_asset_util.py_IsDirectoryr      s*    55;;RWW\\&$788    c                 L    t         j                  j                  | t        |      S )z-Returns the plugin directory for plugin_name.)r	   r
   r   _PLUGINS_DIR)logdirplugin_names     r   PluginDirectoryr      s    77<<k::r   c                 j   t         j                  j                  | t              }	 t        j
                  j                  j                  |      }|D cg c]0  }|j                  d      st        ||      r|j                  d      2 c}S # t        j                  j                  $ r g cY S w xY wc c}w )ab  List all the plugins that have registered assets in logdir.

    If the plugins_dir does not exist, it returns an empty list. This maintains
    compatibility with old directories that have no plugins written.

    Args:
      logdir: A directory that was created by a TensorFlow events writer.

    Returns:
      a list of plugin names, as strings
    /)r	   r
   r   r   r   r   r   listdirerrorsNotFoundErrorendswithr   rstrip)r   plugins_direntriesxs       r   ListPluginsr    #   s     '',,v|4K%%++%%k2 ::c?l;: 	
 	 99"" 	s   )B 5B0B-,B-c                     t        | |      }	 t        j                  j                  j	                  |      D cg c]  }|j                  d       c}S c c}w # t        j                  j                  $ r g cY S w xY w)a  List all the assets that are available for given plugin in a logdir.

    Args:
      logdir: A directory that was created by a TensorFlow summary.FileWriter.
      plugin_name: A string name of a plugin to list assets for.

    Returns:
      A string list of available plugin assets. If the plugin subdirectory does
      not exist (either because the logdir doesn't exist, or because the plugin
      didn't register) an empty list is returned.
    r   )r   r   r   r   r   r   r   r   )r   r   
plugin_dirr   s       r   
ListAssetsr#   =   sb     !5J')uu{{':'::'FG!GGG99"" 	s"   +A AA A A;:A;c                    t         j                  j                  t        | |      |      }	 t        j
                  j                  j                  |d      5 }|j                         cddd       S # 1 sw Y   yxY w# t        j                  j                  $ r t        d|z        t        j                  j                  $ r}t        d|d|      d}~ww xY w)ak  Retrieve a particular plugin asset from a logdir.

    Args:
      logdir: A directory that was created by a TensorFlow summary.FileWriter.
      plugin_name: The plugin we want an asset from.
      asset_name: The name of the requested asset.

    Returns:
      string contents of the plugin asset.

    Raises:
      KeyError: if the asset does not exist.
    rNzAsset path %s not foundzCouldn't read asset path: z
, OpError )r	   r
   r   r   r   r   r   GFilereadr   r   KeyErrorOpError)r   r   
asset_name
asset_pathfes         r   RetrieveAssetr.   Q   s     ofkBJOJ
UU[[z3/ 	1668	 	 	99"" ?0:=>>99 
:DaH
 	

s6   *A< A0&	A< 0A95A< 9A< <ACCC)__doc__os.pathr	   tensorboard.compatr   r   r   r   r    r#   r.    r   r   <module>r3      s0    $  ! 9
;
4(
r   