
    AVh<                         d Z ddlZddlZddlmZ ddlm	Z	 	 ddl
mZ  e	dg      d        Z e	d	g      d
        Z e	dg      d        Z e	dg      d        Z e	dg      dd       Zy# e$ r dZY [w xY w)zResource management library.    N)
tf_inspect)	tf_export)runfileszresource_loader.load_resource)v1c                 x    t        t        |       d      5 }|j                         cddd       S # 1 sw Y   yxY w)a  Load the resource at given path, where path is relative to tensorflow/.

  Args:
    path: a string resource path relative to tensorflow/.

  Returns:
    The contents of that resource.

  Raises:
    IOError: If the path is not found, or the resource can't be opened.
  rbN)openget_path_to_datafileread)pathfs     Z/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/platform/resource_loader.pyload_resourcer      s4      &- 668  s   09z#resource_loader.get_data_files_pathc                      t         j                  j                  t        j                  t        j                  d                  S )zGet a direct path to the data files colocated with the script.

  Returns:
    The directory where files specified in data attribute of py_test
    and py_binary are stored.
     )_osr   dirname_inspectgetfile_sys	_getframe     r   get_data_files_pathr   0   s-     
		(**4>>!+<=	>>r   z/resource_loader.get_root_dir_with_all_resourcesc                     t               } | g}d}	 |d   }t        j                  j                  |      }d|v rt	        |      dkD  r|d   }n7t        j                  j                  |      }||k(  rn|j                  |       s|xs | S )a%  Get a root directory containing all the data attributes in the build rule.

  Returns:
    The path to the specified file present in the data attribute of py_test
    or py_binary. Falls back to returning the same as get_data_files_path if it
    fails to detect a bazel runfiles directory.
   z	.runfilesr   )r   r   r   basenamelenr   append)
script_dirdirectoriesdata_files_dircandidate_dircurrent_directorynew_candidate_dirs         r   get_root_dir_with_all_resourcesr(   ;   s     #$*
 +.OM))-8''
 
[	A	$R((**=9	m	+,-% 	( 
	%:%r   z$resource_loader.get_path_to_datafilec           	         t         rt        j                         }|j                  t        j                  j                  t        j                  j                  d|                   }|!t        j                  j                  |      r|S t        j                  j                  t        j                  j                  t        j                  t        j                  d                  |       }|S )ae  Get the path to the specified file in the data dependencies.

  The path is relative to tensorflow/

  Args:
    path: a string resource path relative to tensorflow/

  Returns:
    The path to the specified file present in the data attribute of py_test
    or py_binary.

  Raises:
    IOError: If the path is not found, or the resource can't be opened.
  
tensorflowr   )r   Create	Rlocationr   r   abspathjoinexistsr   r   r   r   r   )r   r	new_fpathold_filepaths       r   r
   r
   c   s    " A|T:;=I!; 	hhx''q(9:;TC,	r   z#resource_loader.readahead_file_pathc                     | S )z;Readahead files not implemented; simply returns given path.r   )r   	readaheads     r   readahead_file_pathr5      s	     
+r   )128M)__doc__osr   sysr   tensorflow.python.utilr   r    tensorflow.python.util.tf_exportr   rules_python.python.runfilesr   ImportErrorr   r   r(   r
   r5   r   r   r   <module>r>      s    #   9 63 ./0 1" 456? 7? @AB$& C$&N 567 8: 456 7S  (s   A0 0A:9A: