File: //lib/google-cloud-sdk/lib/googlecloudsdk/calliope/__pycache__/walker.cpython-312.pyc
�
��� � �n � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddl
Z
G d � d
e� Zy)z,A module for walking the Cloud SDK CLI tree.� )�absolute_import)�division)�unicode_literals)�Any)�
console_io)�progress_trackerNc �: � e Zd ZdZ d d�Zd� Zd
d�Zd� Zd� Zd� Z y)�Walkera= Base class for walking the Cloud SDK CLI tree.
Attributes:
_roots: The root elements of the CLI tree that will be walked.
_num_nodes: The total number of nodes in the tree.
_num_visited: The count of visited nodes so far.
_progress_callback: The progress bar function to call to update progress.
Nc �N � |j � }|r8|D �cg c] }| j ||� �� }}|D �cg c] }|s�|�� c}| _ n|g| _ d| _ |rZt j
d� 5 | j D ]+ }| xj d|j
d|�� z z
c_ �- ddd� n:| j D ]+ }| xj d|j
d|�� z z
c_ �- d| _ |xs t j | _
yc c}w c c}w # 1 sw Y �4xY w)a� Constructor.
Args:
cli: The Cloud SDK CLI object.
progress_callback: f(float), The function to call to update the progress
bar or None for no progress bar.
ignore_load_errors: bool, True to ignore command load failures. This
should only be used when it is not critical that all data is returned,
like for optimizations like static tab completion.
restrict: Restricts the walk to the command/group dotted paths in this
list. For example, restrict=['gcloud.alpha.test', 'gcloud.topic']
restricts the walk to the 'gcloud topic' and 'gcloud alpha test'
commands/groups. When provided here, any groups above the restrictions
in the tree will not be loaded or visited.
r zLoading CLI Treeg �?T)� recursive�ignore_load_errorsN)�_TopElement�_GetSubElement�_roots�
_num_nodesr �ProgressTracker�LoadAllSubElements�_num_visitedr �DefaultProgressBarCallback�_progress_callback) �self�cli�progress_callbackr
�restrict�top�r�roots�roots �%lib/googlecloudsdk/calliope/walker.py�__init__zWalker.__init__'