o
    Nrf                     @   sV   d dl Z d dlZd dlZd dlZd dlZddlmZmZ ddlm	Z	 G dd dZ
dS )    N   )	constantserrors)create_environment_dictc                   @   s>   e Zd ZdddZdd Zdd Zdd	 Zd
d Zdd ZdS )StoreNc                 C   sH   t j| | _t| j| _|| _| jdu r"tj| j ddd dS dS )z Create a store object that acts as an interface to
            perform the basic operations for storing, retrieving
            and erasing credentials using `program`.
        N' not installed or not available in PATHr   )
stacklevel)	r   ZPROGRAM_PREFIXprogramshutilwhichexeenvironmentwarningswarn)selfr	   r    r   a/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/docker/credentials/store.py__init__   s   


zStore.__init__c                 C   s^   t |ts
|d}| d|}t|d}|d dkr-|d dkr-td| j	 |S )zt Retrieve credentials for `server`. If no credentials are found,
            a `StoreError` will be raised.
        utf-8getUsername SecretzNo matching credentials in )

isinstancebytesencode_executejsonloadsdecoder   ZCredentialsNotFoundr	   )r   serverdataresultr   r   r   r      s   


z	Store.getc                 C   s$   t |||dd}| d|S )z_ Store credentials for `server`. Raises a `StoreError` if an error
            occurs.
        )Z	ServerURLr   r   r   store)r   dumpsr   r   )r   r    usernamesecret
data_inputr   r   r   r#   .   s   zStore.storec                 C   s$   t |ts
|d}| d| dS )z_ Erase credentials for `server`. Raises a `StoreError` if an error
            occurs.
        r   eraseN)r   r   r   r   )r   r    r   r   r   r(   9   s   

zStore.erasec                 C   s   |  dd}t|dS )zB List stored credentials. Requires v0.4.0+ of the helper.
        listNr   )r   r   r   r   )r   r!   r   r   r   r)   A   s   z
Store.listc              
   C   s   | j d u rt| j dd }t| j}ztj| j |g||d}W |S  tjy8 } zt	|| j|d }~w t
ya } z|jtjkrOt| j d|td|j d|j |d }~ww )Nr   )inputenvzUnexpected OS error "z	", errno=)r   r   Z
StoreErrorr	   r   r   
subprocesscheck_outputCalledProcessErrorZprocess_store_errorOSErrorerrnoENOENTstrerror)r   Zsubcmdr'   outputr+   er   r   r   r   G   s8   



zStore._execute)N)	__name__
__module____qualname__r   r   r#   r(   r)   r   r   r   r   r   r      s    
r   )r0   r   r
   r,   r   r   r   r   utilsr   r   r   r   r   r   <module>   s    