o
    €j6hÿ  ã                   @  s\   d Z ddlmZ ddlZddlmZ ddd	„ZG d
d„ dƒZG dd„ dƒZG dd„ dƒZ	dS )z<Module for classes related to identifying a Sheets document.é    )ÚannotationsN)Úsheets_sanitize_urlÚkeyÚstrÚreturnc                 C  s   t  d| ¡std | ¡ƒ‚| S )Nz[a-zA-Z0-9_-]+z"{}" is not a valid Sheets key)ÚreÚ	fullmatchÚ
ValueErrorÚformat)r   © r   úu/var/www/html/chefvision.cloud.itp360.com/venv/lib/python3.10/site-packages/google/generativeai/notebook/sheets_id.pyÚ_sanitize_key   s   r   c                   @  ó$   e Zd ZdZd
dd„Zddd„Zd	S )Ú	SheetsURLz?Class that enforces safety by ensuring that URLs are sanitized.Úurlr   c                 C  s   t  |¡| _d S ©N)r   Úsanitize_sheets_urlÚ_url)Úselfr   r   r   r   Ú__init__   s   zSheetsURL.__init__r   c                 C  ó   | j S r   ©r   ©r   r   r   r   Ú__str__"   ó   zSheetsURL.__str__N)r   r   ©r   r   ©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      ó    
r   c                   @  r   )Ú	SheetsKeyz?Class that enforces safety by ensuring that keys are sanitized.r   r   c                 C  s   t |ƒ| _d S r   )r   Ú_key)r   r   r   r   r   r   )   s   zSheetsKey.__init__r   c                 C  r   r   ©r#   r   r   r   r   r   ,   r   zSheetsKey.__str__N)r   r   r   r   r   r   r   r   r"   &   r!   r"   c                   @  sH   e Zd ZdZ			ddd	d
„Zddd„Zddd„Zddd„Zdd„ ZdS )ÚSheetsIdentifierzèEncapsulates a means to identify a Sheets document.

    The gspread library provides three ways to look up a Sheets document: by name,
    by url and by key. An instance of this class represents exactly one of the
    methods.
    NÚnameú
str | Noner   úSheetsKey | Noner   úSheetsURL | Nonec                 C  sP   || _ || _|| _tt| j ƒƒtt| jƒƒ tt| jƒƒ }|dkr&tdƒ‚dS )aì  Constructor.

        Exactly one of the arguments should be provided.

        Args:
          name: The name of the Sheets document. More-than-one Sheets documents can
            have the same name, so this is the least precise method of identifying
            the document.
          key: The key of the Sheets document
          url: The url to the Sheets document

        Raises:
          ValueError: If the caller does not specify exactly one of name, url or
          key.
        é   z(Must set exactly one of name, key or urlN)Ú_namer#   r   ÚintÚboolr	   )r   r&   r   r   Ú
num_inputsr   r   r   r   8   s   *ÿzSheetsIdentifier.__init__r   c                 C  r   r   )r+   r   r   r   r   r&   V   r   zSheetsIdentifier.namec                 C  r   r   r$   r   r   r   r   r   Y   r   zSheetsIdentifier.keyc                 C  r   r   r   r   r   r   r   r   \   r   zSheetsIdentifier.urlc                 C  s0   | j r	d | j ¡S | jrd | j¡S d | j¡S )Nzname={}zkey={}zurl={})r+   r
   r#   r   r   r   r   r   r   _   s
   zSheetsIdentifier.__str__)NNN)r&   r'   r   r(   r   r)   )r   r'   )r   r(   )r   r)   )	r   r   r   r    r   r&   r   r   r   r   r   r   r   r%   0   s    	ü


r%   )r   r   r   r   )
r    Ú
__future__r   r   Úgoogle.generativeai.notebookr   r   r   r"   r%   r   r   r   r   Ú<module>   s   


