o
    Wiv                     @  s   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ e	r6ddlmZ ddlmZ dd	lmZ G d
d deZG dd deZddgZdS )z&Application data stored by virtualenv.    )annotations)ABCabstractmethod)contextmanager)TYPE_CHECKING)	IS_ZIPAPP)	Generator)Path)Anyc                   @  s   e Zd ZdZed)ddZed)ddZed*ddZed)ddZe	d+ddZ
ed,ddZe	d-ddZe	d+ddZed.ddZed/d0d"d#Zeed0d$d%Zeed1d'd(ZdS )2AppDataz:Abstract storage interface for the virtualenv application.returnNonec                 C     dS )zCalled before virtualenv exits.N selfr   r   L/home/ubuntu/.local/lib/python3.10/site-packages/virtualenv/app_data/base.pyclose       zAppData.closec                 C  r   )z2Called when the user passes in the reset app data.Nr   r   r   r   r   reset   r   zAppData.resetpathr	   ContentStorec                 C     t )zReturn a content store for cached interpreter information at the given path.

        :param path: the interpreter executable path

        :returns: a content store for the cached data

        NotImplementedErrorr   r   r   r   r   py_info   s   	zAppData.py_infoc                 C  r   )z)Clear all cached interpreter information.r   r   r   r   r   py_info_clear'      zAppData.py_info_clearboolc                 C  r   )zA``True`` if this app data store supports updating cached content.r   r   r   r   r   
can_update,   r   zAppData.can_updatedistributionstrfor_py_versionc                 C  r   )a   Return a content store for the embed update log of a distribution.

        :param distribution: the package name (e.g. ``pip``)
        :param for_py_version: the target Python version string

        :returns: a content store for the update log

        r   )r   r!   r#   r   r   r   embed_update_log1      
zAppData.embed_update_logc                 C  r   )z1The root directory of the application data store.r   r   r   r   r   house=   r   zAppData.housec                 C  r   )zN``True`` if this app data store is transient and does not persist across runs.r   r   r   r   r   	transientB   r   zAppData.transientnamec                 C  r   )zReturn the path to a cached wheel image.

        :param for_py_version: the target Python version string
        :param name: the package name

        :returns: the path to the cached wheel

        r   )r   r#   r(   r   r   r   wheel_imageG   r%   zAppData.wheel_imageN	to_folderPath | NoneGenerator[Path]c                 c  sH    t r| ||}|V  W d   dS 1 sw   Y  dS |V  dS )zEnsure a path is available on disk, extracting from zipapp if needed.

        :param path: the path to ensure is available
        :param to_folder: optional target directory for extraction

        :returns: yields the usable path on disk

        N)r   extract)r   r   r*   resultr   r   r   ensure_extractedS   s   
"
zAppData.ensure_extractedc                 C  r   )zExtract a path from the zipapp to a location on disk.

        :param path: the path to extract
        :param to_folder: optional target directory

        :returns: yields the extracted path

        r   )r   r   r*   r   r   r   r-   c   s   zAppData.extractGenerator[None]c                 C  r   )z]Acquire an exclusive lock on the given path.

        :param path: the path to lock

        r   r   r   r   r   lockedp   s   zAppData.lockedr   r   )r   r	   r   r   r   r   )r!   r"   r#   r"   r   r   )r   r	   )r#   r"   r(   r"   r   r	   )N)r   r	   r*   r+   r   r,   )r   r	   r   r0   )__name__
__module____qualname____doc__r   r   r   r   r   propertyr    r$   r&   r'   r)   r   r/   r-   r1   r   r   r   r   r      s8    
r   c                   @  sZ   e Zd ZdZedddZedddZedddZedddZee	dddZ
dS )r   z/A store for reading and writing cached content.r   r   c                 C  r   )z[Check if the stored content exists.

        :returns: ``True`` if content exists

        r   r   r   r   r   exists~      zContentStore.existsr
   c                 C  r   )zHRead the stored content.

        :returns: the stored content

        r   r   r   r   r   read   r:   zContentStore.readcontentr   c                 C  r   )zSWrite content to the store.

        :param content: the content to write

        r   )r   r<   r   r   r   write   r:   zContentStore.writec                 C  r   )zRemove the stored content.r   r   r   r   r   remove   r   zContentStore.remover0   c                 C  r   )z0Acquire an exclusive lock on this content store.Nr   r   r   r   r   r1      r   zContentStore.lockedNr3   )r   r
   )r<   r
   r   r   r2   )r   r0   )r4   r5   r6   r7   r   r9   r;   r=   r>   r   r1   r   r   r   r   r   {   s    r   N)r7   
__future__r   abcr   r   
contextlibr   typingr   virtualenv.infor   collections.abcr   pathlibr	   r
   r   r   __all__r   r   r   r   <module>   s    j*