
    k                     ^   S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKrSSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSK!J"r"  SSK!J#r#  SSK!J$r$  SSK%r%Sr&Sr' " S S\(5      r) " S S\(5      r*S/S jr+S r, " S  S!\(5      r- " S" S#\R\                  5      r/\R`                  " \'S\/S$S%S&9r1 " S' S(\(5      r2 " S) S*\Rf                  5      r4S+ r5S/S, jr6 " S- S.\(5      r7g)0zDThe calliope CLI/API is a framework for building library interfaces.    )absolute_import)division)unicode_literalsN)actions)backend)base)command_loading)
exceptions)parser_errors)parser_extensions)
argv_utils)config)log)metrics)
properties)yaml)named_configs)console_attr)encoding)files)pkg_resourcesz.pyz---flag-file-line-c                   $    \ rS rSrSrS rS rSrg)_FlagLocation9   z&--flags-file (file,line_col) location.c                 8    Xl         UR                  S-   U l        g )N   	file_nameline)selfr   line_cols      "lib/googlecloudsdk/calliope/cli.py__init___FlagLocation.__init__<   s    N!DI    c                 N    SR                  U R                  U R                  5      $ )Nz{}:{})formatr   r   r    s    r"   __str___FlagLocation.__str__@   s    >>$..$))44r%   r   N)__name__
__module____qualname____firstlineno____doc__r#   r)   __static_attributes__ r%   r"   r   r   9   s    ."5r%   r   c                   .    \ rS rSrSrSS jrS rS rSrg)	_ArgLocationsD   z"--flags-file (arg,locations) info.Nc                     Xl         U(       a  UR                  S S  O/ U l        U R                  R                  [        X#5      5        g N)arg	locationsappendr   )r    r7   r   r!   r8   s        r"   r#   _ArgLocations.__init__G   s4    H/8Y((+bDNNN-	<=r%   c                     SR                  U R                   Vs/ s H  n[        R                  " U5      PM     sn5      $ s  snf )N;)joinr8   six	text_type)r    locations     r"   r)   _ArgLocations.__str__L   s0    88T^^L^S]]8,^LMMLs    Ac                 p    [        U R                   Vs/ s H  o!UR                  :H  PM     sn5      $ s  snf )z4Returns True if file_name is in the locations stack.)anyr8   r   )r    r   xs      r"   FileInStack_ArgLocations.FileInStackO   s*    $..A.QQ[[(.ABBAs   3)r7   r8   r6   )	r+   r,   r-   r.   r/   r#   r)   rE   r0   r1   r%   r"   r3   r3   D   s    *>
NCr%   r3   c           
         [         R                  R                  nU(       a;  UR                  U5      (       a%  [        R
                  " SR                  X25      5      eUS:X  a  [        R                  R                  5       nO_[        R                  R                  U5      (       d%  [        R
                  " SR                  X15      5      e[        R                  " U5      nU(       d%  [        R
                  " SR                  X15      5      e[        R                   " USS9n[#        U[$        5      (       a  UOU/nU GH  n[#        UR&                  [(        5      (       d=  [        R
                  " SR                  XR*                  R,                  S-   U5      5      e[.        R0                  " UR&                  5       GH8  u  pU	R*                  n
[        R2                  " U	5      nX:X  a[  [#        U	R&                  [$        5      (       a  U	R&                  OU	R&                  /nU H  n[5        XX5      n[7        XU5        M     M  [#        U[9        S	5      [:        45      (       a  S
nO1[#        U[$        [(        45      (       a  SnOS
nSR                  X5      nU R=                  [>        5        U R=                  [5        XX5      5        U R=                  U5        U(       d  GM'  U R=                  U5        GM;     GM     g	)z2Recursively append the flags file flags to inject.z{} recursive reference ({}).-z{} [{}] not found.z{} [{}] is empty.T)location_valuezJ{}:{}: {} file must contain a dictionary or list of dictionaries of flags.r   NFz{}={}) calliope_baseFLAGS_FILE_FLAGnamerE   r   ArgumentErrorr'   sysstdinreadospathexistsr   ReadFileContentsr   load
isinstancelistvaluedictlcr   r>   	iteritemsstrip_locationsr3   _AddFlagsFileFlagstypeboolr9   _FLAG_FILE_LINE_NAME)inject
flags_fileparent_locationsflagcontentsdatagroupmemberr7   objr!   rX   	file_listrR   r8   separate_value_args                   r"   r]   r]   T   sK    
	&	&	+	+$*66zBB

%
%&--dEG G 3yy~~H77>>*%%

%
%##D57 7 %%j1H	

%
%""446 6	8D	1$T4(($tf% ffllD))''fZ!);TBD D MM&,,/h""3'e	!+CIIt!<!<CII399+	D#CXP)
V9
5  		EDJ-	.	."edD\**!"nnS(mm()mmM#8NOmmC		 	e5 0 r%   c                    [         R                  R                  nUS-   n[        U  Vs/ s H  o3U:H  =(       d    UR	                  U5      PM!     sn5      (       d  U $ Sn/ nU  Hb  nU(       a  Sn[        XS5        M  X1:X  a  SnM"  UR	                  U5      (       a  [        XS[        U5      S 5        MQ  UR                  U5        Md     U$ s  snf )a  Applies FLAGS_FILE_FLAG in args and returns the new args.

The basic algorithm is arg list manipulation, done before ArgParse is called.
This function reaps all FLAGS_FILE_FLAG args from the command line, and
recursively from the flags files, and inserts them into a new args list by
replacing the --flags-file=YAML-FILE flag by its constituent flags. This
preserves the left-to-right precedence of the argument parser. Internal
_FLAG_FILE_LINE_NAME flags are also inserted into args. This specifies the
flags source file and line number for each flags file flag, and is used to
construct actionable error messages.

Args:
  args: The original args list.

Returns:
  A new args list with all FLAGS_FILE_FLAG args replaced by their constituent
  flags.
=FTN)rJ   rK   rL   rC   
startswithr]   lenr9   )argsrd   flag_eqr7   peeknew_argss         r"   _ApplyFlagsFilert      s    & 
	&	&	+	+$3J'	ETk4S^^G44E	F	FK 
$(cd'	d		 	 s7|}#56ooc  
/% Fs   &Cc                   (    \ rS rSrSrSS jrS rSrg)RunHook   zEncapsulates a function to be run before or after command execution.

The function should take **kwargs so that more things can be passed to the
functions in the future.
Nc                 <    Xl         U(       a  UOSU l        X0l        g)a2  Constructs the hook.

Args:
  func: function, The function to run.
  include_commands: str, A regex for the command paths to run.  If not
    provided, the hook will be run for all commands.
  exclude_commands: str, A regex for the command paths to exclude.  If not
    provided, nothing will be excluded.
z.*N)_RunHook__func_RunHook__include_commands_RunHook__exclude_commands)r    funcinclude_commandsexclude_commandss       r"   r#   RunHook.__init__   s     K2B.D.r%   c                     [         R                  " U R                  U5      (       d  gU R                  (       a'  [         R                  " U R                  U5      (       a  gU R	                  US9  g)zRuns this hook if the filters match the given command.

Args:
  command_path: str, The calliope command path for the command that was run.

Returns:
  bool, True if the hook was run, False if it did not match.
F)command_pathT)rematchrz   r{   ry   )r    r   s     r"   RunRunHook.Run   sV     88D++\::288D,C,C,8$: $:KK\K*r%   )__exclude_commands__func__include_commandsNN)r+   r,   r-   r.   r/   r#   r   r0   r1   r%   r"   rv   rv      s    /r%   rv   c                   "    \ rS rSrSrSS jrSrg)_SetFlagsFileLine   z$FLAG_INTERNAL_FLAG_FILE_LINE action.Nc                     [        US5      (       d%  [        US[        R                  " [        5      5        UR
                  UR                     R                  [        R                  " U5      5        g )Nflags_locations)
hasattrsetattrcollectionsdefaultdictsetr   r7   addr>   r?   )r    parser	namespacevaluesoption_strings        r"   __call___SetFlagsFileLine.__call__   sN    6,--f')@)@)EF
6::&**3==+@Ar%   r1   r6   )r+   r,   r-   r.   r/   r   r0   r1   r%   r"   r   r      s    ,Br%   r   Tz;Internal *--flags-file* flag, line number, and source file.defaultactionhiddenhelpc                       \ rS rSrSr\R                  " S5      r   SS jr\	S 5       r
SS jrSS jrS	 rS
 r SS jr SS jrS rS rS r SS jrS rS rSrg)	CLILoader   zBA class to encapsulate loading the CLI and bootstrapping the REPL.z(?:([\w\.]+)\.)?([^\.]+)Nc                 x   Xl         X l        U R                  (       d  [        R                  " S5      eX0l        U=(       d    [
        R                  " 5       R                  U l        XPl	        X`l
        Xpl        / U l        / U l        / U l        [        R                   " ["        5      U l        0 U l        0 U l        g)a  Initialize Calliope.

Args:
  name: str, The name of the top level command, used for nice error
    reporting.
  command_root_directory: str, The path to the directory containing the main
    CLI module.
  allow_non_existing_modules: True to allow extra module directories to not
    exist, False to raise an exception if a module does not exist.
  logs_dir: str, The path to the root directory to store logs in, or None
    for no log files.
  version_func: func, A function to call for a top-level -v and
    --version flag. If None, no flags will be available.
  known_error_handler: f(x)->None, A function to call when an known error is
    handled. It takes a single argument that is the exception.
  yaml_command_translator: YamlCommandTranslator, An instance of a
    translator that will be used to load commands written as a yaml spec.

Raises:
  backend.LayoutException: If no command root directory is given.
z*You must specify a command root directory.N)_CLILoader__name"_CLILoader__command_root_directoryr	   LayoutException&_CLILoader__allow_non_existing_modulesr   Pathslogs_dir_CLILoader__logs_dir_CLILoader__version_func_CLILoader__known_error_handler#_CLILoader__yaml_command_translator_CLILoader__pre_run_hooks_CLILoader__post_run_hooks_CLILoader__modulesr   r   rW   _CLILoader__modules_by_parent_CLILoader__missing_components_CLILoader__release_tracks)r    rL   command_root_directoryallow_non_existing_modulesr   version_funcknown_error_handleryaml_command_translators           r"   r#   CLILoader.__init__   s    2 K$:!((++
68 8 )C%9&,,."9"9DO&!4%<"DDDN*66t<D "DDr%   c                     U R                   $ r6   )r   r(   s    r"   r   !CLILoader.yaml_command_translator*  s    )))r%   c                 \    UR                   (       d  [        S5      eX#4U R                  U'   g)a  Adds a release track to this CLI tool.

A release track (like alpha, beta...) will appear as a subgroup under the
main entry point of the tool.  All groups and commands will be replicated
under each registered release track.  You can implement your commands to
behave differently based on how they are called.

Args:
  release_track: base.ReleaseTrack, The release track you are adding.
  path: str, The full path the directory containing the root of this group.
  component: str, The name of the component this release track is in, if
    you want calliope to auto install it for users.

Raises:
  ValueError: If an invalid track is registered.
zLYou may only register alternate release tracks that have a different prefix.N)prefix
ValueErrorr   )r    release_trackrR   	components       r"   AddReleaseTrackCLILoader.AddReleaseTrack.  s2    "  2 3 3,0+<D-(r%   c                 >    U R                   R                  XU45        g)a  Adds a module to this CLI tool.

If you are making a CLI that has subgroups, use this to add in more
directories of commands.

Args:
  name: str, The name of the group to create under the main CLI.  If this is
    to be placed under another group, a dotted name can be used.
  path: str, The full path the directory containing the commands for this
    group.
  component: str, The name of the component this command module is in, if
    you want calliope to auto install it for users.
N)r   r9   )r    rL   rR   r   s       r"   	AddModuleCLILoader.AddModuleD  s     	NN4y12r%   c                     U R                   $ )z'Returns modules added to this CLI tool.)r   r(   s    r"   
GetModulesCLILoader.GetModulesT  s    >>r%   c                     U R                   $ )zReturns info about added modules (if any) for each parent command group.

Returns:
  {str: [(str, bool, str)]}, Mapping of parent group to list of
    (module_name, module_is_command, module_impl_path) tuples for each
    additional module.
)r   r(   s    r"   GetModulesByParentCLILoader.GetModulesByParentX  s     ###r%   c                 R    [        XU5      nU R                  R                  U5        g)at  Register a function to be run before command execution.

Args:
  func: function, The function to run.  See RunHook for more details.
  include_commands: str, A regex for the command paths to run.  If not
    provided, the hook will be run for all commands.
  exclude_commands: str, A regex for the command paths to exclude.  If not
    provided, nothing will be excluded.
N)rv   r   r9   r    r|   r}   r~   hooks        r"   RegisterPreRunHookCLILoader.RegisterPreRunHookb  s%     4+;<D%r%   c                 R    [        XU5      nU R                  R                  U5        g)as  Register a function to be run after command execution.

Args:
  func: function, The function to run.  See RunHook for more details.
  include_commands: str, A regex for the command paths to run.  If not
    provided, the hook will be run for all commands.
  exclude_commands: str, A regex for the command paths to exclude.  If not
    provided, nothing will be excluded.
N)rv   r   r9   r   s        r"   RegisterPostRunHookCLILoader.RegisterPostRunHookp  s%     4+;<D  &r%   c                     SR                  U5      n[        R                  " U R                  5       VVs/ s H'  u  p4X#:X  d  UR	                  US-   5      (       d  M%  UPM)     snn$ s  snnf )zGets the components that need to be installed to run the given command.

Args:
  command_path: [str], The path of the command being run.

Returns:
  [str], The component names of the components that should be installed.
.)r=   r>   r[   r   rn   )r    r   path_stringrR   r   s        r"   ComponentsForMissingCommand%CLILoader.ComponentsForMissingCommand~  sc     ((<(K#&==1J1J#KJ#K"k&<&<TCZ&H #KJ J Js   $A'A'c                    [        U5      S:  a  / $ [        R                  R                  US   5      nU(       a  X R                  ;  a  SnUS   nU(       a  USS OUSS nU(       d  / $ [        5       nU R                   H  nU/UR                  /-   U-   XV'   M     U(       a#  XR	 U/U-   U[        R                  R                  '   U$ )a  Finds other release tracks this command could be in.

The returned values are not necessarily guaranteed to exist because the
commands could be disabled for that particular release track.  It is up to
the caller to determine if the commands actually exist before attempting
use.

Args:
  command_path: [str], The path of the command being run.

Returns:
  {ReleaseTrack: [str]}, A mapping of release track to command path of other
  places this command could be found.
   r   Nr   )ro   rJ   ReleaseTrack
FromPrefixr   rY   r   GA)r    r   trackrootsub_pathresultsts          r"   %ReplicateCommandPathForAllOtherTracks/CLILoader.ReplicateCommandPathForAllOtherTracks  s      <1i &&11,q/BE333e ?D#(|ABl12.>HifG""6QXXJ&1gj #  .04v/@gm((++,Nr%   c           	      j   U R                    GH  u  pnUR                  [        5      nU(       a  US[        [        5      *  n[        R
                  R                  U5      nUR                  SS5      u  pgU R                  UU R                  S9n[        R                  R                  /U R                  Q H  n	U(       a|  SR                  U R                  /U	R                   (       a  U	R                   /O/ -   U(       a  UR#                  SS5      /O/ -   5      n
U R$                  U
   R'                  XtU45        M  U(       d  M  SR                  U R                  /U	R                   (       a  U	R                   /O/ -   UR#                  SS5      /-   5      nX0R(                  U'   M     GM     U R                  U R*                  SS9n[,        R.                  " U/U R                  /[        R                  R                  [0        R2                  " 5       R4                  U S5      nU R7                  U5        [9        S	 U R                  R;                  5        5       5      n[<        R>                  " U R                  5       H  u  n	u  pU R                  UU R                  S9nU(       aF  U/UR@                  U	R                   '   URC                  U	R                   S
U	S9nURE                  XS9  Mo  U(       d  Mx  X0R(                  U R                   SU	R                    3'   M     U RG                  U5      nU$ )zcUses the registered information to generate the CLI tool.

Returns:
  CLI, The generated CLI tool.
Nr   r   )r   r   _rH   Fc              3   8   #    U  H  oR                   v   M     g 7fr6   )r   ).0r   s     r"   	<genexpr>%CLILoader.Generate.<locals>.<genexpr>  s     M0Lull0Ls   T)allow_emptyrelease_track_override)ignore)$r   endswith_COMMAND_SUFFIXro   r   PATH_REr   rg   &_CLILoader__ValidateCommandOrGroupInfor   rJ   r   r   r   r=   r   r   replacer   r9   r   r   r   CommandGroupuuiduuid4hex!_CLILoader__AddBuiltinGlobalFlagsr   keysr>   r[   _groups_to_loadLoadSubElementCopyAllSubElementsTo_CLILoader__MakeCLI)r    module_dot_pathmodule_dir_pathr   
is_commandr   r   cmd_or_grp_name	impl_pathr   parent_group_name
group_name	top_grouptrack_names
module_dirtrack_groupclis                    r"   GenerateCLILoader.Generate  s    8<~~3)"++O<j	)*@C,@+@A%%o6e#kk!Q/d33
%)%F%F 4 Hi "..11JD4I4IJ%!hh{{m~2F+/S#&'R9:
 
"
"#4
5
<
<I68Yxx{{m~2F&&sC0123* 3<
#
#J
/ K 8F0 11%%% 2 II$$	dkk]M$>$>$A$A

$&I 	  + M0E0E0J0J0LMMK*---8M8M*N&&
33
%)%F%F 4 Hi 
 4=+	!!%,,/  ..LLd5 / J 	&&{&G9EN!!T[[M5<<."AB +O" ..
#CJr%   c                     [         R                  R                  U5      u  p4[        R                  " XC5      (       d-  U(       a  g[
        R                  " SR                  U5      5      eU$ )a  Generates the information necessary to be able to load a command group.

The group might actually be loaded now if it is the root of the SDK, or the
information might be saved for later if it is to be lazy loaded.

Args:
  impl_path: str, The file path to the command implementation for this
    command or group.
  allow_non_existing_modules: True to allow this module directory to not
    exist, False to raise an exception if this module does not exist.

Raises:
  LayoutException: If the module directory does not exist and
  allow_non_existing is False.

Returns:
  impl_path or None if the module directory does not exist and
  allow_non_existing is True.
Nz.The given module directory does not exist: {0})rQ   rR   splitr   IsImportabler	   r   r'   )r    r  r   module_rootmodules        r"   __ValidateCommandOrGroupInfo&CLILoader.__ValidateCommandOrGroupInfo  s\    * ''--	2K%%f::	#++
:
A
A  r%   c           
      X   [         R                  R                  UR                  5        [         R                  R                  UR                  5        [         R
                  R                  UR                  5        U R                  bJ  UR                  R                  SSS[         R                  [        R                  " U R                  5      SS9  UR                  R                  SS[         R                  S	R                  [        R                  5      S
9  UR                  R                  S[        R                  " 5       [        R                   [         R                  S[        R"                  " [$        R&                  R(                  R*                  5      S9  UR                  R                  SS[        R,                  " [$        R&                  R(                  R.                  5      SS9  UR                  R                  SS[        R,                  " [$        R&                  R(                  R0                  5      SS9  UR                  R                  SS[        R"                  " [$        R&                  R2                  R4                  5      SSS9  UR                  R                  SS[        R"                  " [$        R&                  R2                  R6                  5      SSS9  UR                  R                  S[        R"                  " [$        R&                  R2                  R8                  5      SSS9  UR                  R                  SS[        R"                  " [$        R&                  R(                  R:                  5      SSS9  [<        R                  UR                  5        g)a/  Adds in calliope builtin global flags.

This needs to happen immediately after the top group is loaded and before
any other groups are loaded.  The flags must be present so when sub groups
are loaded, the flags propagate down.

Args:
  top_element: backend._CommandCommon, The root of the command tree.
Nz-vz	--versionTzTPrint version information and exit. This flag is only available at the global level.)do_not_propagatecategoryr   r   z--configurationCONFIGURATIONa+          File name of the configuration to use for this command invocation.
        For more information on how to use configurations, run:
        `gcloud topic configurations`.  You can also use the {0} environment
        variable to set the equivalent of this flag for a terminal
        session.)metavarr  r   z--verbosityz0Override the default verbosity for this command.)choicesr   r  r   r   z--user-output-enabledz*Print user intended output to the console.)r   r   r   z
--log-httpz5Log all HTTP server requests and responses to stderr.z--authority-selectorzTHIS ARGUMENT NEEDS HELP TEXT.r   z--authorization-token-filez--credential-file-override)r   r   r   z--http-timeout)rJ   rK   AddToParseraiFLATTEN_FLAGFORMAT_FLAGr   add_argumentCOMMONLY_USED_FLAGSr   FunctionExitActionr'   r   CLOUDSDK_ACTIVE_CONFIG_NAMEr   OrderedVerbosityNamesDEFAULT_VERBOSITY_STRINGStorePropertyr   VALUEScore	verbosityStoreBooleanPropertyuser_output_enabledlog_httpauthauthority_selectorauthorization_token_filecredential_file_overridehttp_timeoutFLAG_INTERNAL_FLAG_FILE_LINE)r    top_elements     r"   __AddBuiltinGlobalFlags!CLILoader.__AddBuiltinGlobalFlags  s    !!--knn=**;>>:))+..9&nn!!
 44++D,?,?@" " # NN22
 F6==>   	@ NN))+,,22?$$Z%6%6%;%;%E%EF   H NN++""66
 :    NN++J,=,=,B,B,K,KLD	   F NN$$Z%6%6%;%;%N%NO-   / NN$$$"";;=-   / NN$$$"";;=-   / NN$$Z%6%6%;%;%H%HI-   / !,,[^^<r%   c                 P   S[         R                  ;  d  S[         R                  ;   a  [        R                  " U R                  5        [
        R                  " [         R                  S5      nU(       a5  [        R                  R                  U5      n[        R                  " U5        [        R                  R                  R                  R                  5       (       a  UR                  SS9  [!        U R"                  XR$                  U R&                  U R(                  5      nU$ )zGenerate a CLI object from the given data.

Args:
  top_element: The top element of the command tree
    (that extends backend.CommandCommon).

Returns:
  CLI, The generated CLI tool.
_ARGCOMPLETE_ARGCOMPLETE_TRACET)	recursive)rQ   environr   AddFileLoggingr   r   GetEncodedValueVALID_VERBOSITY_STRINGSgetSetVerbosityr   r#  r$  disable_command_lazy_loadingGetBoolLoadAllSubElementsCLIr   r   r   r   )r    r/  verbosity_stringr%  r  s        r"   	__MakeCLICLILoader.__MakeCLIo  s     RZZ'+?2::+M	)!11"**2FH	//334DE	# ::BBDD$$t$4
dkk;(<(<##T%?%?ACJr%   )__allow_non_existing_modules__command_root_directory__known_error_handler
__logs_dir__missing_components	__modules__modules_by_parent__name__post_run_hooks__pre_run_hooks__release_tracks__version_func__yaml_command_translator)FNNNNr6   r   )F)r+   r,   r-   r.   r/   r   compiler   r#   propertyr   r   r   r   r   r   r   r   r   r	  r   r   r   r0   r1   r%   r"   r   r      s    J JJ23' ;?6:'+,\ * *=,3 $ BF& CG'J-^:z 38<X=tr%   r   c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )_CompletionFinderi  zCalliope overrides for argcomplete.CompletionFinder.

This makes calliope ArgumentInterceptor and actions objects visible to the
argcomplete monkeypatcher.
c                    > U R                   nUR                  U l         [        [        U ]  5       nU(       a  Xl         U$ r6   )_parserr   superrS  _patch_argument_parser)r    r  active_parsers	__class__s      r"   rW  (_CompletionFinder._patch_argument_parser  s5    	B99DL,dJLN	lr%   c                 2   U R                  5       n[        R                  " 5       nSU l         U R                  R                  USS  US9  SU l        U R                  XVUS 5      nU R                  U5      nU R                  XsU5      $ ! [         a     NJf = f)NTr   )r   Fc                      g r6   r1   )r   s    r"   <lambda>4_CompletionFinder._get_completions.<locals>.<lambda>  s    dr%   )
rW  r   	Namespace
completingrU  parse_known_argsBaseExceptioncollect_completionsfilter_completionsquote_completions)r    
comp_wordscword_prefixcword_prequotelast_wordbreak_posrX  parsed_argscompletionss           r"   _get_completions"_CompletionFinder._get_completions  s    002N#--/KDO
ll##JqrNk#J DO**\?DK))+6K!!%79 9  
s   B	 	
BBc           	      (   SnSnSnSnSnU(       d!  U(       a  U V	s/ s H
  oUS-   S PM     nn	Un
OUS:X  a  Un
OUn
[         R                  " [        R                  S	5      U;   a  S
n
O)US:X  a#  S
n
U V	s/ s H  oR	                  SS5      PM     nn	U
 H'  nU V	s/ s H  oR	                  USU-   5      PM     nn	M)     [        U SS5      (       a1  Un[        U5      S:X  a   US   S   U;  a  U(       d  US==   S-  ss'   U$ s  sn	f s  sn	f s  sn	f )aS  Returns the completion (less aggressively) quoted for the shell.

If the word under the cursor started with a quote (as indicated by a
nonempty ``cword_prequote``), escapes occurrences of that quote character
in the completions, and adds the quote to the beginning of each completion.
Otherwise, escapes *most* characters that bash splits words on
(``COMP_WORDBREAKS``), and removes portions of completions before the first
colon if (``COMP_WORDBREAKS``) contains a colon.

If there is only one completion, and it doesn't end with a
**continuation character** (``/``, ``:``, or ``=``), adds a space after
the completion.

Args:
  completions: The current completion strings.
  cword_prequote: The current quote character in progress, '' if none.
  last_wordbreak_pos: The index of the last wordbreak.

Returns:
  The completions quoted for the shell.
z\();<>|&$* 	
`"'z\`"$\z=/:)tcshfishzshr   N"_ARGCOMPLETE_SHELL 'z'\''append_spaceFr    )r   r8  rQ   r6  r   getattrro   )r    rk  rh  ri  no_quote_specialdouble_quote_specialsingle_quote_specialcontinuation_specialno_escaping_shellscspecial_charscharcontinuation_charss                r"   re  #_CompletionFinder.quote_completions  sC   4 ." 0
  
;FG;a+a/01;G&m	3	*m*m

 469KL m	3	 m6ABkYYsG,kkB;FG;aYYtTD[1;kGk  t^U++ 0	[	Q	;q>"#5=O#O
a.C
.? H C Hs   D6D
D)rU  r`  )
r+   r,   r-   r.   r/   rW  rl  re  r0   __classcell__)rY  s   @r"   rS  rS    s    9(G Gr%   rS  c                    S[         R                  ;  a  gSnSn [        R                  R                  n[
        R                  [        R                  l        S[         R                  ;   a  [        R                  nS nU[        l        [        5       nU" U 4SS0UD6  U(       a  U[        R                  l        U(       a  U[        l        gg! U(       a  U[        R                  l        U(       a  U[        l        f f = f)zARuns argcomplete.autocomplete on a calliope argument interceptor.r3  Nr4  c                      g r6   r1   r1   r%   r"   _DisableMuteStderr(_ArgComplete.<locals>._DisableMuteStderr
  s    r%   always_complete_optionsF)rQ   r6  argcompleteargparser_  r   mute_stderrrS  )r  kwargsr  r   r  	completers         r"   _ArgCompleter    s    2::%
+), $$..I%6%@%@K" rzz)++k !3k!#I
 % 
 '0k$ +k  '0k$ +k s   BC 1D c                 .   AUS   nUSS nU R                   [        R                  La  [        X R                   U5         U R                  U   nUR                  Xb5      u  p&U(       aS  [        U5      R                  [        R                  / 5        [        U[        R                  5      R                  U5        gg! [
         aM    USR                  U R                  5      4n[        R                  " SU-  5      n[        R                  " X5      ef = f)z>argparse._SubParsersAction.__call__ version 1.2.1 MonkeyPatch.r   r   Nz, zunknown parser %r (choices: %s))destr  SUPPRESSr   _name_parser_mapKeyErrorr=   r   rM   ra  vars
setdefault_UNRECOGNIZED_ARGS_ATTRrz  extend)	r    r   r   r   r   parser_namearg_stringstupmsgs	            r"   _SubParsersActionCallr    s     q	+qr
+ 
YYh'''Iyy+.,"";/F "22;J)Ox??DIx778??L  
 ,
tyy!6!67
7C
**6<
=C

 
 
++,s    B= =ADc                   Z    \ rS rSrSrS rS r\S 5       r\S 5       r	S r
SS	 jrS
 rSrg)r?  i<  zA generated command line tool.c                 b    Xl         UR                  U l        X l        X0l        X@l        XPl        g r6   )
_CLI__namerU  _CLI__parser_CLI__top_element_CLI__pre_run_hooks_CLI__post_run_hooks_CLI__known_error_handler)r    rL   r/  pre_run_hookspost_run_hooksr   s         r"   r#   CLI.__init__?  s.     K''DM$(*!4r%   c                     U R                   $ r6   r  r(   s    r"   _TopElementCLI._TopElementI  s    r%   c                     U R                   $ r6   )r  r(   s    r"   rL   CLI.nameL  s    ;;r%   c                     U R                   $ r6   r  r(   s    r"   r/  CLI.top_elementP  s    r%   c                 8    U R                   R                  U5      $ )zChecks if given command exists.

Args:
  cmd: [str], The command path not including any arguments.

Returns:
  True, if the given command exist, False otherwise.
)r  IsValidSubPath)r    cmds     r"   IsValidCommandCLI.IsValidCommandT  s     ,,S11r%   Nc                   ^ ^^^ [        U[        R                  5      (       a  [        S5      e[        R                  [
        l        [
        R                  S:X  a  [        [
        R                  l
        U(       a  [        T R                  R                  5        U(       d  [        R                  " 5       SS n[         R"                  R%                  U5        [&        R(                  R+                  5         T R,                  mSm[        R.                  (       a'  U Vs/ s H  n[0        R2                  " U5      PM     snOUnSnSn T R4                  R7                  [9        U5      5      nUR:                  b  UR:                  R=                  5         UR?                  5       nSRA                  URC                  5       5      mURE                  5       mURF                  b  URF                  RI                  5         [J        RL                  " S5      n[J        RN                  " S5      n[Q        [&        R(                  RS                  5       5      S:X  a3  [&        R(                  RT                  RV                  RY                  T5        [&        R(                  R[                  [&        R(                  RT                  RV                  TS5        T R\                   H  nUR_                  T5        M     UR_                  T US9mT R`                   H  nUR_                  T5        M     [        T[b        Rd                  5      (       a  UUU U4S jn	U	" 5       [&        R(                  Rg                  5         [         R"                  Ri                  5         Ub  [J        RL                  " U5        Ub  [J        RN                  " U5        $ $ [T        Rj                  " T[l        Rn                  T5        T[&        R(                  Rg                  5         [         R"                  Ri                  5         Ub  [J        RL                  " U5        Ub  [J        RN                  " U5        $ $ s  snf ! [p        Rr                   a  n
U
Rt                  s Sn
A
[&        R(                  Rg                  5         [         R"                  Ri                  5         Ub  [J        RL                  " U5        Ub  [J        RN                  " U5        $ $ Sn
A
f[v         a  n
T Ry                  U
TT5         Sn
A
OSn
A
ff = f [&        R(                  Rg                  5         [         R"                  Ri                  5         Ub  [J        RL                  " U5        Ub  [J        RN                  " U5        gg! [&        R(                  Rg                  5         [         R"                  Ri                  5         Ub  [J        RL                  " U5        Ub  [J        RN                  " U5        f f = f)	aI  Execute the CLI tool with the given arguments.

Args:
  args: [str], The arguments from the command line or None to use sys.argv
  call_arg_complete: Call the _ArgComplete function if True

Returns:
  The result of executing the command determined by the command
  implementation.

Raises:
  ValueError: for ill-typed arguments.
z5Execute expects an iterable of strings, not a string.z1.1r   Nr   r   )r  rp   c               3   ~   >#     T H  n U v   M	     g! [          a  nTR                  UTT5         SnAgSnAff = f7f)zActivates generator exceptions.N)	Exception_HandleAllErrors)resourceexccommand_path_string	resourcesr    specified_arg_namess     r"   _YieldCLI.Execute.<locals>._Yield  sC     Q%n & Q!!#':<OPPQs    = =
:5=:=)=rV   r>   string_typesr   r?   r  str__version__r  _SubParsersActionr   r  r  r  r   GetDecodedArgvr   FLAG_OVERRIDE_STACKPushFromArgsr   r#  PushInvocationValuesr  PY2r   Decoder  
parse_argsrt   CONCEPT_ARGSParseConcepts_GetCommandr=   GetPathGetSpecifiedArgNamesCONCEPTSResetr   SetUserOutputEnabledr;  ro   GetInvocationStackr   command_nameSetSetInvocationValuer  r   r  typesGeneratorTypePopInvocationValuesPopCommandsr   CLOUD_SDK_VERSIONr
   DryRunErrorrequestr  r  )r    rp   call_arg_completer7   argvold_user_output_enabledold_verbositycalliope_commandr   r  r  r  r  r  s   `          @@@r"   ExecuteCLI.Execute_  s    $(())NOO ==HLu$,Ah  )4%%(()&&(,d %%2248**, ++ :=5L$5dD"MF(]]%%od&;<d				&'')))+HH%5%=%=%?@ 557 
	" !$ 8 8 >&&t,m 
Z113	4	9!!..223FG**



#
#
0
02EtM &&$$% '"&&4d&;i''$$% (
 
Iu22	3	3	Q 	Q x ++-''++- 
!	,  !89		"' 
## 
v779L  ++-''++- 
!	,  !89		"' 
#Q 6x !! [[
 ++-''++- 
!	,  !89		"' 
#  K
C!46IJJKJ ++-''++- 
!	,  !89		"' 
# ++-''++- 
!	,  !89		"' 
#sP    QHQ <'Q T,S,7T8V
 ,T9TV
 TV
 
A1W;c                    S[         R                  ;   a  [         R                  S   S:X  a  UeS[        USS5      0n[        [        USS5      SS5      nUb  XTS	'   [        R                  " U[
        R                  UUR                  US
9  [        R                  " X!R                  UUS9  [        R                  " XU R                  5        g)a$  Handle all errors.

Args:
  exc: Exception, The exception that was raised.
  command_path_string: str, The '.' separated command path.
  specified_arg_names: [str], The specified arg named scrubbed for metrics.

Raises:
  exc or a core.exceptions variant that does not produce a stack trace.
CLOUDSDK_CORE_DRY_RUN1
error_code	exit_coder   payloadNstatus_codehttp_status_code)errorerror_extra_info)r  )rQ   r6  rz  r   r  r   r  rY  Errorr
   HandleErrorr  )r    r  r  r  r  r  s         r"   r  CLI._HandleAllErrors  s     	 2::-JJ./36 i$gc;&BC wsIt<,d4#-=)*V557Jmm.>@ MM%}}6I#35 3T5O5OPr%   )rE  rJ  __parserrK  rL  __top_element)NT)r+   r,   r-   r.   r/   r#   r  rQ  rL   r/  r  r  r  r0   r1   r%   r"   r?  r?  <  sI    &5    	2x(t Qr%   r?  r6   )8r/   
__future__r   r   r   r  r   rQ   r   rN   r  r   r  googlecloudsdk.callioper   r   r   rJ   r	   r
   r   r   googlecloudsdk.corer   r   r   r   r   r   "googlecloudsdk.core.configurationsr   googlecloudsdk.core.consoler   googlecloudsdk.core.utilr   r   r   r>   r   r`   objectr   r3   r]   rt   rv   Actionr   Argumentr.  r   CompletionFinderrS  r  r  r?  r1   r%   r"   <module>r     s    K &  '   	 	 
    + + 9 3 . 1 5 * & # ' * $ < 4 - * 2 
 + 5F 5CF C <~'T$f $NB B  -55	F H S Slj44 jZ!,HM@}Q& }Qr%   