HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/docker/models/__pycache__/images.cpython-310.pyc
o

�hPF�@s�ddlZddlZddlZddlmZddlmZddlmZm	Z	m
Z
ddlmZddl
mZdd	lmZmZGd
d�de�ZGdd
�d
e�ZGdd�de�Zdd�ZdS)�N�)�	APIClient)�DEFAULT_DATA_CHUNK_SIZE)�
BuildError�ImageLoadError�InvalidArgument)�parse_repository_tag)�json_stream�)�
Collection�Modelc@sfeZdZdZdd�Zedd��Zedd��Zedd	��Zd
d�Z	dd
d�Z
edfdd�Zddd�Z
dS)�Imagez!
    An image on the server.
    cCs"d�|j�}d|jj�d|�d�S)Nz', '�<z: 'z'>)�join�tags�	__class__�__name__)�self�tag_str�r�G/usr/local/CyberCP/lib/python3.10/site-packages/docker/models/images.py�__repr__szImage.__repr__cCs|jd�d�}|piS)z7
        The labels of an image as dictionary.
        �Config�Labels��attrs�get)r�resultrrr�labelsszImage.labelscCs(|j�d�r
|jdd�S|jdd�S)�f
        The ID of the image truncated to 12 characters, plus the ``sha256:``
        prefix.
        �sha256:N��)�id�
startswith�rrrr�short_idszImage.short_idcCs&|j�d�}|durg}dd�|D�S)z#
        The image's tags.
        �RepoTagsNcSsg|]}|dkr|�qS)z
<none>:<none>r)�.0�tagrrr�
<listcomp>/szImage.tags.<locals>.<listcomp>r)rrrrrr'sz
Image.tagscCs|jj�|j�S)z�
        Show the history of an image.

        Returns:
            (list): The history of the image.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )�client�api�historyr#r%rrrr-1sz
Image.historyFcCs|jjj|j||d�S)a
        Remove this image.

        Args:
            force (bool): Force removal of the image
            noprune (bool): Do not delete untagged parents

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )�force�noprune)r+r,�remove_imager#)rr.r/rrr�remove>s
�zImage.removecCsT|j}|r"|jr
|jdn|}t|t�r"||jvr t|�d���|}|jj�||�S)a�
        Get a tarball of an image. Similar to the ``docker save`` command.

        Args:
            chunk_size (int): The generator will return up to that much data
                per iteration, but may return less. If ``None``, data will be
                streamed as it is received. Default: 2 MB
            named (str or bool): If ``False`` (default), the tarball will not
                retain repository and tag information for this image. If set
                to ``True``, the first tag in the :py:attr:`~tags` list will
                be used to identify the image. Alternatively, any element of
                the :py:attr:`~tags` list can be used as an argument to use
                that specific tag as the saved identifier.

        Returns:
            (generator): A stream of raw archive data.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.

        Example:

            >>> image = cli.images.get("busybox:latest")
            >>> f = open('/tmp/busybox-latest.tar', 'wb')
            >>> for chunk in image.save():
            >>>   f.write(chunk)
            >>> f.close()
        rz" is not a valid tag for this image)r#r�
isinstance�strrr+r,�	get_image)r�
chunk_size�named�imgrrr�savePs

�z
Image.saveNcKs|jjj|j|fd|i|��S)a�
        Tag this image into a repository. Similar to the ``docker tag``
        command.

        Args:
            repository (str): The repository to set for the tag
            tag (str): The tag name
            force (bool): Force

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.

        Returns:
            (bool): ``True`` if successful
        r))r+r,r)r#�r�
repositoryr)�kwargsrrrr)zsz	Image.tag)FF�N)r�
__module__�__qualname__�__doc__r�propertyrr&rr-r1rr8r)rrrrr

s

	
	

*r
cs\eZdZdZ�fdd�Zedd��Zedd��Zdd	d
�Zdd�Z	d
d�Z
ej
je
_�ZS)�RegistryDatazO
    Image metadata stored on the registry, including available platforms.
    cst�j|i|��||_dSr<)�super�__init__�
image_name)rrD�argsr;�rrrrC�s
zRegistryData.__init__cCs|jddS)z'
        The ID of the object.
        �
Descriptor�digest)rr%rrrr#�szRegistryData.idcCs|jdd�S)rNr!)r#r%rrrr&�szRegistryData.short_idNcCs"t|j�\}}|jj||j|d�S)z�
        Pull the image digest.

        Args:
            platform (str): The platform to pull the image for.
            Default: ``None``

        Returns:
            (:py:class:`Image`): A reference to the pulled image.
        )r)�platform)rrD�
collection�pullr#)rrIr:�_rrrrK�szRegistryData.pullcCs�|r>t|t�s>|�d�}t|�dkst|�dkr td|�d���d|di}t|�dkr2|d|d	<t|�dkr>|d|d
<t||j���|jdvS)a�
        Check whether the given platform identifier is available for this
        digest.

        Args:
            platform (str or dict): A string using the ``os[/arch[/variant]]``
                format, or a platform dictionary.

        Returns:
            (bool): ``True`` if the platform is recognized as available,
            ``False`` otherwise.

        Raises:
            :py:class:`docker.errors.InvalidArgument`
                If the platform argument is not a valid descriptor.
        �/�r
�"z$" is not a valid platform descriptor�osrr�variant�architecture�	Platforms)	r2�dict�split�lenr�normalize_platformr+�versionr)rrI�partsrrr�has_platform�s 

�
��zRegistryData.has_platformcCs|jj�|j�|_dSr<)r+r,�inspect_distributionrDrr%rrr�reload�szRegistryData.reloadr<)
rr=r>r?rCr@r#r&rKrZr\r�
__classcell__rrrFrrA�s


 rAc@s�eZdZeZdd�Zdd�Zddd�Zdd	d
�Zdd�Z	dd
d�Z
ddd�Zejj
e_
dd�Zejj
e_
dd�Zejj
e_
ddd�Zejj
e_
dd�Zejj
e_
dS)�ImageCollectionc	Ks�|jjjdi|��}t|t�r|�|�Sd}d}t�t|��\}}|D]"}d|vr0t	|d|��d|vrCt
�d|d�}|rC|�d�}|}q#|rO|�|�|fSt	|pSd|��)a�
        Build an image and return it. Similar to the ``docker build``
        command. Either ``path`` or ``fileobj`` must be set.

        If you already have a tar file for the Docker build context (including
        a Dockerfile), pass a readable file-like object to ``fileobj``
        and also pass ``custom_context=True``. If the stream is also
        compressed, set ``encoding`` to the correct value (e.g ``gzip``).

        If you want to get the raw output of the build, use the
        :py:meth:`~docker.api.build.BuildApiMixin.build` method in the
        low-level API.

        Args:
            path (str): Path to the directory containing the Dockerfile
            fileobj: A file object to use as the Dockerfile. (Or a file-like
                object)
            tag (str): A tag to add to the final image
            quiet (bool): Whether to return the status
            nocache (bool): Don't use the cache when set to ``True``
            rm (bool): Remove intermediate containers. The ``docker build``
                command now defaults to ``--rm=true``, but we have kept the old
                default of `False` to preserve backward compatibility
            timeout (int): HTTP timeout
            custom_context (bool): Optional if using ``fileobj``
            encoding (str): The encoding for a stream. Set to ``gzip`` for
                compressing
            pull (bool): Downloads any updates to the FROM image in Dockerfiles
            forcerm (bool): Always remove intermediate containers, even after
                unsuccessful builds
            dockerfile (str): path within the build context to the Dockerfile
            buildargs (dict): A dictionary of build arguments
            container_limits (dict): A dictionary of limits applied to each
                container created by the build process. Valid keys:

                - memory (int): set memory limit for build
                - memswap (int): Total memory (memory + swap), -1 to disable
                    swap
                - cpushares (int): CPU shares (relative weight)
                - cpusetcpus (str): CPUs in which to allow execution, e.g.,
                    ``"0-3"``, ``"0,1"``
            shmsize (int): Size of `/dev/shm` in bytes. The size must be
                greater than 0. If omitted the system uses 64MB
            labels (dict): A dictionary of labels to set on the image
            cache_from (list): A list of images used for build cache
                resolution
            target (str): Name of the build-stage to build in a multi-stage
                Dockerfile
            network_mode (str): networking mode for the run commands during
                build
            squash (bool): Squash the resulting images layers into a
                single layer.
            extra_hosts (dict): Extra hosts to add to /etc/hosts in building
                containers, as a mapping of hostname to IP address.
            platform (str): Platform in the format ``os[/arch[/variant]]``.
            isolation (str): Isolation technology used during build.
                Default: `None`.
            use_config_proxy (bool): If ``True``, and if the docker client
                configuration file (``~/.docker/config.json`` by default)
                contains a proxy configuration, the corresponding environment
                variables will be set in the container being built.

        Returns:
            (tuple): The first item is the :py:class:`Image` object for the
                image that was built. The second item is a generator of the
                build logs as JSON-decoded objects.

        Raises:
            :py:class:`docker.errors.BuildError`
                If there is an error during the build.
            :py:class:`docker.errors.APIError`
                If the server returns any other error.
            ``TypeError``
                If neither ``path`` nor ``fileobj`` is specified.
        N�error�streamz*(^Successfully built |sha256:)([0-9a-f]+)$r�Unknownr)
r+r,�buildr2r3r�	itertools�teer	r�re�search�group)	rr;�resp�
last_event�image_id�
result_stream�internal_stream�chunk�matchrrrrb�s(L

�
zImageCollection.buildcCs|�|jj�|��S)am
        Gets an image.

        Args:
            name (str): The name of the image.

        Returns:
            (:py:class:`Image`): The image.

        Raises:
            :py:class:`docker.errors.ImageNotFound`
                If the image does not exist.
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )�
prepare_modelr+r,�
inspect_image)r�namerrrr=szImageCollection.getNcCst||jj�||�|j|d�S)a
        Gets the registry data for an image.

        Args:
            name (str): The name of the image.
            auth_config (dict): Override the credentials that are found in the
                config for this request.  ``auth_config`` should contain the
                ``username`` and ``password`` keys to be valid.

        Returns:
            (:py:class:`RegistryData`): The data object.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )rDrr+rJ)rAr+r,r[)rrq�auth_configrrr�get_registry_dataOs�z!ImageCollection.get_registry_dataFcs&�jjj|||d�}�fdd�|D�S)a�
        List images on the server.

        Args:
            name (str): Only show images belonging to the repository ``name``
            all (bool): Show intermediate image layers. By default, these are
                filtered out.
            filters (dict): Filters to be processed on the image list.
                Available filters:
                - ``dangling`` (bool)
                - `label` (str|list): format either ``"key"``, ``"key=value"``
                    or a list of such.

        Returns:
            (list of :py:class:`Image`): The images.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        )rq�all�filterscsg|]	}��|d��qS)�Id�r)r(�rr%rrr*}sz(ImageCollection.list.<locals>.<listcomp>)r+r,�images)rrqrtrurhrr%r�listgszImageCollection.listcsr�jj�|�}g}|D]$}d|vr%t�d|d�}|r%|�d�}|�|�d|vr/t|d��q�fdd�|D�S)a�
        Load an image that was previously saved using
        :py:meth:`~docker.models.images.Image.save` (or ``docker save``).
        Similar to ``docker load``.

        Args:
            data (binary): Image data to be loaded.

        Returns:
            (list of :py:class:`Image`): The images.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.
        r`z)(^Loaded image ID: |^Loaded image: )(.+)$rr_csg|]}��|��qSrrw)r(�ir%rrr*�sz(ImageCollection.load.<locals>.<listcomp>)r+r,�
load_imagererfrg�appendr)r�datarhryrmrnrjrr%r�loads�

�zImageCollection.loadc	Ks�t|�\}}|p|pd}d|vrtjddd�|d=|jjj|f|d|d�|��}|D]}q+|sD|�d�r7d	nd
}|�|�|�|���S|�|�S)a�
        Pull an image of the given name and return it. Similar to the
        ``docker pull`` command.
        If ``tag`` is ``None`` or empty, it is set to ``latest``.
        If ``all_tags`` is set, the ``tag`` parameter is ignored and all image
        tags will be pulled.

        If you want to get the raw pull output, use the
        :py:meth:`~docker.api.image.ImageApiMixin.pull` method in the
        low-level API.

        Args:
            repository (str): The repository to pull
            tag (str): The tag to pull
            auth_config (dict): Override the credentials that are found in the
                config for this request.  ``auth_config`` should contain the
                ``username`` and ``password`` keys to be valid.
            platform (str): Platform in the format ``os[/arch[/variant]]``
            all_tags (bool): Pull all image tags

        Returns:
            (:py:class:`Image` or list): The image that has been pulled.
                If ``all_tags`` is True, the method will return a list
                of :py:class:`Image` objects belonging to this repository.

        Raises:
            :py:class:`docker.errors.APIError`
                If the server returns an error.

        Example:

            >>> # Pull the image tagged `latest` in the busybox repo
            >>> image = client.images.pull('busybox')

            >>> # Pull all tags in the busybox repo
            >>> images = client.images.pull('busybox', all_tags=True)
        �latestr`zH`stream` is not a valid parameter for this method and will be overriddenr
)�
stacklevelT)r)r`�all_tagsr �@�:)	r�warnings�warnr+r,rKr$rrz)	rr:r)r�r;�	image_tag�pull_logrL�seprrrrK�s*&����
zImageCollection.pullcKs|jjj|fd|i|��S)Nr))r+r,�pushr9rrrr��szImageCollection.pushcOs|jjj|i|��dSr<)r+r,r0�rrEr;rrrr1�szImageCollection.removecO�|jjj|i|��Sr<)r+r,rfr�rrrrf��zImageCollection.searchcCs|jjj|d�S)N)ru)r+r,�prune_images)rrurrr�prune�szImageCollection.prunecOr�r<)r+r,�prune_buildsr�rrrr��r�zImageCollection.prune_buildsr<)NFN)NF)rr=r>r
�modelrbrrsrzrrKr�rr?r1r0rfr�r�r�rrrrr^�s$a


 
>




r^cCs8|duri}d|vr|d|d<d|vr|d|d<|S)NrP�OsrR�Archr)rI�engine_inforrrrW�srW)rcrer�r,r�	constantsr�errorsrrr�utilsr�utils.json_streamr	�resourcerrr
rAr^rWrrrr�<module>s K