o
    ®Ÿ?e<  ã                   @   s¾   d Z ddlZddlZddlmZ ddlm	Z	 zddl
mZ W n ey)   dZY nw e	dgddd	„ ƒZe	d
gddd„ ƒZe	dgddd„ ƒZe	dgddd„ ƒZe	dgdddd„ƒZdS )zResource management library.é    N)Ú
tf_inspect)Ú	tf_export)Úrunfileszresource_loader.load_resource)Úv1c                 C   s:   t t| ƒdƒ}| ¡ W  d  ƒ S 1 sw   Y  dS )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Úf© r   úk/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/platform/resource_loader.pyÚload_resource   s   $ÿr   z#resource_loader.get_data_files_pathc                   C   s   t j t t d¡¡¡S )z°Get 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Ú	_getframer   r   r   r   Úget_data_files_path0   s   r   z/resource_loader.get_root_dir_with_all_resourcesc                  C   sn   t ƒ } | g}d}	 |d }tj |¡}d|v r"t|ƒdkr!|d }q3tj |¡}||kr-q3| |¡ q	|p6| 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.
  Ú Téÿÿÿÿz	.runfilesr   éþÿÿÿ)r   r   r
   ÚbasenameÚlenr   Úappend)Z
script_dirÚdirectoriesZdata_files_dirZcandidate_dirZcurrent_directoryZnew_candidate_dirr   r   r   Úget_root_dir_with_all_resources;   s    	
îr   z$resource_loader.get_path_to_datafilec              	   C   sf   t r t  ¡ }| tj tj d| ¡¡¡}|dur tj |¡r |S tj tj t	 
t 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.
  Z
tensorflowNr   )r   ZCreateZ	Rlocationr   r
   ÚabspathÚjoinÚexistsr   r   r   r   r   )r
   ÚrZ	new_fpathZold_filepathr   r   r   r   c   s   ÿÿr   z#resource_loader.readahead_file_pathÚ128Mc                 C   s   | S )z;Readahead files not implemented; simply returns given path.r   )r
   Z	readaheadr   r   r   Úreadahead_file_path   s   r$   )r#   )Ú__doc__Úosr   Úsysr   Ztensorflow.python.utilr   r   Z tensorflow.python.util.tf_exportr   Zrules_python.python.runfilesr   ÚImportErrorr   r   r   r   r$   r   r   r   r   Ú<module>   s(   ÿ







'

