
    l                     d   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
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rS r\\l        S rS rS r " S S\5      r  " S S\5      r! " S S\5      r"S r# " S S\5      r$ " S S\RJ                  5      r&g)z(The gcloud interactive shell completion.    )absolute_import)division)unicode_literalsN)parser_completer)parser)generate_cli_trees)module_util)console_attr)
completion   z://c                 ,   U R                   nUR                  (       d  U R                  R                  SSS9  g[	        UR                  R
                  5      S:X  a)  UR                  UR                  R
                  S   5        gUR                  5         g)zFcompletion.generate_completions override that auto selects singletons.TF)insert_common_partselect_firstr   r   N)current_buffercomplete_stateclistart_completionlencurrent_completionsapply_completioncomplete_next)eventbs     7lib/googlecloudsdk/command_lib/interactive/completer.py_GenerateCompletionsr   ,   ss     !	
			II$UK
1//0A5q'';;A>? OO    c                 2   [         R                  " 5       nUR                  S5        U  HK  nUR                  SR                  UR                  =(       d    SUR
                  R                  5      5        MM     UR                  S5        UR                  5       $ )z0Pretty prints args into a string and returns it.[z({},{})z""])ioStringIOwriteformatvalue
token_typenamegetvalue)argsbufargs      r   _PrettyArgsr,   >   se    
#))C.cIIisyy0D#..2E2EFG ))C.	r   c                     [         nU R                  U5      nUS:  a/  U[        [         5      -   nU SUS-
   /XS R                  S5      -   $ U R                  S5      $ )zFReturns the list of component names in path, treating foo:// as a dir.r   Nr   /)_URI_SEPfindr   split)pathurisep	uri_indexns       r   _Splitr6   H   s\    &ii)!^CM!A!A#J<$r(..---	Cr   c                 <    SR                  [        U 5      SS 5      $ )z,Returns the dirname of path, '' if it's '.'.r.   Nr   )joinr6   )r2   s    r   _Dirnamer9   R   s    	&,s#	$$r   c                   *    \ rS rSrSrS rS rS rSrg)CacheArgW   zA completion cache arg.c                 *    Xl         X l        0 U l        g N)prefixcompletionsdirs)selfr?   r@   s      r   __init__CacheArg.__init__Z   s    K"DIr   c                     U R                   S L$ r>   )r@   rB   s    r   IsValidCacheArg.IsValid_   s    4''r   c                 6    [         U l        S U l        0 U l        g r>   )_INVALID_ARG_COMMAND_COUNTcommand_countr@   rA   rF   s    r   
InvalidateCacheArg.Invalidateb   s    3DDDIr   )rK   r@   rA   r?   N)	__name__
__module____qualname____firstlineno____doc__rC   rG   rL   __static_attributes__ r   r   r;   r;   W   s    
(r   r;   c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
CompletionCacheh   a  A per-arg cache of completions for the command line under construction.

Since we have no details on the compeleted values this cache is only for the
current command line. This means that async activities by other commands
(creating files, instances, resources) may not be seen until the current
command under construction is executed.

Attributes:
  args: The list of CacheArg args holding the completion state for each arg.
  completer: The completer object.
  command_count: The completer.cli.command_count value for the current cache.
c                 4    / U l         Xl        [        U l        g r>   )r)   	completer_INVALID_COMMAND_COUNTrK   )rB   rY   s     r   rC   CompletionCache.__init__v   s    DIN/Dr   c                 \    U R                   U R                  R                  R                   :H  $ r>   )rK   rY   r   rF   s    r   rG   CompletionCache.IsValid{   s#    !3!3!A!AAAr   c                     U R                   U   R                  5       (       d  gX   R                  R                  U R                   U   R                  5      $ )z?Returns True if args[index] matches the cache prefix for index.T)r)   rG   r%   
startswithr?   )rB   r)   indexs      r   ArgMatchCompletionCache.ArgMatch~   sE    99U##%%;''		%(8(?(?@@r   c                    U(       a  U R                  5       (       d  g[        U5      [        U R                  5      :  a  g[        U5      S-
  n[        U5       H  nU R	                  X5      (       a  M    g   U R                  U   R                  5       (       d  gX   R
                  nUR                  S5      (       a  USS nU R                  R                  R                  R                  U5        U R                  U   R                  R                  US5      u  pgU(       d  gX`R                  U   l        XpR                  U   l        OX@R                  U   R                  ;   a  U R                  R                  R                  R                  [        U5      5        U R                  U   R                  R                  [        U5      S5      u  pgU(       a&  X`R                  U   l        XpR                  U   l        U R	                  X5      (       d  gU R                  U   R                   Vs/ s H  oR!                  U5      (       d  M  UPM     sn$ s  snf )z@Returns the cached completions for the last arg in args or None.Nr   r.   r   NN)rG   r   r)   rangera   r%   endswithrY   debugdirtextrA   getr?   r@   r9   r_   )	rB   r)   last_arg_indexiaparentr?   r@   cs	            r   LookupCompletionCache.Lookup   s   
 t||~~
4y3tyy>! Y]N>"]]4## # 99^$,,.. 	""Azz#"vf
nn##F+ IIn5::>>v?KMf)/ii&.9ii+	
ii',,	,
nn##HQK0 IIn5::>>x{?KMf	+1		.!(0;		.!- ==.. yy0<<P<!QA<PPPs   5IIc                    U R                   R                  R                  U l        [        U5      S-
  n[	        U5       H  nU[        U R
                  5      :  a3  U R
                  R                  [        X   R                  S5      5        MO  U R                  X5      (       a  Mg  U R
                  U   R                  5         M     X   R                  nU[        U R
                  5      :X  a$  U R
                  R                  [        XR5      5        U R
                  U   R                  5       (       aC  UR                  U R
                  U   R                  5      (       a  UR                  S5      (       a  UR                  S5      (       a  U R
                  U   R                  (       dL  U R
                  U   R                  U R
                  U   R                   4U R
                  U   R                  S'   XR4U R
                  U   R                  USS '   U(       Ga?  SUS   SS ;   Ga2  SU;  Ga+  0 nU H  nUR                  S5      (       a  USS nSnOSn[#        U5      n	U(       a  U	S==   U-  ss'   [	        [        U	5      5       Ho  nSR%                  U	SU 5      n
X;  a  / Xj'   SR%                  U	SUS-    5      nUR                  S5      (       a  US-  nXvU
   ;  d  M\  Xj   R                  U5        Mq     M     [&        R(                  " U5       H?  u  pU
nUR                  S5      (       a  US-  nX4U R
                  U   R                  U
'   MA     O&XPR
                  U   l        X R
                  U   l        [	        US-   [        U R
                  5      5       H   nU R
                  U   R                  5         M"     g)z-Updates completions for the last arg in args.r   Nr.    r   r   z:/)rY   r   rK   r   re   r)   appendr;   r%   ra   rL   rG   r_   r?   rf   rA   r@   r6   r8   six	iteritems)rB   r)   r@   rk   rl   rm   rA   compmarkpartsdro   markeds                r   UpdateCompletionCache.Update   s   ++99DY]N>"	
c$))n			$'--67}}T%%		!! # 	""A TYY'
iix/0 IIn%--//LL>299::	

3	
Cyy(-- ii'..ii'3305$))N
#
(
(
, 341A		.!&&q"v. sk!nSb11cld$==cr$$$t
)t
)s5z"AhhuRay!!]DG%Q-($]]4  CKDa GNN4  # $ --%$!??4  
C-&,2I		.!&&q)	 & *+ii&.9ii+ >A%s499~6
iil 7r   )r)   rK   rY   N)rN   rO   rP   rQ   rR   rC   rG   ra   rp   r|   rS   rT   r   r   rV   rV   h   s%    0
BA3QjA r   rV   c                   H    \ rS rSrSrSrSrSrS rS r	S r
S	 rS
 rS rSrg)Spinner   a  A Spinner to show when completer takes too long to respond.

Some completer calls take too long, specially those that fetch remote
resources. An instance of this class can be used as a context manager wrapping
slow completers to get spinmarks while the completer fetches.

Attributes:
  _done_loading: Boolean flag indicating whether ticker thread is working.
  _set_spinner: Function reference to InteractiveCliCompleter's spinner
    setter.
  _spin_marks: List of unicode spinmarks to be cycled while loading.
  _ticker: Thread instance that handles displaying the spinner.
  _ticker_index: Integer specifying the last iteration index in _spin_marks.
  _TICKER_INTERVAL: Float specifying time between ticker rotation in
    milliseconds.
  _ticker_length: Integer spcifying length of _spin_marks.
  _TICKER_WAIT: Float specifying the wait time before ticking in milliseconds.
  _TICKER_WAIT_CHECK_INTERVAL: Float specifying interval time to break wait
    in milliseconds.
d      
   c                     SU l         [        R                  " 5       R                  5       R                  U l        S U l        SU l        [        U R
                  5      U l	        Xl
        g )NFr   )_done_loadingr
   GetConsoleAttrGetProgressTrackerSymbols
spin_marks_spin_marks_ticker_ticker_indexr   _ticker_length_set_spinner)rB   set_spinners     r   rC   Spinner.__init__  sS    D#224	"	"	$ZZ 	DLDd../D#r   c                     [         R                  R                  US-   5        [         R                  R                  5         g)z0Marks spin_mark on stdout and moves cursor back.N)sysstdoutr#   flush)rB   	spin_marks     r   _MarkSpinner._Mark!  s)    JJY%&JJr   c                     U R                  S5        SU l        U R                  (       a  U R                  R                  5         gg)z2Erases last spin_mark and joins the ticker thread. TN)r   r   r   r8   rF   s    r   StopSpinner.Stop&  s1    JJsOD||
ll r   c                    [        [        R                  [        R                  -  5       H=  n[        R
                  " [        R                  S-  5        U R                  (       d  M=    O   U R                  (       d  U R                  U R                     nU R                  U5        U R                  S-   U R                  -  U l        [        R
                  " [        R                  S-  5        U R                  (       d  M  gg)z<Waits for _TICKER_WAIT and then starts printing the spinner.g     @@r   N)re   r   _TICKER_WAIT_TICKER_WAIT_CHECK_INTERVALtimesleepr   r   r   r   r   _TICKER_INTERVAL)rB   _r   s      r   _TickerSpinner._Ticker-  s    7''7+N+NNO
jj44V;<				 P   ""4#5#56i
jj ..2d6I6IId
jj))&01	    r   c                     U R                  U 5        [        R                  " U R                  S9U l        U R                  R                  5         U $ )N)target)r   	threadingThreadr   r   startrF   s    r   	__enter__Spinner.__enter__9  s;    d##4<<8DLLLKr   c                 F    U R                  5         U R                  S 5        g r>   )r   r   rB   r)   s     r   __exit__Spinner.__exit__?  s    IIKdr   )r   r   r   r   r   r   N)rN   rO   rP   rQ   rR   r   r   r   rC   r   r   r   r   r   rS   rT   r   r   r   r      s8    * , "$

2r   r   c                 x   0 nSnU  GH.  nUR                   [        R                  R                  :X  a6  UR                  R                  [        R                  5      nUR                  nOUR                   [        R                  R                  :X  a_  UR                  R                  [        R                  5      nU(       a-  UR                  S5      (       a  USS nUR                  SS5      nM  U(       d  M  UR                   [        R                  R                  :X  a  UR                  nOGM*  XAU'   GM1     U$ )z4Returns a namespace dict given parsed CLI tree args.Nz--   -r   )r&   r   ArgTokenType
POSITIONALtreerj   LOOKUP_NAMEr%   FLAGr_   replaceFLAG_ARG)r)   	namespacer'   r+   r%   s        r   _NameSpaceDictr   D  s    )	$c
~~,,777XX\\&,,-diie	6..33	3XX\\&,,-d	??4  ab$||C%	6..77	7iiedO# $ 
r   c                   "    \ rS rSrSrSrS rSrg)ModuleCachei]  a  A local completer module cache item to minimize intra-command latency.

Some CLI tree positionals and flag values have completers that are specified
by module paths. These path strings point to a completer method or class that
can be imported at run-time. The ModuleCache keeps track of modules that have
already been imported, the most recent completeion result, and a timeout for
the data. This saves on import lookup, and more importantly, repeated
completion requests within a short window. Users really love that TAB key.

Attributes:
  _TIMEOUT: Newly updated choices stale after this many seconds.
  completer_class: The completer class.
  coshell: The coshell object.
  choices: The cached choices.
  stale: choices stale after this time.
<   c                 V    Xl         S U l        SU l        [        R                  U l        g Nr   )completer_classchoicesstaler   _TIMEOUTtimeout)rB   r   s     r   rC   ModuleCache.__init__q  s#    *DLDJ''DLr   )r   r   r   r   N)rN   rO   rP   rQ   rR   r   rC   rS   rT   r   r   r   r   ]  s    " ((r   r   c                       \ rS rSrSr   SS jrS rS rS rS r	S	 r
S
 rS rS rS rS rS rS rS r\SS j5       rSrg)InteractiveCliCompleterix  az  A prompt_toolkit interactive CLI completer.

This is the wrapper class for the get_completions() callback that is
called when characters are added to the default input buffer. It's a bit
hairy because it maintains state between calls to avoid duplicate work,
especially for completer calls of unknown cost.

cli.command_count is a serial number that marks the current command line in
progress. Some of the cached state is reset when get_completions() detects
that it has changed.

Attributes:
  cli: The interactive CLI object.
  coshell: The interactive coshell object.
  debug: The debug object.
  empty: Completion request is on an empty arg if True.
  hidden: Complete hidden commands and flags if True.
  last: The last character before the cursor in the completion request.
  manpage_generator: The unknown command man page generator object.
  module_cache: The completer module path cache object.
  parsed_args: The parsed args namespace passed to completer modules.
  parser: The interactive parser object.
  prefix_completer_command_count: If this is equal to cli.command_count then
    command PREFIX TAB completion is enabled. This completion searches PATH
    for executables matching the current PREFIX token. It's fairly expensive
    and volumninous, so we don't want to do it for every completion event.
  _spinner: Private instance of Spinner used for loading during
    ArgCompleter.
Nc                    [        U 5      U l        Xl        X l        X0l        X`l        Xpl        0 U l        X@l        XPl	        SU l
        S U l        SU l        [        R                  R                  S5        U R!                  5         g )NFrs   T)rV   	arg_cacher   coshellrg   hiddenmanpage_generatormodule_cacher   parsed_argsempty_spinnerlastr   CliTreeGeneratorMemoizeFailuresreset)rB   r   r   rg   interactive_parserr)   r   r   s           r   rC    InteractiveCliCompleter.__init__  so     %T*DNHLJK.D$KDJDMDI''77=JJLr   c                     U R                  5         U R                  (       a"  U R                  R                  5         SU l        gg)z?Resets any cached state for the current command being composed.N)DisableExecutableCompletionsr   r   rF   s    r   r   InteractiveCliCompleter.reset  s1    %%'}}
mmdm r   c                     Xl         g)z'Sets and Unsets current spinner object.N)r   )rB   spinners     r   
SetSpinner"InteractiveCliCompleter.SetSpinner  s    Mr   c                 H    U R                   U R                  R                  :H  $ )zEReturns True if command prefix args should use executable completion.)prefix_completer_command_countr   rK   rF   s    r   DoExecutableCompletions/InteractiveCliCompleter.DoExecutableCompletions  s    ..$((2H2HHHr   c                     [         U l        g)z2Disables command prefix arg executable completion.N)rZ   r   rF   s    r   r   4InteractiveCliCompleter.DisableExecutableCompletions  s
    *@D'r   c                 :    U R                   R                  U l        g)z1Enables command prefix arg executable completion.N)r   rK   r   rF   s    r   EnableExecutableCompletions3InteractiveCliCompleter.EnableExecutableCompletions  s    *.((*@*@D'r   c                     U R                   (       + =(       a*    US   R                  [        R                  R                  :H  $ )zCReturns True if the input buffer cursor is in a command prefix arg.r   )r   r&   r   r   PREFIXr   s     r   IsPrefixArg#InteractiveCliCompleter.IsPrefixArg  s.    zz>Od2h11V5H5H5O5OOOr   c                     U R                   (       a/  UR                  [        R                  S5      R	                  S5      $ UR                  [        R
                  5      $ )z@Returns True if the info for a command, group or flag is hidden.rs   z--no-)r   rj   r   r   r_   LOOKUP_IS_HIDDEN)rB   infos     r   IsSuppressed$InteractiveCliCompleter.IsSuppressed  s@    {{XXf(("-88AA88F++,,r   c              #   x  #    U R                   R                  R                  5       R                  SR	                  U R
                  R                  UR                  (       a  SOS5      5        UR                  (       dH  UR                  (       a7  U R                  5       (       a  U R                  5         gU R                  5         gU R                  R                  UR                  5      nU(       d  gU R                  U R                  U R                   U R"                  4nU R%                  U5      (       a3  U R                  5       (       d  UR                  (       a  U R"                  4nUR                  (       a  UR                  S   OSU l        U R&                  R)                  5       U l        X l        U R                   R&                  R                  U R&                  5        U R                   R.                  R                  [1        U5      5        U H  nU" U5      u  pgUc  M  U R                   R3                  UR4                  5      R                  5       R                  [7        [9        U5      5      5        Uc  U H  nUv   M	       g[;        U5       H  n[<        R>                  " XS9v   M       g   g7f)zYields the completions for doc.

Args:
  doc: A Document instance containing the interactive command line to
       complete.
  event: The CompleteEvent that triggered this completion.

Yields:
  Completion instances for doc.
z@{}:{}explicitimplicitNr   rs   )start_position) rg   tabscountri   r$   r   rK   completion_requestedtext_before_cursorr   r   r   r   ParseCommandCommandCompleterFlagCompleterPositionalCompleterInteractiveCompleterr   r   isspacer   r   tokensr,   tagrN   r   listsortedr   
Completion)	rB   docr   r)   
completersrY   r   offsetchoices	            r   get_completions'InteractiveCliCompleter.get_completions  s     	JJOO  00
j"B C !!e&@&@		%	%	'	'))+  	((* ;;##C$:$:;D
 	  !!	J $$&&%*D*D--/j.1.D.D&&r*"DI""$DJJJJOO#JJ;t,-
  	!$og	
jjnnY''(..055c$w-6HI	F, 
  WoF%%fD
D &  s   J8J:c                    US   nUR                   R                  S5      (       a  gU R                  U5      (       a$  U R                  R                  nUR                   nGOUR
                  [        R                  R                  [        R                  R                  4;   aS  U R                  (       dB  [        U5      S:  a  US   R                  OU R                  R                  nUR                   nGOjUR
                  [        R                  R                  :X  a%  U R                  (       d  / S4$ UR                  nSnGOUR
                  [        R                  R                  :X  a  UR                   nU R                  (       a  U(       d  [        U5      S:X  av  US   R                   (       ab  [        R                  " US   R                   5      nU(       d  gX0R                  R                  [        R                      US   R                   '   OL[        U5      S:  a;  US   R
                  [        R                  R                  :X  a  US   R                  nOgg["        R$                  " U[        R                      5       VVs/ s H7  u  pVUR                  U5      (       d  M  U R'                  U5      (       a  M5  UPM9     nnnU(       a  U[        U5      * 4$ gs  snnf )	zReturns the command/group completion choices for args or None.

Args:
  args: The CLI tree parsed command args.

Returns:
  (choices, offset):
    choices - The list of completion strings or None.
    offset - The completion prefix offset.
r   r   r   r   r   rs   r   )r%   r_   r   r   rootr&   r   COMMANDGROUPr   r   r   UNKNOWNr   r   LoadOrGenerateLOOKUP_COMMANDSru   rv   r   )rB   r)   r+   noder?   kvr   s           r   r   (InteractiveCliCompleter.CommandCompleter  s    r(C
yyC  			$		 [[dyyf	F//77"//557 
7?Czz "$i!mT"X]]1A1Adyyf	6..44	4ZZ1uXXdf	6..66	6yyf

 
 
d)q.T!W]]!00a?BF//0a?t9q=T"X00F4G4G4M4MMBx}}  ]]40F0F+GH EHTQ,,v& /3/@/@/C HG Es6{l""Es   
K!*K!K!c                    UR                  [        R                  5      nU(       a|  UR                  [        R                  0 5      R                  [        R                  / 5      nU Vs/ s H#  ofR                  U5      (       d  M  Xe;  d  M!  UPM%     nnU[        U5      * 4$ U(       d  U R                  R                  (       d  / S4$ UR                  [        R                  5      nU(       d  / S4$ U R                  R                  U5      n	U	(       d-  [        [        R                  " U5      5      n	XR                  U'   Un
[        U	R                  [         5      (       d  U	R                  U
S9U	l        GO'U	R$                  [&        R&                  " 5       :  Ga  U R(                  R*                  n0 U R(                  l        U R(                  R*                  R-                  U5        U R(                  R*                  R-                  [/        U5      5        [0        R2                  " U	R                  U R(                  S9n[5        U R6                  5         U" SS9U	l        SSS5        XR(                  l        [&        R&                  " 5       U	R8                  -   U	l        UR                  [        R:                  5      S:X  a  UR=                  S5      nUS   n
U	R"                  (       d  / S4$ U	R"                   Vs/ s H  ofR                  U
5      (       d  M  UPM     sn[        U
5      * 4$ s  snf ! , (       d  f       N= fs  snf )	a<  Returns the flag or positional completion choices for arg or [].

Args:
  args: The CLI tree parsed command args.
  arg: The flag or positional argument.
  value: The (partial) arg value.

Returns:
  (choices, offset):
    choices - The list of completion strings or None.
    offset - The completion prefix offset.
r   r?   )r   rs   Nr  ,r   )rj   r   LOOKUP_CHOICESLOOKUP_ATTRLOOKUP_HIDDEN_CHOICESr_   r   r   r   LOOKUP_COMPLETERr   r   r	   ImportModule
isinstancer   typer   r   r   r   __dict__updater   r   ArgumentCompleterr   r   r   LOOKUP_TYPEr1   )rB   r)   r+   r%   r   hidden_choicesr  static_choicesmodule_pathcacher?   old_dictrY   ry   s                 r   ArgCompleter$InteractiveCliCompleter.ArgCompleterN  sw    ggf++,Gwwv1126::

&
&,n QU 3!8O!W  Qc%j[((88Ul''&112KUl !!+.E+22;?@e',$Fe++T22++6+:em	tyy{	"!!**h"$d
&&x0
&&~d';<"44


&&(i 4??#!, $"*IIK%--/ek
wwv!!"f,kk#eRyf==Ul}}=}!V(<A}=F|KKIQ6 $# >s*   )L.L.L.L3<MM3
Mc                    US   nUR                   [        R                  R                  :X  a  US   R                   [        R                  R                  :X  an  UR
                  (       d  U R                  S;   d"  UR
                  (       a<  U R                  (       d+  US   R                  nU R                  XUR
                  5      $ UR                   [        R                  R                  :X  Ga  U R                  (       Gd  0 n[        U5       HS  nUR                  (       d  M  [        R                  UR                  ;   d  M6  UR                  [        R                     n  O   [        R                  " U5       VVs/ s HR  u  pgXbR
                  :w  d  M  UR                  UR
                  5      (       d  M8  U R                  U5      (       a  MP  UPMT     nnnU(       a3  UR!                  UR
                  5        U[#        UR
                  5      * 4$ UR                  nUR%                  [        R&                  5      S:w  aM  U R                  XS5      u  pU R                  (       d%  U R                  S:w  a  U V
s/ s H  n
SU
-   PM
     nn
X4$  g	UR
                  R                  S5      (       a  [        R                  " UR                  [        R                     5       VVs/ s HA  u  pgUR                  UR
                  5      (       d  M'  U R                  U5      (       a  M?  UPMC     snn[#        UR
                  5      * 4$ g	s  snnf s  sn
f s  snnf )
zReturns the flag completion choices for args or None.

Args:
  args: The CLI tree parsed command args.

Returns:
  (choices, offset):
    choices - The list of completion strings or None.
    offset - The completion prefix offset.
r   r  )r   =boolrs   r,  r   r   r   )r&   r   r   r   r   r%   r   r   r   r)  reversedLOOKUP_FLAGSru   rv   r_   r   rt   r   rj   r#  )rB   r)   r+   flagflagsrm   r  r  r@   r  ro   s              r   r   %InteractiveCliCompleter.FlagCompleter  s    r(C&--666Rv22777YY499
2	4::"X]]dt39955	6..33	3ZZZ $AVVV++qvv5FF6../E   &)]]5%9 1%9TQyy. ||CII.   ,,Q/ %9 1 


SYY
's399~o-
- XXd	&$$	%	/"//B?zzdii3.*56+Qq++6"" 
0  
		c	"	"MM#((63F3F*GH (HDAcii( ##A& H (*-cii.9 9 /1 7
(s0   ?M
M
:M
M
=M'&MM)Mc                     US   nUR                   [        R                  R                  :X  a&  U R	                  XR
                  UR                  5      $ g)zReturns the positional completion choices for args or None.

Args:
  args: The CLI tree parsed command args.

Returns:
  (choices, offset):
    choices - The list of completion strings or None.
    offset - The completion prefix offset.
r   r   )r&   r   r   r   r)  r   r%   )rB   r)   r+   s      r   r   +InteractiveCliCompleter.PositionalCompleter  sC     r(C
~~,,777tXXsyy99r   c                    U R                   (       aX  US   R                  (       aD  USS nUR                  [        R                  " S[        R
                  R                  S5      5        U R                  R                  U5      nU(       d  U R                  5       =(       a    U R                  U5      nU R                  R                  (       d  U(       d  gU Vs/ s H  oDR                  PM     nn[        U R                  5         U R                  R!                  XSS9nSSS5        U R"                  R$                  R'                  5         U(       d  gU R                  R)                  X5        O$U R"                  R*                  R'                  5         US   R                  n[-        U5      * n [-        [0        R2                  R5                  U5      5      n[6        n	US   R9                  U	5      n
U
S:  a  U(       d  U
[-        U	5      -   n/ n[-        U5      S:g  nU H/  nU R;                  XX5      nU(       d  M  UR                  U5        M1     US4$ s  snf ! , (       d  f       GNB= f)zReturns the interactive completion choices for args or None.

Args:
  args: The CLI tree parsed command args.

Returns:
  (choices, offset):
    choices - The list of completion strings or None.
    offset - The completion prefix offset.
r   Nrs   rd   r  r   r   )r   r%   rt   r   ArgTokenr   r  r   rp   r   r   r   r   r   r   r   GetCompletionsrg   rj   r   r|   hitr   r_   osr2   dirnamer/   r0   MakePathCompletion)rB   r)   r@   r?   r+   commandr   r  chopuri_sepuri_sep_indexresultstrip_trailing_slashro   path_completions                  r   r   ,InteractiveCliCompleter.InteractiveCompleter  s    zzd2hnn!Wd
kk&//"f&9&9&A&A4HI ..''-K ++-H$2B2B42HfZZ,,V '++dsdg+4??#ll11'1I $
jjnn
nnD.
jjnn8>>D$iZF  rwwt$%DGN''0Mqs7|+ F{+q0//
T1o	o&	 
 4<S ,##s   II
I+c                     UnU(       a  XSS R                  S5      nU(       d  gU(       a+  UR                  [        5      (       d  UR                  S5      nU(       d  g[        R
                  " XUS9$ )a  Returns the Completion object for a file/uri path completion value.

Args:
  value: The file/path completion value string.
  offset: The Completion object offset used for dropdown display.
  chop: The minimum number of chars to chop from the dropdown items.
  strip_trailing_slash: Strip trailing '/' if True.

Returns:
  The Completion object for a file path completion value or None if the
  chopped/stripped value is empty.
Nr.   )displayr   )lstriprf   r/   rstripr   r  )clsr%   r  r=  rA  rE  s         r   r;  *InteractiveCliCompleter.MakePathCompletion  s^     G%%c*gENN8$<$<ll3e  OOr   )r   r   r   r   rg   r   r   r   r   r   r   r   r   r   )NNNNNFT)T)rN   rO   rP   rQ   rR   rC   r   r   r   r   r   r   r   r  r   r)  r   r   r   classmethodr;  rS   rT   r   r   r   r   x  sz    < 48:?!%$IAAP-DL<|6Lp6p$IV P Pr   r   )'rR   
__future__r   r   r   r!   r9  r   r   r   googlecloudsdk.callioper   &googlecloudsdk.command_lib.interactiver   googlecloudsdk.command_lib.metar   googlecloudsdk.corer	   googlecloudsdk.core.consoler
   prompt_toolkitr   ru   rZ   rJ   r/   r   generate_completionsr,   r6   r9   objectr;   rV   r   r   r   	Completerr   rT   r   r   <module>rU     s     / &  ' 	 	 
   4 9 > + 4 % 
  3a7  #7
 %
v "S f S lCf CL2(& (6{Pj22 {Pr   