HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib/google-cloud-sdk/lib/surface/artifacts/generic/__pycache__/download.cpython-312.pyc
�

�����j�dZddlmZddlmZddlmZddlZddlmZddl	m
Z
ddlmZdd	lm
Z
dd
lmZddlmZe
j"e
j$e
j&j(e
j&j*e
j&j,�Gd�d
e
j.���Zy)zGImplements the command to download generic artifacts from a repository.�)�absolute_import)�division)�unicode_literalsN)�
exceptions)�base)�
download_util)�	file_util)�flags)�logc�<�eZdZdZddd�Zed��Zd�Zd�Zd�Z	y	)
�Downloadz?Download a generic artifact from a generic artifact repository.z
{description}al    To download version v0.1.0 of myfile.txt located in a repository in "us-central1" to /path/to/destination/:

        $ {command} --location=us-central1 --project=myproject --repository=myrepo             --package=mypackage --version=v0.1.0 --destination=/path/to/destination/             --name=myfile.txt

    To download version v0.1.0 of myfile.txt located in a repository in "us-central1" to /path/to/destination/ using parallel multipart download with 4 threads:

        $ {command} --location=us-central1 --project=myproject --repository=myrepo             --package=mypackage --version=v0.1.0 --destination=/path/to/destination/             --name=myfile.txt --parallelism=4

    To download version v0.1.0 of myfile.txt in 8000 byte chunks located in a repository in "us-central1" to /path/to/destination/:

        $ {command} --location=us-central1 --project=myproject --repository=myrepo             --package=mypackage --version=v0.1.0 --destination=/path/to/destination/             --name=myfile.txt --chunk-size=8000

    To download all files of version v0.1.0 and package mypackage located in a repository in "us-central1" to /path/to/destination/
    while maintaining the folder hierarchy:

        $ {command} --location=us-central1 --project=myproject --repository=myrepo             --package=mypackage --version=v0.1.0 --destination=/path/to/destination/
    )�DESCRIPTION�EXAMPLESc�^�tj�j|�tj�j|�|j	dddd��|j	dddd��|j	d	d
dd��|j	dd
d��|j	ddd��y)z\Set up arguments for this command.

    Args:
      parser: An argparse.ArgumentParser.
    z
--destination�DESTINATIONTz4The path where you want to save the downloaded file.)�metavar�required�helpz	--package�ARTIFACTzThe artifact to download.z	--version�VERSIONz(The version of the artifact to download.z--name�NAMEz<If specified, the file name within the artifact to download.)rrz
--parallelism�PARALLELISMzLSpecifies the number of threads to use for downloading the file in parallel.N)r
�GetRequiredRepoFlag�AddToParser�GetChunkSize�add_argument)�parsers �)lib/surface/artifacts/generic/download.py�Argsz
Download.ArgsCs���
����+�+�F�3�	����$�$�V�,�
������
C�	��������
(�	��������
7�	�������
K���
�����
�	��c��|jjj�}tjj|j�|_tjj|j�s"tjd|jz��tjj|j�s"tjd|jz��|jrotjj|j�}dj|j|j |j�}|j#||||�yt%j&|�}|s9tj(dj|j|j ���|j+|||�y)z*Run the generic artifact download command.z&Destination directory does not exist: z Destination is not a directory: z{}:{}:{}z*No files found for package: {} version: {}N)�CONCEPTS�
repository�Parse�os�path�
expanduser�destination�exists�
ar_exceptions�DirectoryNotExistError�isdir�PathNotDirectoryError�name�basename�format�package�version�downloadGenericArtifactr	�ListGenericFiles�ArtifactRegistryError�batchDownloadFiles)�self�args�repo_ref�	file_name�file_id�
list_filess      r�RunzDownload.RunmsU���}�}�'�'�-�-�/�H��w�w�)�)�$�*:�*:�;�D��
�7�7�>�>�$�*�*�+��0�0�
2�T�5E�5E�
E�
���7�7�=�=��)�)�*��/�/�
,�t�/?�/?�
?�
���y�y��'�'�"�"�4�9�9�-�i��!�!�$�,�,����d�i�i�H�g�
�"�"�4��7�I�F��-�-�d�3�j�
��1�1�8�?�?����d�l�l�
�
�	
�
���d�H�j�9r c
���tjj|j|�}t	j
|j|j|j|�}d}|jxs|}|jxsd}	tj||j�|dt|�t|	��tj j#dj%|j��y)Ni0�Fz&Successfully downloaded the file to {})r%r&�joinr(r	�EscapeFileNameFromIDs�
projectsId�locationsId�repositoriesId�
chunk_size�parallelismrr
�RelativeName�intr�status�Printr0)
r7r8r9r;r:�
final_path�file_escaped�default_chunk_sizerErFs
          rr3z Download.downloadGenericArtifact�s��������d�.�.�	�:�J��2�2�����������	�L�)�����6�$6�J��"�"�'�a�K������!�!�#��
��J���K��
��J�J���0�7�7��8H�8H�I�r c��|D]�}tjj|j�}|j	dd�djdd�}d|vr^tjj
|�}tjtjj|j|�d��|j||||���y)N�:r?z%2F�/T)�exist_ok)r%r&r/r.�rsplit�replace�dirname�makedirsr@r(r3)r7r8r9r<�filesr;r:�ds        rr6zDownload.batchDownloadFiles�s�������� � ����,�g��.�.��a�(��+�3�3�E�3�?�i�	�	�	��G�G�O�O�I�&��
���B�G�G�L�L��!1�!1�1�5��E�
�"�"�4��7�I�F�r N)
�__name__�
__module__�__qualname__�__doc__�
detailed_help�staticmethodrr=r3r6�r rr
r
s>��
H�%���-�:�'��'�R:�:�0	Gr r
)r[�
__future__rrrr%� googlecloudsdk.api_lib.artifactsrr*�googlecloudsdk.callioper�$googlecloudsdk.command_lib.artifactsrr	r
�googlecloudsdk.corer�DefaultUniverseOnly�
ReleaseTracks�ReleaseTrack�ALPHA�BETA�GA�Commandr
r^r r�<module>rks���N�&��'�	�H�(�>�:�6�#�������������T�.�.�3�3�T�5F�5F�5I�5I��HG�t�|�|�HG���HGr