File: //lib/google-cloud-sdk/lib/surface/storage/__pycache__/ls.cpython-312.pyc
�
��D* � �� � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m
Z
ddl mZ dd l mZ dd
l m
Z
ddl mZ ddl mZ dd
l mZ ddlmZ dZdZdZej, ej. ej0 j2 � G d� dej4 � � � Zej, ej. ej0 j8 � G d� de� � � Zy)z(Command to list Cloud Storage resources.� )�absolute_import)�division)�unicode_literals)� cloud_api)�base)�encryption_util)�errors)�flags)� list_util)�ls_command_util)�stdin_iterator)�storage_url)�logz�
List your Cloud Storage buckets in a project and objects in a bucket.
This command treats forward slashes in object names as directories. See
below for examples of how to use wildcards to get the listing behavior
you want.
a�
The following command lists the buckets in the default project:
$ {command}
The following command lists the buckets in the specified project:
$ {command} --project=my-project
The following command lists the contents of a bucket:
$ {command} gs://my-bucket
You can use [wildcards](https://cloud.google.com/storage/docs/wildcards)
to match multiple paths (including multiple buckets). Bucket wildcards are
expanded to match only buckets contained in your current project. The
following command matches ``.txt'' objects that begin with ``log'' and
that are stored in buckets in your project that begin with ``my-b'':
$ {command} gs://my-b*/log*.txt
You can use double-star wildcards to match zero or more directory levels
in a path. The following command matches all ``.txt'' objects in a bucket.
$ {command} gs://my-bucket/**/*.txt
The wildcard `**` retrieves a flat list of objects in a single API call
and does not match prefixes. The following command would not match
`gs://my-bucket/dir/log.txt`:
$ {command} gs://my-bucket/**/dir
Double-star expansion also can not be combined with other expressions in a
given path segment and operates as a single star in that context. For
example, the command `gs://my-bucket/dir**/log.txt` is treated as
`gs://my-bucket/dir*/log.txt`. To get the recursive behavior, the command
should instead be written the following way:
gs://my-bucket/dir*/**/log.txt
The following command lists all items recursively with formatting by
using `--recursive`:
$ {command} --recursive gs://bucket
Recursive listings are similar to `**` except recursive listings include
line breaks and header formatting for each subdirectory.
ao
The following command filters objects based on specified filter while listing.
Note that the flag is only supported for Google Cloud Storage URLs and only
applies to objects. This means that directories or buckets will still be listed
even if they do not contain objects that match the filter.
$ {command} gs://my-bucket --metadata-filter='contexts."foo"="bar"'
c �@ � e Zd ZdZeed�Zed� � Zed� � Z d� Z
y)�Ls�'List Cloud Storage buckets and objects.��DESCRIPTION�EXAMPLESc �" � |j ddd�� |j dddd� � |j d
ddd� � |j d
ddd� � |j dd�� |j ddd� � |j ddddd� � |j d�� }|j dddd� � |j dddd � � |j d!d"dd#� � t j |� t j |d$�%� t j
|d$�&� t j |� t j |� | j � t j j k( rt j |� y'y')(z-Edit argparse.ArgumentParser for the command.�path�*zzThe path of objects and directories to list. The path must begin with gs:// and is allowed to contain wildcard characters.)�nargs�helpz-az--all-versions�
store_truea Include noncurrent object versions in the listing. This flag is typically only useful for buckets with [object versioning](https://cloud.google.com/storage/docs/object-versioning) enabled. If combined with the `--long` option, the metageneration for each listed object is also included.)�actionr z-bz --bucketsz�When given a bucket URL, only return buckets. Useful for avoiding the rule that prints the top-level objects of buckets matching a query. Typically used in combination with `--full` to get the full metadata of buckets.z-ez--etagz=Include ETag metadata in listings that use the `--long` flag.z--formatz�Use "gsutil" to get the style of the older gsutil CLI. (e.g. "--format=gsutil"). Other format values (e.g. "json") do not work. See different ls flags and commands for alternative formatting.)r z--readable-sizeszgWhen used with `--long`, print object sizes in human readable format, such as 1 KiB, 234 MiB, or 2 GiB.z-Rz-rz--recursivezPRecursively list the contents of any directories that match the path expression.�True)�mutexz-lz--longz=For objects only. List size in bytes, creation time, and URL.z-Lz--fullz0List all available metadata about items in rows.z-jz--jsonz7List all available metadata about items as a JSON dump.T)�command_only_reads_data)�is_listN)�add_argument� add_groupr
�add_additional_headers_flag�add_encryption_flags�&add_fetch_encrypted_object_hashes_flag�add_read_paths_from_stdin_flag�add_soft_delete_flags�ReleaseTrackr �ALPHA�add_metadata_filter_flag)�cls�parser�
output_styless �lib/surface/storage/ls.py�ArgszLs.Argso s� � � �����
I� � � ������
8� � � ������
)� �
� ������
L� � � ����
� � � �����
B� � � �������
�
� � �$�$�6�$�2�M�������
L� � � ������
?� � � ������
F� � �
�%�%�f�-� ���v�t�D� �0�0���F� �(�(��0� ����'�
����T�.�.�4�4�4��$�$�V�,� 5� c �Z � t |dd� }t |dd� }t |dd� }|||fS )zGet the args for the command.�soft_deletedF�all_versions�buckets)�getattr)r+ �argsr2 r3 r4 s r. � _get_argszLs._get_args� s; � � �4���7�L��4���7�L��d�I�u�-�G���w�.�.r0 c �� � t j |� | j |� \ }}}|r|rt j d� |r|rt j d� t j |� }d}|j s|j r-t j |j |j d�� }nt j j dz g}t |dd� }|D � cg c] } t j | � �� }
} |
D ]� }t# |t j$ � s.t'