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: //usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/__pycache__/display.cpython-312.pyc
�

��SF��<�dZddlmZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lm
Z
ddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlZGd�dej0�ZGd�de�ZGd�de�ZGd�de�Zy)aHResource display for all calliope commands.

The print_format string passed to resource_printer.Print() is determined in this
order:
 (1) Display disabled and resources not consumed if user output is disabled.
 (2) The explicit --format flag format string.
 (3) The explicit Display() method.
 (4) The DisplayInfo format from the parser.
 (5) Otherwise no output but the resources are consumed.

Format expressions are left-to-right composable. Each format expression is a
string tuple

  < NAME [ATTRIBUTE...] (PROJECTION...) >

where only one of the three elements need be present.
�)�absolute_import)�division)�unicode_literals)�display_taps)�
exceptions)�log)�module_util)�
properties)�cache_update_ops)�resource_lex)�resource_printer)�resource_projection_spec)�resource_property)�resource_reference)�resource_transform)�
peek_iterableNc��eZdZdZy)�ErrorzBase exception for this module.N��__name__�
__module__�__qualname__�__doc__���&lib/googlecloudsdk/calliope/display.pyrr5s��'rrc��eZdZdZy)�CommandNeedsAddCacheUpdaterz(Command needs an AddCacheUpdater() call.Nrrrrrr9s��0rrc��eZdZdZy)�"CommandShouldntHaveAddCacheUpdaterz4Command has an AddCacheUpdater() call and shouldn't.Nrrrrr r =s��<rr c��eZdZdZdZdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�	Displayera�Implements the resource display method.

  Dispatches the global flags args by constructing a format string and letting
  resource_printer.Print() do the heavy lifting.

  Attributes:
    _args: The argparse.Namespace given to command.Run().
    _command: The Command object that generated the resources to display.
    _defaults: The resource format and filter default projection.
    _format: The printer format string.
    _info: The resource info or None if not registered.
    _printer: The printer object.
    _printer_is_initialized: True if self._printer has been initialized.
    _resources: The resources to display, returned by command.Run().
    _transform_uri: A transform function that returns the URI for a resource.
  )�async�filter�limitNc��||_d|_||_d|_d|_d|_d|_d|_d|_d|_	||_
|s|j�}|r|j|_tj|j|j|j ��|_|j"|_|j$|_|j(|_|jj*j-dt.j0�|_||jj*t/j4d�<y)akConstructor.

    Args:
      command: The Command object.
      args: The argparse.Namespace given to the command.Run().
      resources: The resources to display, returned by command.Run(). May be
        omitted if only GetFormat() will be called.
      display_info: The DisplayInfo object reaped from parser.AddDisplayInfo()
        in the command path.
    NF)�defaults�symbols�aliases�uri�conditionals)�_args�_cache_updater�_command�	_defaults�_default_format_used�_format�_filter�_info�_printer�_printer_is_initialized�
_resources�GetDisplayInfo�
cache_updaterr�ProjectionSpec�
transformsr)�format�flatten�_flattenr$r(�getr�TransformUri�_transform_uri�GetTypeDataName)�self�command�args�	resources�display_infos     r�__init__zDisplayer.__init__Vs���D�J��D���D�M��D�N� %�D���D�L��D�L��D�J��D�M�#(�D� ��D�O���(�(�*�l��(�6�6�d��/�>�>��>�>��)�)��&�&��d�n�
"�(�(�d�l�"�*�*�d�m�!�(�(�d�l��.�.�0�0�4�4�
�!�.�.��D��
	
�	�N�N����*�*�>�:�rc�h�|dk(rt|jdd�St|j|d�S)z�Returns the value of flag_name in args, None if it is unknown or unset.

    Args:
      flag_name: The flag name string sans leading '--'.

    Returns:
      The flag value or None if it is unknown or unset.
    r#�async_N)�getattrr,)rB�	flag_names  r�_GetFlagzDisplayer._GetFlag�s4���G���T�Z�Z��4�
0�0��4�:�:�y�$�/�/rc
��ddlm}|jtjk(ry|js�t|j|j|j|j|jf�sydtjjjj�vrOt!dj#dj%|j&j)�j+�����yt-|j.D�cgc]}|j1|���c}�ryt|j|j|jf�r!tj2|j�}�nt|j|j�r tj4|j�}n�t|j|j�r tj6|j�}n�t9dj#t;j<|j�t;j<|j&j)��dj%|j&j)�j+�����t?j@||jB�}tEjF|jH|�|_$ycc}w)z@Taps a resource Uri cache updater into self.resources if needed.r)�baseN�AddCacheUpdaterz8`{}` needs a parser.display_info.AddCacheUpdater() call.� z.Cache updater [{}] not expected for [{}] `{}`.)%�googlecloudsdk.callioperNr-r�NoCacheUpdater�
isinstancer.�
CreateCommand�
DeleteCommand�ListCommand�RestoreCommandr
�VALUES�core�lint�Getrr;�joinr,�_GetCommand�GetPath�any�_CORRUPT_FLAGSrL�AddToCacheOp�DeleteFromCacheOp�ReplaceCacheOpr r	�
GetModulePathr�	UriCacherr@r�Tapperr6)rBrN�flag�cache_update_op�taps     r�_AddUriCacheTapzDisplayer._AddUriCacheTap�s$��-����.�=�=�=�����
�
�-�-�� � �� � �����!�!�	��	�	�j�/�/�4�4�9�9�=�=�?�	?�)�F�M�M�������/�/�1�9�9�;�<�
�
�	
�

�
�D�,?�,?�@�,?�D�D�M�M�$��,?�@�A���$�-�-�$�"4�"4�d�6I�6I�!J�K�(�5�5�d�6I�6I�J�o�	�D�M�M�4�#5�#5�	6�(�:�:�4�;N�;N�O�o�	�D�M�M�4�#3�#3�	4�(�7�7��8K�8K�L�o�.�
:�
A�
A��'�'��(;�(;�<��'�'��
�
�(>�(>�(@�A��h�h�t�z�z�-�-�/�7�7�9�:��
���
 �
 ��$�2E�2E�
F�C�#�*�*�4�?�?�C�@�D�O��)As�Kc�>�|jd�syg}|jjD]o}|jd�r|j	d�}d}nd}|jdd�}|j
tj|�j�|f��q|S)z�Returns the list of --sort-by [(key, reverse)] tuples.

    Returns:
      The list of --sort-by [(key, reverse)] tuples, None if --sort-by was not
      specified. The keys are ordered from highest to lowest precedence.
    �sort_byN�~TFz[]z[0])
rLr,rl�
startswith�lstrip�replace�appendr�Lexer�Key)rB�keys�name�reverses    r�_GetSortKeyszDisplayer._GetSortKeys�s����=�=��#�
�
�D��
�
�"�"��	
����	��{�{�3�������
�\�\�$��
&�d�
�k�k�<�%�%�d�+�/�/�1�7�;�<�#��Krc�P���d��t|j��fd�|��|_y)a_AddSortByTap helper that sorts the resources by keys.

    Args:
      keys: The ordered list of parsed resource keys from highest to lowest
        precedence.
      reverse: Sort by the keys in descending order if True, otherwise
        ascending.
    c��tj||d�}	d|ksJ�|S#ttf$rt	j
|�cYSwxYw)z>Returns the value for key in r that can be compared with None.N)rr[�AssertionError�	TypeError�six�	text_type)�r�key�values   r�_GetKeyz)Displayer._SortResources.<locals>._GetKey�sO���#�#�A�s�D�1�e�$��e�|��|�����i�
(�$��}�}�U�#�#�$�s�"�$A	�A	c�<���D�cgc]}�||���
c}Scc}w)Nr)r~�kr�rts  ��r�<lambda>z*Displayer._SortResources.<locals>.<lambda>�s���d�3�d��w�q�!�}�d�3��3s�)rrvN)�sortedr6)rBrtrvr�s ` @r�_SortResourceszDisplayer._SortResources�s#���	$�����3���D�Orc�v�tj|j�sy|j�}|syd|j_g}g}d}|D]8\}}|s|}n||k7r|j
d||f�g}|}|j|��:|r|j
d||f�|D]\}}|j||��y)z-Sorts the resources using the --sort-by keys.NFr)	r�
IsListLiker6rwr,rl�insertrqr�)rB�	sort_keys�groups�
group_keys�
group_reverserrvrts        r�
_AddSortByTapzDisplayer._AddSortByTap�s����'�'����8���!�!�#�I����D�J�J���F��J��M�!���W�
��
��G�#��
�
�a�*�m�4�5��
��
������"���m�m�A�
�M�2�3� �
��g�
���$��(� rc��|j�}|sytj||j�}t	j
|j|�|_y)z5Taps a resource filter into self.resources if needed.N)�
_GetFilterr�Filtererr/rrfr6)rB�
expressionris   r�
_AddFilterTapzDisplayer._AddFilterTapsB�����"�J���
�
�
�
�D�N�N�
;�C�#�*�*�4�?�?�C�@�D�Orc�����fd�}�j�}|sy|D]Y}g}d}tj|�j�D]"}|�d}||��d}|j	|��$|r�R||��[y)zCTaps one or more resource flatteners into self.resources if needed.c�z��tj|�}tj�j|��_y)z&Helper to add one flattened slice tap.N)r�	Flattenerrrfr6)rrirBs  �r�_Slicez(Displayer._AddFlattenTap.<locals>._Slices-����"�"�3�'�c�&�,�,�T�_�_�c�B�d�orNFT)�_GetFlattenrrrrsrq)rBr�rtr�
flattened_key�slicedr�s`      r�_AddFlattenTapzDisplayer._AddFlattenTaps����C�����D������m��f��!�!�#�&�*�*�,�!��9��&�
��
��&�
�
�
�q�
!�
-���}��rc��|jd�}|�|dkrytj|�}tj|j
|�|_y)z4Taps a resource limit into self.resources if needed.r%Nr)rLr�Limiterrrfr6)rBr%ris   r�_AddLimitTapzDisplayer._AddLimitTap6sF���M�M�'�"�E��}���	��
�
�
�u�
%�C�#�*�*�4�?�?�C�@�D�Orc��|jd�}|�|dkrytj|�}tj|j
|�|_y)z4Taps a resource pager into self.resources if needed.�	page_sizeNr)rLr�Pagerrrfr6)rBr�ris   r�_AddPageTapzDisplayer._AddPageTap>sG���
�
�k�*�I���I��N��
�
�
�Y�
'�C�#�*�*�4�?�?�C�@�D�Orc��|jd�durytj|j�}t	j
|j|�|_y)z;Taps a resource Uri replacer into self.resources if needed.r*TN)rLr�UriReplacerr@rrfr6)rBris  r�_AddUriReplaceTapzDisplayer._AddUriReplaceTapFsF��
�}�}�U��4�'��
�
"�
"�4�#6�#6�
7�C�#�*�*�4�?�?�C�@�D�Orc�B�|js|jS|jj�}|s"|jjs|jSt	j
t	j|jj|jg�|��S)z6Returns the default symbols for --filter and --format.)r'r()r3r/�
GetTransformsr'rr9�CombineDefaults)rBr(s  r�_GetResourceInfoDefaultsz"Displayer._GetResourceInfoDefaultsQsz���:�:�
�^�^���j�j�&�&�(�G��4�:�:�.�.�
�^�^��#�2�2�)�9�9�
�Z�Z�
 �
 �$�.�.�1�
��	�rc�6�|jjxsdS)z~Determines the explicit format.

    Returns:
      format: The format string, '' if there is no explicit format, or None
    �)r,r;�rBs r�_GetExplicitFormatzDisplayer._GetExplicitFormat_s���:�:���"��"rc�H�t|jd�ry|jS)zxDetermines the default format.

    Returns:
      format: The format string, '' if there is an explicit Display().
    �Displayr�)�hasattrr.r1r�s r�_GetDefaultFormatzDisplayer._GetDefaultFormatgs���t�}�}�i�(�
��<�<�rc���|jd�}|�K|jr3tjdt	j
|j��|jS|S)Nr$zDisplay filter: "%s")rLr2r�infor|r})rB�flag_filters  rr�zDisplayer._GetFilterqsI���-�-��)�K���	
������'����t�|�|�)D�E�
�\�\��
�rc�D�|jd�}|�|jS|S)Nr<)rLr=)rB�flag_flattens  rr�zDisplayer._GetFlattenzs&���=�=��+�L���
�]�]��
�rc��|j�}|j�}|s|jd�duryd|_|}n
|r|dz|z}|s|S|j	�}|s|Sg}t|d��D]D\}\}}|rdnd}|j
d	jtj|�||�
���F|djdj|��
�z
}|S)zZDetermines the display format.

    Returns:
      format: The display format string.
    r*Tzvalue(.)rP�)�startz:reverser�z{name}:sort={order}{attr})ru�order�attrz:({orders})�,)�orders)r�r�rLr0rw�	enumeraterqr;r�
GetKeyNamer\)	rB�default_fmt�fmtr�r�r�rrvr�s	         r�	GetFormatzDisplayer.GetFormat�s����(�(�*�K�
�
!�
!�
#�C��
���u�	��	%��"&�d���c�	�"
�#���#�c��
�j��!�!�#�I��
�j��F�!*�9�A�!>���~��W�"�Z��d��m�m�
%�
,�
,��*�*�3�/�u�4�-���"?��=���s�x�x��'7��8�8�C��Jrc�h�|jryd|_|j�|_|j�|_|jrhtj|j|jtj��|_	|jr|jj|_yyy)z2Initializes the printer and associated attributes.NT)r'�out)r5r�r1r�r/r
�Printerrr�r4�column_attributesr�s r�_InitPrinterzDisplayer._InitPrinter�s����#�#��#'�D� ��>�>�#�D�L��2�2�4�D�N��|�|�&�.�.�
�,�,����S�W�W��d�m�
������8�8���
�	rc��|j�tj|j�|j|j
��S)z7Returns the set of key names referenced by the command.)�
filter_string�printerr')r�r�GetReferencedKeyNamesr�r4r/r�s rr�zDisplayer.GetReferencedKeyNames�s9�������3�3��o�o�'��
�
�����rc���|j�|j�|j�|j�|j	�|j�|j
�y)a!Adds each of the standard display taps, if needed.

    The taps must be included in this order in order to generate the correct
    results. For example, limiting should not happen until after filtering is
    complete, and pagination should only happen on the fully trimmed results.
    N)rjr�r�r�r�r�r�r�s r�_AddDisplayTapszDisplayer._AddDisplayTaps�sX��	���������������������������rc�f�tj�sUtjd�tj|j
�rt
|j
�S|j
S|j�|j�d}|jr`tjd|j�|jj|j
�|jj�}n[t|jd�rEtjd�|jj|j |j
�tj"j%�|j j'd�s|jj)|�|j
S)zThe default display method.zDisplay disabled.TzDisplay format: "%s"r�zExplicit Display.r;)r�IsUserOutputEnabledr�rr�r6�listr�r�r4r1�Print�ResourcesWerePrintedr�r.r�r,r��flush�IsSpecified�Epilog)rB�resources_were_displayeds  rr�zDisplayer.Display�s$���"�"�$�	�h�h�"�#�

�	%�	%�d�o�o�	6��D�O�O�$�$�
�_�_��	��������#���}�}�	�h�h�%�t�|�|�4�
�m�m���$�/�/�*�!%���!C�!C�!E��	����	�	*�	�h�h�"�#�
�m�m���D�J�J����8��G�G�M�M�O��:�:�!�!�(�+�
�m�m���3�4��?�?�r)NN)rrrrr`rGrLrjrwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr"r"As����$0�.�(
�T
0�1A�f�,�6)�@A��6A�A�	A��#����5�n9�*�
�$rr")r�
__future__rrrrQr�googlecloudsdk.corerrr	r
�googlecloudsdk.core.cacher�googlecloudsdk.core.resourcerr
rrrr�googlecloudsdk.core.utilrr|rrr �objectr"rrr�<module>r�sw���$'��'�0�*�#�+�*�6�5�9�A�:�;�;�2�
�(�J���(�1�%�1�=��=�H��Hr