HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/cwd/usr/lib/python3/dist-packages/compose/__pycache__/volume.cpython-310.pyc
o

S�`��@s�ddlZddlZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
dd	lmZdd
lmZddlmZe�e�ZGdd
�d
�ZGdd�d�ZGdd�de�Zdd�ZdS)�N)�chain)�NotFound)�
version_lt�)�__version__)�ConfigurationError)�
VolumeSpec)�
LABEL_PROJECT)�
LABEL_VERSION)�LABEL_VOLUMEc@steZdZ		ddd�Zdd�Zdd�Zdd	d
�Zdd�Zed
d��Z	edd��Z
edd��Zedd��Zdd�Z
dS)�VolumeNFc		Cs:||_||_||_||_||_||_||_||_d|_dS�N)	�client�project�name�driver�driver_opts�external�labels�custom_name�legacy)	�selfrrrrrrrr�r�0/usr/lib/python3/dist-packages/compose/volume.py�__init__s
zVolume.__init__cCs|jj|j|j|j|jd�S)N)r)r�
create_volume�	full_namerr�_labels�rrrr�create s�z
Volume.createcCs4|jrt�d|j�dSt�d|j�|j�|j�S)NzVolume %s is external, skippingzRemoving volume %s)r�log�info�	true_namer�
remove_volumerrrr�remove%s
z
Volume.removecCs |r	|j�|j�S|j�|j�Sr
)r�inspect_volume�legacy_full_namer)rrrrr�inspect,szVolume.inspectcCs2|��z
|j|jd�WdStyYdSw)N�rFT)�_set_legacy_flagr'rrrrrr�exists1s��z
Volume.existscCs"|jr|jSd�|j�d�|j�S)N�{}_{}z-_)rr�formatr�lstriprrrrr9szVolume.full_namecCs&|jr|jSd�t�dd|j�|j�S)Nr+z[_-]�)rrr,�re�subrrrrrr&?s
�zVolume.legacy_full_namecCs|��|jr
|jS|jSr
)r)rr&rrrrrr"GszVolume.true_namecCsDt|jjd�r	dS|jr|j��ni}|�t|jt|j	t
ti�|S)Nz1.23)rr�_versionr�copy�updater	rrrr
r)rrrrrrNs�zVolume._labelscCsF|jdurdSz|jdd�}|du|_WdSty"d|_YdSw)NTr(F)rr'r)r�datarrrr)Zs
�zVolume._set_legacy_flag)NNFNFr
)�__name__�
__module__�__qualname__rrr$r'r*�propertyrr&r"rr)rrrrrs"
�




rc@s8eZdZdd�Zedd��Zdd�Zdd�Zd	d
�ZdS)�ProjectVolumescCs
||_dSr
)�volumes)rr:rrrrfs
zProjectVolumes.__init__cs*|jpi}��fdd�|��D�}||�S)NcsZi|])\}}|t��|�d|�|�d�|�d�|�d�du|�d�t|�dd��d��qS)rrrNrrF)rrrrrrrr)r�get�bool)�.0�vol_namer4�rrrr�
<dictcomp>ls�
��z.ProjectVolumes.from_config.<locals>.<dictcomp>)r:�items)�clsr�config_datar�config_volumesr:rr?r�from_configis

�
zProjectVolumes.from_configc	Cs@|j��D]}z|��Wqtyt�d|j�YqwdS)NzVolume %s not found.)r:�valuesr$rr �warningr")r�volumerrrr${s��zProjectVolumes.removecCs�zF|j��D]=}|��}|jr%t�d�|j��|s$tdj|j	dd���q|s9t�
d�|j	|jp1d��|��qt
|j|jd�|�qWdStyWtd�|j|j���w)	Nz>Volume {} declared as external. No new volume will be created.z�Volume {name} declared as external, but could not be found. Please create the volume manually using `{command}{name}` and try again.zdocker volume create --name=)r�commandz#Creating volume "{}" with {} driver�defaultr(z)Volume {} specifies nonexistent driver {})r:rFr*rr �debugr,rrrr!rr�check_remote_volume_configr'rr)rrH�
volume_existsrrr�
initialize�s>�����
���zProjectVolumes.initializecCsB|js|St|t�r|j|j}|j|jd�S|j|jj|_|S)N)r)�is_named_volume�
isinstancerr:r�_replacer"�source)r�volume_specrHrrr�namespace_spec�s
zProjectVolumes.namespace_specN)	r5r6r7r�classmethodrEr$rNrTrrrrr9ds
"r9cseZdZ�fdd�Z�ZS)�VolumeConfigChangedErrorc	s$t��dj|j||||jd��dS)NaConfiguration for volume {vol_name} specifies {property_name} {local_value}, but a volume with the same name uses a different {property_name} ({remote_value}). If you wish to use the new configuration, please remove the existing volume "{full_name}" first:
$ docker volume rm {full_name})r>�
property_name�local_value�remote_valuer)�superrr,rr")r�localrWrXrY��	__class__rrr�s��z!VolumeConfigChangedError.__init__)r5r6r7r�
__classcell__rrr\rrV�srVcCs�|jr|�d�|jkrt|d|j|�d���|jpi}|�d�p!i}tt||��D]"}|�d�r1q)|�|�|�|�krKt|d�|�|�|�|�|���q)|jpPi}|�d�pWi}tt||��D]}|�d�rgq_|�|�|�|�kr{t	�
d�|j|��q_dS)N�Driverr�Optionszcom.docker.z"{}" driver_opt�Labelsz?Volume {}: label "{}" has changed. It may need to be recreated.)rr;rVr�setr�
startswithr,rr rGr)�remoter[�
local_opts�remote_opts�k�local_labels�
remote_labelsrrrrL�s0

��


���rL)�loggingr/�	itertoolsr�
docker.errorsr�docker.utilsrr.r�configr�config.typesr�constr	r
r�	getLoggerr5r rr9rVrLrrrr�<module>s 
QL