
    e                        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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 r " S S\R0                  5      r " S S\R0                  5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r  " S S \5      r! " S! S"\5      r" " S# S$\ 5      r# " S% S&\5      r$ " S' S(\5      r% " S) S*\%5      r& " S+ S,\5      r' " S- S.\ 5      r( " S/ S0\5      r) " S1 S2\5      r* " S3 S4\5      r+ " S5 S6\5      r, " S7 S8\5      r-g)9aY  Classes to specify concept and resource specs.

To use a concept, give it at least help text and a name (or use
the default name if the concept provides one) and add it to a concept manager.
During command.Run, the parsed concept will be available under args.
For example:

from googlecloudsdk.command_lib.concepts import concept_managers

  def Args(self, parser):
    manager = concept_managers.ConceptManager()
    concept = concepts.SimpleArg('foo', help_text='Provide the value of foo.')
    manager.AddConcept(concept)
    manager.AddToParser(parser)

  def Run(self, args):
    return args.foo
    )absolute_import)division)unicode_literalsN)deps)base)dependency_managers)
exceptions)names)scaled_integer)semver)timesc                 ~    [         R                  " U 5      R                  S5      nUS   R                  5       USS -   $ )z4Return the string representation of sub-exception e..r      N)six	text_typerstripupper)emessages     @lib/googlecloudsdk/command_lib/concepts/all_concepts/concepts.py_SubExceptionr   7   s9    MM!##C('				gabk	))    c                 P    U (       d  gU S   R                  5       (       a  U $ U S-   $ )z:Appends a space to text if it is not empty and returns it.  isspacetexts    r   _Insertr"   =   s*    		"XK	r   c                 P    U (       d  gU S   R                  5       (       a  U $ SU -   $ )z:Inserts a space to text if it is not empty and returns it.r   r   r   r   r    s    r   _Appendr$   F   s*    		"XK	tr   c                   R   ^  \ rS rSrSr  S
U 4S jjrS rS rS rS r	S r
S	rU =r$ )	SimpleArgO   a  A basic concept with a single attribute.

Attributes:
  fallthroughs: [calliope.concepts.deps.Fallthrough], the list of sources of
    data, in priority order, that can provide a value for the attribute if
    not given on the command line. These should only be sources inherent to
    the attribute, such as associated properties, not command- specific
    sources.
  positional: bool, True if the concept is a positional value.
  completer: core.cache.completion_cache.Completer, the completer associated
    with the attribute.
  metavar: string,  a name for the argument in usage messages.
  default: object, the concept value if one is not otherwise specified.
  choices: {name: help}, the possible concept values with help text.
  action: string or argparse.Action, the basic action to take when the
     concept is specified on the command line. Required for the current
     underlying argparse implementation.
c	                    > Uc  [         R                  " S5      eU=(       d    / U l        X0l        X@l        XPl        X`l        Xpl        Xl        [        [        U ].  " U40 U	D6  gzInitializes the concept.NzConcept name required.)r	   InitializationErrorfallthroughs
positional	completermetavardefaultchoicesactionsuperr&   __init__)selfnamer+   r,   r-   r.   r/   r0   r1   kwargs	__class__s             r   r3   SimpleArg.__init__c   s[     |**+CDD$*D ONLLLK	)T#D3F3r   c                     [         R                  " SU U R                  U R                  U R                  U R
                  U R                  U R                  S.U R                  5       D6$ )N)conceptr+   r-   r.   r/   r1   r0    )	r   	Attributer+   r-   r.   r/   r1   r0   MakeArgKwargsr4   s    r   r<   SimpleArg.Attributeq   sY    >> 2$'+'8'8$(NN"&,,"&,,!%"&,,2 !..02 2r   c                     g)zReturns the type constraints message text if any.

This message text decribes the Validate() method constraints in English.
For example, a regex validator could provide prose for a better UX than
a raw 100 char regex pattern.
r   r;   r>   s    r   ConstraintsSimpleArg.Constraints{   s     r   c                      UR                   $ ! [        R                   aI  nU R                  (       a.  [        R
                  " U R                  5       [        U5      5      e SnAgSnAff = f)a=  Parses the concept.

Args:
  dependencies: googlecloudsdk.command_lib.concepts.dependency_managers
    .DependencyView, the dependency namespace for the concept.

Raises:
  exceptions.MissingRequiredArgumentException, if no value is provided and
    one is required.

Returns:
  str, the value given to the argument.
N)valuedeps_libAttributeNotFoundErrorrequiredr	   MissingRequiredArgumentErrorGetPresentationNamer   )r4   dependenciesr   s      r   ParseSimpleArg.Parse   sY    ** 	55$$&a(8: 	:	s    A+?A&&A+c                     U R                   (       a   [        R                  " U R                  5      $ [        R                  " U R                  5      $ )zDGets presentation name for the attribute, either positional or flag.)r,   r
   ConvertToPositionalNamer5   ConvertToFlagNamer>   s    r   rI   SimpleArg.GetPresentationName   s3    **49955""499--r   c                 J    U R                   =(       a    U R                  (       + $ )aQ  Determines whether command line argument for attribute is required.

Returns:
  bool: True, if the command line argument is required to be provided,
    meaning that the attribute is required and that there are no
    fallthroughs. There may still be a parsing error if the argument isn't
    provided and none of the fallthroughs work.
)rG   r+   r>   s    r   IsArgRequiredSimpleArg.IsArgRequired   s     ==2!2!222r   )r1   r0   r-   r/   r+   r.   r,   )NFNNNNN)__name__
__module____qualname____firstlineno____doc__r3   r<   rA   rK   rI   rR   __static_attributes____classcell__r7   s   @r   r&   r&   O   s5    & KO@D42,.	3 	3r   r&   c                   T   ^  \ rS rSrSrSU 4S jjrS rS rS rS r	S r
S	 rS
rU =r$ )GroupArg   zaA group concept.

Attributes:
  mutex: bool, True if this is a mutex (mutually exclusive) group.
c                    > Uc  [         R                  " S5      eX l        X0l        / U l        [
        [        U ]  " U40 UD6  gr)   )r	   r*   mutexprefixesconceptsr2   r]   r3   )r4   r5   r`   ra   r6   r7   s        r   r3   GroupArg.__init__   s?    |**+CDDJMDM	(D"4262r   c                     [         R                   " U5      nU R                  UR                  5      Ul        U R                  R	                  U5        g N)copy_GetSubConceptNamer5   rb   append)r4   r:   new_concepts      r   
AddConceptGroupArg.AddConcept   s;    ))G$K..{/?/?@KMM%r   c           	          [         R                  " SU U R                   Vs/ s H  oR                  5       PM     snU R                  S.U R                  5       D6$ s  snf )N)r:   
attributesr`   r;   )r   AttributeGrouprb   r<   r`   r=   )r4   cs     r   r<   GroupArg.Attribute   sT     +/==9=aKKM=9jj 


	 9s   Ac                 t    U R                   (       a&  [        R                  " U R                  S-   U-   5      $ U$ )N_)ra   r
   ConvertToNamespaceNamer5   )r4   attribute_names     r   rg   GroupArg._GetSubConceptName   s-    }}))$))c/N*JKKr   c                     U$ )z:Returns a namespace with the values of the child concepts.r;   )r4   rJ   s     r   rK   GroupArg.Parse   s    r   c                     U R                   $ )z/Gets presentation name for the attribute group.)r5   r>   s    r   rI   GroupArg.GetPresentationName   s    99r   c                 j    U R                   =(       a!    [        S U R                   5       5      (       + $ )aO  Determines whether the concept group is required to be specified.

Returns:
  bool: True, if the command line argument is required to be provided,
    meaning that the attribute is required and that there are no
    fallthroughs. There may still be a parsing error if the argument isn't
    provided and none of the fallthroughs work.
c              3   8   #    U  H  oR                   v   M     g 7fre   )r+   ).0ro   s     r   	<genexpr>)GroupArg.IsArgRequired.<locals>.<genexpr>   s     $K]^^]s   )rG   anyrb   r>   s    r   rR   GroupArg.IsArgRequired   s%     ==K$KT]]$K!KKKr   )rb   r`   ra   )FF)rT   rU   rV   rW   rX   r3   rj   r<   rg   rK   rI   rR   rY   rZ   r[   s   @r   r]   r]      s2    3&

	L 	Lr   r]   c                   D   ^  \ rS rSrSrS rS rS rU 4S jrS r	Sr
U =r$ )	ConceptType   zConcept type base class.

All concept types derive from this class. The methods implement lexing,
parsing, constraints, help text, and formatting.
c                     U$ )aX  Converts a value from string and returns it.

The converter must do syntax checking and raise actionable exceptions. All
non-space characters in string must be consumed. This method may raise
syntax exceptions, but otherwise does no validation.

Args:
    string: The string to convert to a concept type value.

Returns:
  The converted value.
r;   r4   strings     r   ConvertConceptType.Convert   s	     Mr   c                 .    [         R                  " U5      $ )aK  Returns the string representation of a parsed concept value.

This method is the inverse of Convert() and Parse(). It returns the
string representation of a parsed concept value that can be used in
formatted messages.

Args:
    value: The concept value to display.

Returns:
  The string representation of a parsed concept value.
)r   r   r4   rD   s     r   DisplayConceptType.Display   s     ==r   c                     U$ )aH  Returns the normalized value.

Called after the value has been validated. It normalizes internal values
for compatibility with other interfaces. This can be accomplished by
subclassing with a shim class that contains only a Normalize() method.

Args:
    value: The concept value to normalize.

Returns:
  The normalized value.
r;   r   s     r   	NormalizeConceptType.Normalize  s	     Lr   c                    > [         [        U ]  U5      nU R                  U5      nU R	                  U5        U R                  U5      $ )zDConverts, validates and normalizes a value string from dependencies.)r2   r   rK   r   Validater   )r4   rJ   r   rD   r7   s       r   rK   ConceptType.Parse  s=    ;+L9FLL EMM%>>%  r   c                     g)a  Validates value.

Syntax checking has already been done by Convert(). The validator imposes
additional constraints on valid values for the concept type and must raise
actionable exceptions when the constraints are not met.

Args:
  value: The concept value to validate.
Nr;   r   s     r   r   ConceptType.Validate  s     	r   r;   )rT   rU   rV   rW   rX   r   r   r   rK   r   rY   rZ   r[   s   @r   r   r      s&     !
	 
	r   r   c                   "    \ rS rSrSrSS jrSrg)Endpointi*  zTypeWithIntervalConstraint endpoint.

Attributes:
  string: string, the representation of the endpoint value.
  closed: bool, True if the interval is closed (the endpoint is included).
c                 *    Xl         X l        S U l        g re   )r   closedrD   )r4   r   r   s      r   r3   Endpoint.__init__2  s    KKDJr   )r   r   rD   N)T)rT   rU   rV   rW   rX   r3   rY   r;   r   r   r   r   *  s    r   r   c                   H   ^  \ rS rSrSr   SU 4S jjrS rS rS rSr	U =r
$ )	TypeWithIntervalConstrainti8  a}  Concept type with value interval constraints.

Validates that a ConceptType value is within the interval defined by min and
max endpoints. A missing min or max endpoint indicates that there is no min or
max value, respectively.

Attributes:
  _min_endpoint: Endpoint, the minimum value interval endpoint.
  _max_endpoint: Endpoint, the maximum value interval endpoint.
  _constraint_kind: string, the interval value type name.
  _convert_endpoint: f(str)=>x, converts an endpoint string to a value.
  _convert_interval: f(str)=>x, converts an interval value to a value.
  _display_endpoint: f(value)=>str, displays an interval endpoint.
c                   > [         [        U ]
  " U40 UD6  X l        X0l        U=(       d    SU l        U=(       d    U R                  U l        U=(       d    U R                  U l	        U=(       d    S U l
        U R                  (       a  U R                  U R                  S5        U R                  (       a  U R                  U R                  S5        g g )NrD   c                     U $ re   r;   )xs    r   <lambda>5TypeWithIntervalConstraint.__init__.<locals>.<lambda>Q  s    ar   zmin endpointzmax endpoint)r2   r   r3   _min_endpoint_max_endpoint_kindr   _convert_endpointr   _display_endpoint_convert_value_ConvertEndpoint)
r4   r5   min_endpointmax_endpointconstraint_kindconvert_endpointconvert_valuedisplay_endpointr6   r7   s
            r   r3   #TypeWithIntervalConstraint.__init__H  s     

$d4TDVD%% +GDJ-=D-=D'8KD
D..?
D..? r   c                    Sn U R                  UR                  5      Ul        g! [        R                   aB  n[
        R                  " U5      R                  SS5      S   R                  S5      n SnAO+SnAf[        [        4 a  n[        U5      n SnAOSnAff = f[        R                  " U R                  5       X!R                  US-   5      e)z+Declaration time endpoint conversion check.Nz. r   r   )r   r   rD   r	   
ParseErrorr   r   splitr   AttributeError
ValueErrorr   ConstraintErrorrI   )r4   endpointkindr   r   s        r   r   +TypeWithIntervalConstraint._ConvertEndpointW  s    G!--hoo>hn   ?a &&tQ/299#>gJ' !a g!

$
$  "D//7S=J Js     % B8A66B	BBc                 D   / nU R                   (       ae  U R                   R                  nU R                   R                  (       a  SnOSnUR                  SR	                  X0R                  U5      5      5        U R                  (       ae  U R                  R                  nU R                  R                  (       a  SnOSnUR                  SR	                  X0R                  U5      5      5        U(       d  gSR	                  U R                  SR                  U5      5      $ )	1Returns the type constraints message text if any.greater than or equal togreater thanz{} {}less than or equal to	less thanr   zThe {} must be {}.z and )	r   rD   r   rh   formatr   r   r   join)r4   
boundariesr   boundarys       r   rA   &TypeWithIntervalConstraint.Constraintsd  s    J##))h				"	"-!
**846 7##))h				"	"*
**846 7&&tzz7<<
3KLLr   c                    U R                  U5      nS nU R                  (       a@  U R                  R                  nU R                  R                  (       a  X:  a  SnOX::  a  SnU(       dQ  U R                  (       a@  U R                  R                  nU R                  R                  (       a  X:  a  SnOX:  a  SnU(       a~  [
        R                  " U R                  5       SR                  U R                  S   R                  5       U R                  SS  U R                  U5      UU R                  W5      5      5      eg )Nr   r   r   r   z{}{} [{}] must be {} [{}].r   r   )r   r   rD   r   r   r	   ValidationErrorrI   r   r   r   r   )r4   rD   invalidr   s       r   r   #TypeWithIntervalConstraint.Validate{  s   &EG##))h				"	".' t))##))h				"	"+'&&

"
"
$
&
-
-jjm!!#jjn$$U+$$X.01 1 r   )r   r   r   r   r   r   )NNNNNN)rT   rU   rV   rW   rX   r3   r   rA   r   rY   rZ   r[   s   @r   r   r   8  s0     <@JN $@JM.1 1r   r   c                   R   ^  \ rS rSrSrSrSr\S 5       r  S	U 4S jjr	S r
SrU =r$ )
TypeWithSizeConstrainti  zConcept type with size interval constraints.

Validates that a ConceptType size is within the interval defined by min and
max endpoints. A missing min or max endpoint indicates that there is no min or
max size, respectively.
,^c                 *    U(       a  [        U5      $ S$ )Nr   )len)clsrD   s     r   _GetIntervalValue(TypeWithSizeConstraint._GetIntervalValue  s    3u:%A%r   c                    > [         [        U ]
  " U4U=(       d    SU=(       d    [        U=(       d    U R                  U=(       d    [
        S.UD6  g )Nsize)r   r   r   r   )r2   r   r3   intr   str)r4   r5   r   r   r   r   r6   r7   s          r   r3   TypeWithSizeConstraint.__init__  sK    	
 $0'16)0S#=t'='=)0S r   c                 P   U(       d  gU R                   nUR                  U R                  5      (       a`  U R                  USS ;   aM  USS R                  U R                  S5      u  p!U(       d%  [        R
                  " U R                  5       S5      eUR                  U5      U4$ )a  Splits string on _DEFAULT_DELIM or the alternate delimiter expression.

By default, splits on commas:
    'a,b,c' -> ['a', 'b', 'c']

Alternate delimiter syntax:
    '^:^a,b:c' -> ['a,b', 'c']
    '^::^a:b::c' -> ['a:b', 'c']
    '^,^^a^,b,c' -> ['^a^', ',b', 'c']

See `gcloud topic escaping` for details.

Args:
  string: The string with optional alternate delimiter expression.

Raises:
  exceptions.ParseError: on invalid delimiter expression.

Returns:
  (string, delimiter) string with the delimiter expression stripped, if any.
NNr   NzqInvalid delimiter. Please see $ gcloud topic escaping for information on escaping list or dictionary flag values.)_DEFAULT_DELIM
startswith
_ALT_DELIMr   r	   r   rI   )r4   r   delims      r   _SplitTypeWithSizeConstraint._Split  s    , E))doo.KQRj&&t:me##$$&FG 	G <<%%r   r;   )NNNN)rT   rU   rV   rW   rX   r   r   classmethodr   r3   r   rY   rZ   r[   s   @r   r   r     s?     .*& & CG48 &  &r   r   c                   <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )TypeWithRegexConstrainti  zConcept type with regex constraint.

Attributes:
  _regex: string, an unanchored regular expression pattern that must match
    valid values.
  _constraint_details: string, optional prose that describes the regex
    constraint.
c                 H   > [         [        U ]
  " U40 UD6  X l        X0l        g re   )r2   r   r3   _regex_constraint_details)r4   r5   regexconstraint_detailsr6   r7   s        r   r3    TypeWithRegexConstraint.__init__  s#    	
!41$A&AK1r   c                     U R                   (       d  gU R                  (       a  U R                  $ SR                  U R                   5      $ )r   r   z5The value must match the regular expression ```{}```.)r   r   r   r>   s    r   rA   #TypeWithRegexConstraint.Constraints  s;    ;;%%%BII r   c                 .   U R                   (       a  [        R                  " U R                   U R                  U5      5      (       dN  [        R
                  " U R                  5       SR                  U R                  U5      U R                   5      5      eg g )NzValue [{}] does not match [{}].)r   rematchr   r	   r   rI   r   r   s     r   r    TypeWithRegexConstraint.Validate  sn    {{288DKKe1DEE&&

"
"
$
+
2
2ll5!kk  F{r   )r   r   r   )
rT   rU   rV   rW   rX   r3   rA   r   rY   rZ   r[   s   @r   r   r     s    2
 r   r   c                   <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )Booleani  zBoolean value concept.c                    > U(       a  SOSnUR                  SS5      nU(       a=  U R                  5       nUR                  S5      (       a  USR                  USS  5      -  nXSS'   [        [
        U ]  " U4X$S.UD6  g )	Nstore_false
store_true	help_textzA Boolean value.z--z' On by default, use --no-{} to disable.   )r/   r1   )getrI   r   r   r2   r   r3   )r4   r5   r/   r6   r1   r   presentationr7   s          r   r3   Boolean.__init__  s    %]<F

;(:;I--/l		 	 	&	&>EE 		#;	'4!$ , ,$*,r   c                     Uc  gUS:X  d  UR                  5       S:X  a  gUS:X  d  UR                  5       S:X  a  g[        R                  " U R                  5       SR	                  U5      5      e)NF1trueT0falsezInvalid Boolean value [{}].)lowerr	   r   rI   r   r   s     r   r   Boolean.Convert  se    ~}&0}'1


  "%,,V46 6r   c                     U(       a  S$ S$ )z/Returns the display string for a Boolean value.r   r   r;   r   s     r   r   Boolean.Display  s    6''r   r;   re   )
rT   rU   rV   rW   rX   r3   r   r   rY   rZ   r[   s   @r   r   r     s    
,
6( (r   r   c                   B   ^  \ rS rSrSrSU 4S jjrS rU 4S jrSrU =r	$ )Enumi  zEnum value concept.c                    > U(       d  [         R                  " S5      eU(       a  X2;  a  [         R                  " S5      eX l        [        [        U ]  " U4X#S.UD6  g )Nz(Choices must be specified for Enum type.z*Enum default value must be a valid choice.)r0   r/   )r	   r*   r0   r2   r   r3   )r4   r5   r0   r/   r6   r7   s        r   r3   Enum.__init__  sX    **
46 67)**
68 8L	$tPWPPr   c                 |    UR                  5       nX R                  ;  a  UR                  5       U R                  ;  ae  [        R                  " U R                  5       SR                  USR                  [        U R                  R                  5       5      5      5      5      eU$ ! [        [        4 a    Us $ f = f)Nz)Invalid choice [{}], must be one of [{}].r   )r   r0   r   r	   r   rI   r   r   sortedkeysr   r   )r4   r   choices      r   r   Enum.Convert!  s    	||~f	||	#dll(J##$$&7>>(9(9(;!<=?@ 	@ mJ' ms   B#B& &B;:B;c                 f  > [         R                  " 5       nUR                  S5        [        [        R
                  " U R                  5      5       H%  u  p#UR                  SR                  X#5      5        M'     SR                  [        [        [        U ]/  5       5      UR                  5       5      $ )z.Appends enum values to the original help text.
+
*{}*::: {}
z({}Must be one of the following values:{})ioStringIOwriter  r   	iteritemsr0   r   r"   r2   r   BuildHelpTextgetvalue)r4   bufkeyr   r7   s       r   r  Enum.BuildHelpText-  s    
++-CIIg t||!<=	ii%%c56 > 	399E$356	HIr   )r0   r   )
rT   rU   rV   rW   rX   r3   r   r  rY   rZ   r[   s   @r   r   r     s    Q
I Ir   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )Stringi8  zString value concept.c                 F   > SU;  a  SUS'   [         [        U ]
  " U40 UD6  g )Nr   zA string value.)r2   r  r3   )r4   r5   r6   r7   s      r   r3   String.__init__;  s)    & -f[	&$ 00r   r;   )rT   rU   rV   rW   rX   r3   rY   rZ   r[   s   @r   r  r  8  s    1 1r   r  c                   B   ^  \ rS rSrSrSU 4S jjrU 4S jrS rSrU =r	$ )IntegeriA  zInteger value concept.

Attributes:
  _unlimited: bool, the value 'unlimited' specifies the largest valid value.
    Internally it's represented as None.
c                 <   > X l         [        [        U ]  " U40 UD6  g re   )
_unlimitedr2   r  r3   r4   r5   	unlimitedr6   r7   s       r   r3   Integer.__init__I  s    O	'4!$1&1r   c                 X   > SR                  [        [        [        U ]  5       5      5      $ )z1Appends integer syntax to the original help text.z+{}Must be a string representing an integer.)r   r"   r2   r  r  r4   r7   s    r   r  Integer.BuildHelpTextM  s*     	6<<E'4689	;<r   c           	          Uc  g  [        U5      $ ! [         a^  nU R                  (       a  US:X  a   S nAg [        R                  " U R                  5       SR                  [        U5      5      5      eS nAff = f)Nr  z{}.)r   r   r  r	   r   rI   r   r   r4   r   r   s      r   r   Integer.ConvertS  sj    ~*[ *	V{2!!

"
"
$
,,}Q'
(* **s   
 
A9A4=A44A9r  F
rT   rU   rV   rW   rX   r3   r  r   rY   rZ   r[   s   @r   r  r  A  s    2<
* 
*r   r  c                   R   ^  \ rS rSrSr  S	U 4S jjrS rU 4S jrS rS r	Sr
U =r$ )
ScaledIntegeri`  a  ISO Decimal/Binary scaled Integer value concept.

ISO/IEC prefixes: 1k == 1000, 1ki == 1024.

Attributes:
  _default_unit: string, the unit suffix if none is specified.
  _output_unit: string, the implicit output unit. Integer values are
    divided by the output unit value.
  _output_unit_value: int, the output unit value.
  _type_abbr: string, the type abbreviation, for example 'b/s' or 'Hz'.
  _type_details: string, prose that describes type syntax details.
c                 n  > Xl         X@l        X l        U R                  (       a$  U R                  SU R                  5      u  U l        nX0l        U R                  (       a*  U R                  SU R                  5      u  U l        U l        OSU l        U=(       d    SU l        [        [        U ]&  " U40 UD6  g )Nzdefault scaled integer unitzoutput scaled integer unitr   zqMust be a string representing an ISO/IEC Decimal/Binary scaled integer. For example, 1k == 1000 and 1ki == 1024. )
r5   
_type_abbr_default_unit_GetUnitValue_output_unit_output_unit_value_type_detailsr2   r)  r3   )	r4   r5   default_unitoutput_unit	type_abbrtype_detailsr6   rr   r7   s	           r   r3   ScaledInteger.__init__n  s    IO%"00
'););=d!#373E3E
&(9(94;0d0 !"d% >	= 	 
-'77r   c           	         U R                   (       a  [        R                  " U5      n U[        R                  " U5      4$ ! [         a3  n[
        R                  " U R                  X[        U5      S-   5      eSnAff = f)z3Returns the integer unit suffix and value for unit.r   N)	r+  r   DeleteTypeAbbrGetUnitSizer   r	   r   r5   r   )r4   r   unitr   s       r   r-  ScaledInteger._GetUnitValue  sl    **40d9>--d333 9&&
))Tq!1C!79 99s   A 
A>.A99A>c                   > U R                   (       a  SR                  U R                   5      nOSnU R                  (       a  SR                  U R                  5      nOSnU R                  (       a  SR                  U R                  5      nOSnSR                  [	        [
        [        U ]  5       5      U R                  UUU[	        U R                  5       5      5      $ )zBAppends ISO Decimal/Binary scaled integer syntax to the help text.zThe default unit is `{}`. r   zGThe output unit is `{}`. Integer values are divided by the unit value. z'The default type abbreviation is `{}`. zH{}{}{}{}{}{}See https://en.wikipedia.org/wiki/Binary_prefix for details.)
r,  r   r.  r+  r"   r2   r)  r  r0  rA   )r4   r1  r2  r3  r7   s       r   r  ScaledInteger.BuildHelpText  s    1889K9KLllF4,,-  k;BB
//i i	6E-<>?D$$&')*r   c           
      H   U(       d  g  [         R                  " XR                  U R                  S9nU R                  (       a  X R                  -  nU$ ! [
         aC  n[        R                  " U R                  5       SR                  U[        U5      5      5      eS nAff = f)N)r1  r3  z7Failed to parse binary/decimal scaled integer [{}]: {}.)r   ParseIntegerr,  r+  r/  r   r	   r   rI   r   r   )r4   r   rD   r   s       r   r   ScaledInteger.Convert  s    
)))
11T__Ne		 	 )))l )!!

"
"
$
C
J
JmA&() ))s   A	A 
B!>BB!c                 |    U R                   (       a  XR                   -  n[        R                  " XR                  S9$ )z5Returns the display string for a binary scaled value.)r3  )r/  r   FormatIntegerr+  r   s     r   r   ScaledInteger.Display  s.    &&&e''IIr   )r,  r.  r/  r+  r0  r5   )NNBN)rT   rU   rV   rW   rX   r3   r-  r  r   r   rY   rZ   r[   s   @r   r)  r)  `  s2     KN 8&9*6)J Jr   r)  c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )BinaryScaledIntegeri  a  ISO Binary scaled Integer value with binary display concept.

All ISO/IEC prefixes are powers of 2: 1k == 1ki == 1024. This is a
concession to the inconsistent mix of binary/decimal scaled measures for
memory capacity, disk capacity, cpu speed. Ideally ScaledInteger should
be used.
c                 >   > Uc  Sn[         [        U ]
  " U4SU0UD6  g )NzMust be a string representing binary scaled integer where all ISO/IEC prefixes are powers of 2. For example, 1k == 1ki == 1024. r4  )r2   rE  r3   )r4   r5   r4  r6   r7   s       r   r3   BinaryScaledInteger.__init__  s9    O  

t-3'3+13r   c           
          U(       d  g  [         R                  " XR                  5      $ ! [         aC  n[        R
                  " U R                  5       SR                  U[        U5      5      5      eS nAff = f)Nz/Failed to parse binary scaled integer [{}]: {}.)	r   ParseBinaryIntegerr,  r   r	   r   rI   r   r   r#  s      r   r   BinaryScaledInteger.Convert  sk    )..v7I7IJJ )!!

"
"
$
;
B
BmA&() ))s   * 
A7>A22A7r;   re   )	rT   rU   rV   rW   rX   r3   r   rY   rZ   r[   s   @r   rE  rE    s    3	) 	)r   rE  c                   B   ^  \ rS rSrSrSU 4S jjrU 4S jrS rSrU =r	$ )Floati  zFloat value concept.

Attributes:
  _unlimited: bool, the value 'unlimited' specifies the largest valid value.
    Internally it's represented as None.
c                 <   > X l         [        [        U ]  " U40 UD6  g re   )r  r2   rL  r3   r  s       r   r3   Float.__init__  s    O	%//r   c                    > SR                  [        [        [        U ]  5       5      [        U R                  5       5      5      $ )z/Appends float syntax to the original help text.z:{}Must be a string representing a floating point number.{})r   r"   r2   rL  r  r$   rA   r   s    r   r  Float.BuildHelpText  s<     	EKKE%467D$$&'	)*r   c           
         U(       d  g  [        U5      $ ! [         a_  nU R                  (       a  US:X  a   S nAg [        R                  " U R                  5       SR                  U[        U5      5      5      eS nAff = f)Nr  z/Failed to parse floating point number [{}]: {}.)floatr   r  r	   r   rI   r   r   r#  s      r   r   Float.Convert  so    )6] )	V{2!!

"
"
$
;
B
BmA&() ))s   
 
A>A9>A99A>r%  r&  r'  r[   s   @r   rL  rL    s    0*) )r   rL  c                   :   ^  \ rS rSrSr/ SQrU 4S jrS rSrU =r	$ )	DayOfWeeki  zDay of the week concept.)SUNMONTUEWEDTHUFRISATc                    > SR                  [        [        [        U ]  5       5      [        U R                  5       5      5      $ )z5Appends day of week syntax to the original help text.z{}Must be a string representing a day of the week in English, such as 'MON' or 'FRI'. Case is ignored, and any characters after the first three are ignored.{})r   r"   r2   rU  r  r$   rA   r   s    r   r  DayOfWeek.BuildHelpText  s:    	))/E)T8:;D$$&'*)*r   c           	          U(       d  gUR                  5       SS nX R                  ;  aN  [        R                  " U R	                  5       SR                  USR                  U R                  5      5      5      eU$ )z.Converts a day of week from string returns it.N   z.A day of week value [{}] must be one of: [{}].z, )r   _DAYSr	   r   rI   r   r   )r4   r   rD   s      r   r   DayOfWeek.Convert  sj    LLN2AEJJ!!

"
"
$
:
A
Adii

+-. . Lr   r;   )
rT   rU   rV   rW   rX   ra  r  r   rY   rZ   r[   s   @r   rU  rU    s     
;%*
 
r   rU  c                   H   ^  \ rS rSrSrSU 4S jjrU 4S jrS rS rSr	U =r
$ )	Durationi  zDuration concept.

Attributes:
  _default_suffix: string, the time unit suffix if none is specified.
  _subsecond: bool, return floating point values if True.
c                 H   > X l         X0l        [        [        U ]  " U40 UD6  g re   )_default_suffix
_subsecondr2   rd  r3   )r4   r5   default_suffix	subsecondr6   r7   s        r   r3   Duration.__init__  s"    )O	(D"4262r   c                    > U R                   (       a  SR                  U R                   5      nOSnSR                  [        [        [        U ]  5       5      U[        U R                  5       5      5      $ )z2Appends duration syntax to the original help text.zThe default suffix is `{}`. r   a  {}Must be a string representing an ISO 8601 duration. Syntax is relaxed to ignore case, the leading P and date/time separator T if there is no ambiguity. {}For example, `PT1H` and `1h` are equivalent representations of one hour. {}See $ gcloud topic datetimes for more information.)rf  r   r"   r2   rd  r  rA   )r4   rh  r7   s     r   r  Duration.BuildHelpText"  sg    5<<


 n n	 vE(D79:ND$$&')*r   c           
      T   U(       d  g [         R                  " XR                  S9R                  nU R                  (       a  U$ [        U5      $ ! [         R                   aC  n[        R                  " U R                  5       SR                  U[        U5      5      5      eSnAff = f)z+Converts a duration from string returns it.N)rh  "Failed to parse duration [{}]: {}.)r   ParseDurationrf  total_secondsrg  r   Errorr	   r   rI   r   r   )r4   r   dr   s       r   r   Duration.Convert2  s    )



!5!577D} //Q-s1v-;; )!!

"
"
$
.
5
5mA&() ))s   :A 
A B'$>B""B'c                     [         R                  " SR                  U5      5      n[         R                  " U5      nUR	                  S5      (       a  USS R                  5       nU$ )zDReturns the display string for a duration value, leading PT dropped.z{}sPTr   N)r   ro  r   FormatDurationr   r   )r4   rD   rr  ss       r   r   Duration.Display@  sP    ELL/0AQA||D
AB%++-aHr   )rf  rg  )rw  F)rT   rU   rV   rW   rX   r3   r  r   r   rY   rZ   r[   s   @r   rd  rd    s!    3
* ) r   rd  c                   N   ^  \ rS rSrSrS	U 4S jjrU 4S jrS rS rS r	Sr
U =r$ )
	TimeStampiI  zTimeStamp concept.

Attributes:
  _fmt: string, a times.FormatDateTime() format specification.
  _string: bool, normalize value to a string if True
  _tzinfo: datetime.tzinfo, a time zone object, typically times.UTC or
    times.LOCAL.
c                    > X l         U=(       d    [        R                  U l        X@l        [
        [        U ]  " U40 UD6  g re   )_fmtr   UTC_tzinfo_stringr2   rz  r3   )r4   r5   fmttzr   r6   r7   s         r   r3   TimeStamp.__init__S  s0    I?DLL	)T#D3F3r   c                    > SR                  [        [        [        U ]  5       5      [        U R                  5       5      5      $ )z3Appends timestamp syntax to the original help text.z{}Must be a string representing an ISO 8601 date/time. Relative durations (prefixed by - or +) may be used to specify offsets from the current time. {}See $ gcloud topic datetimes for more information.)r   r"   r2   rz  r  rA   r   s    r   r  TimeStamp.BuildHelpTextY  s<    	 vE)T8:;D$$&')	*r   c           
         U(       d  g [         R                  " XR                  S9$ ! [         R                   aC  n[        R
                  " U R                  5       SR                  U[        U5      5      5      eSnAff = f)z1Converts a datetime value from string returns it.N)tzinforn  )	r   ParseDateTimer~  rq  r	   r   rI   r   r   r#  s      r   r   TimeStamp.Convertc  sm    )  ==;; )!!

"
"
$
.
5
5mA&() ))s   ( A?>A::A?c                 T    [         R                  " XR                  U R                  S9$ )z0Returns the display string for a datetime value.)r  r  )r   FormatDateTimer|  r~  r   s     r   r   TimeStamp.Displayo  s    99T\\JJr   c                 J    U R                   (       a  U R                  U5      $ U$ re   )r  r   r   s     r   r   TimeStamp.Normalizes  s    "&,,4<<9E9r   )r|  r  r~  )NNF)rT   rU   rV   rW   rX   r3   r  r   r   r   rY   rZ   r[   s   @r   rz  rz  I  s'    4*
)K: :r   rz  c                   8   ^  \ rS rSrSrU 4S jrS rS rSrU =r	$ )SemVeriw  zSemVer concept.c                    > SR                  [        [        [        U ]  5       5      [        U R                  5       5      5      $ )z0Appends SemVer syntax to the original help text.z{}Must be a string representing a SemVer number of the form _MAJOR_._MINOR_._PATCH_, where omitted trailing parts default to 0. {}See https://semver.org/ for more information.)r   r"   r2   r  r  rA   r   s    r   r  SemVer.BuildHelpTextz  s:    	::@&E&$578D$$&';)*r   c                 z   U(       d  g UR                  S5      n[        U5      S:  a"  UR                  S5        [        U5      S:  a  M"  SR                  U5      n[        R
                  " U5      $ ! [        R                   a3  n[        R                  " U R                  5       [        U5      5      eSnAff = f)z0Converts a SemVer object from string returns it.Nr   r`  r   )
r   r   rh   r   r   r  r   r	   rI   r   )r4   r   partsr   s       r   r   SemVer.Convert  s    Pll3eJNS JNxxf]]6"" P!!$":":"<mA>NOOPs   A A3 &A3 3B:.B55B:c                 d    SR                  UR                  UR                  UR                  5      $ )z5Returns the display string for a SemVer object value.z{}.{}.{})r   majorminorpatchr   s     r   r   SemVer.Display  s#    U[[%++u{{CCr   r;   )
rT   rU   rV   rW   rX   r  r   r   rY   rZ   r[   s   @r   r  r  w  s    *PD Dr   r  c                   N   ^  \ rS rSrSrS	U 4S jjrU 4S jrS rS rS r	Sr
U =r$ )
Listi  zA list attribute concept.

Attributes:
  _delim: string, the user specified lit item delimiter character.
  _element: string, the list element type object.
c                    > [         [        U ]
  " U4SS0UD6  U R                  U l        U=(       d    [        U5      U l        g )Nr   zlist length)r2   r  r3   r   _delimr  _element)r4   r5   elementr6   r7   s       r   r3   List.__init__  s9    	$tM]MfM%%DK+vd|DMr   c                   > U R                   R                  5       nUR                  S5      (       a  SR                  USS 5      nO*UR                  S5      (       a  SR                  USS 5      nSR                  [	        [
        [        U ]  5       5      U R                   R                  [	        U R                  5       5      [	        U5      5      $ )z.Appends list syntax to the original help text.Must zEach item m{}r   NA zEach item is a{}z{}Must be a string representing a list of `,` separated {} values. {}{}See $ gcloud topic escaping for details on using alternate delimiters.)	r  r  r   r   r"   r2   r  r5   rA   )r4   item_help_textr7   s     r   r  List.BuildHelpText  s    ]]002N  ))&--nQR.@An		"	"4	(	()001CDn	fE$356MMD$$&'N#	%&r   c                     U R                   R                  U Vs/ s H  o R                  R                  U5      PM     sn5      $ s  snf )z.Returns the display string for the list value.)r  r   r  r   )r4   rD   items      r   r   List.Display  s6    ;;UKUT]]2248UKLLKs   $Ac                     U R                   /$ z8Returns the list of concepts that this concept marshals.)r  r>   s    r   MarshalList.Marshal  s    MM?r   c                    / n UR                   nU R                  U5      u  oPl        U HC  n[        R                  " U5      nUR                  U R                  R                  U5      5        ME     U R                  U5      nU R                  U5        U R!                  U5      $ ! [        R                   a@  nU R                  (       d   SnAg[        R
                  " U R                  5       U5      eSnAff = f)z1Parses the list from dependencies and returns it.N)rD   rE   rF   rG   r	   rH   rI   r   r  r   DependencyViewFromValuerh   r  rK   r   r   r   )r4   rJ   
list_valuerD   r   itemsr  item_dependenciess           r   rK   
List.Parse  s    J)  e U+E;-EEdK++,=>?  j)JMM*>>*%% ** )]]33

"
"
$a) ))s   B$ $C88C3%C33C8)r  r  re   rT   rU   rV   rW   rX   r3   r  r   r  rK   rY   rZ   r[   s   @r   r  r    s'    ,
& M& &r   r  c                   N   ^  \ rS rSrSrS	U 4S jjrU 4S jrS rS rS r	Sr
U =r$ )
Dicti  aD  A dict attribute concept.

Attributes:
  _delim: string, the user specified lit item delimiter character.
  _entries: {string: ConceptType}, the map of concept type names to
    concept type objects.
  _additional: ConceptType, uninstantiated type used for unknown keys.
    If not specified then unknown keys are an error.
c                    > [         [        U ]
  " U4SS0UD6  U R                  U l        0 U l        U(       a!  U H  nXPR
                  UR                  '   M     U R
                  (       d  U(       d  [        nX0l        g )Nr   znumber of entries)	r2   r  r3   r   r  _entriesr5   r  _additional)r4   r5   entries
additionalr6   entryr7   s         r   r3   Dict.__init__  sj    	$=1=5;=%%DKDM%$)ejj! ==j!r   c                 4  > [         R                  " 5       nUR                  S5        [        [        R
                  " U R                  5      5       H3  u  p#UR                  SR                  X#R                  5       5      5        M5     U R                  (       a  SnU R                  (       a  SnOSnU R                  S5      R                  5       nUR                  S5      (       a  SR                  US	S
 5      nO*UR                  S5      (       a  SR                  US	S
 5      nUR                  SR                  XV5      5        OSnSR                  [        [        [        U ]#  5       5      [        U R                  5       5      UUR                  5       5      $ )z.Appends dict syntax to the original help text.r	  r
  mayz#Additional _key_ names are allowed.zAny _key_ name is accepted.*r  zEach _value_ m{}r   Nr  zEach _value_ is a{}z```*```::: {} {}
mustzd{}Must be a string representing a list of `,` separated _key_=_value_ pairs. {}_key_ {} be one of:{})r  r  r  r  r   r  r  r   r  r  r   r"   r2   r  rA   r  )r4   r  r  r  may_mustr!   value_help_textr7   s          r   r  Dict.BuildHelpText  s@   
++-CIIgS]]4==9:
	ii%%c+>+>+@AB ;h	4,((-;;=o		#	#G	,	,,33OAB4GH%%d++/66qr7JK	ii$++DBCh	77=vE$356D$$&'LLN	8r   c                     U R                   R                  [        [        R                  " U5       VVs/ s H/  u  p#SR                  X R                  R                  U5      5      PM1     snn5      5      $ s  snnf )z.Returns the display string for the dict value.z{}={})r  r   r  r   r  r   r  r   )r4   rD   kvs       r   r   Dict.Display  si    ;;F03e0D$F0D %,NN1mm6K6KA6N$O0D$F G H H $Fs   6A6c                 6    U R                   R                  5       $ r  )r  valuesr>   s    r   r  Dict.Marshal  s    ==!!r   c                 l   0 n UR                   nU R                  U5      u  oPl        U H  nUR                  SS5      u  pxU R                  R                  U5      n	U	(       dV  U R                  (       d4  [        R                  " U R                  5       SR                  U5      5      eU R                  U5      n	[        R                  " UR                   R                  U5      5      n
 Xl         U	R)                  U
5      X''   M     U R+                  U5      nU R-                  U5        U R/                  U5      $ ! [        R                   a@  nU R                  (       d   SnAg[        R
                  " U R                  5       U5      eSnAff = f! ["         a    [$        R&                  " U5      n
 Nf = f)z1Parses the dict from dependencies and returns it.N=r   zUnknown dictionary key [{}].)rD   rE   rF   rG   r	   rH   rI   r   r  r   r  r   r  r   r   rf   marshalled_dependenciesr   r   r  rK   r   r   r   )r4   rJ   
dict_valuerD   r   r  r  r  valr  r  s              r   rK   
Dict.Parse
  s|   J)  e U+E;C#hcmm$e%%&&(,33C8: :   %))L$H$H$L$L
% M"% $56jo   j)JMM*>>*%%1 ** )]]33

"
"
$a) ))&  M/GGLMs/   D9 )F9FF#%FF F32F3)r  r  r  r   r  r[   s   @r   r  r    s'    
"8H
"& &r   r  ).rX   
__future__r   r   r   rf   r  r    googlecloudsdk.calliope.conceptsr   rE   #googlecloudsdk.command_lib.conceptsr   r   r	   r
   googlecloudsdk.core.utilr   r   r   r   r   r"   r$   Conceptr&   r]   r   objectr   r   r   r   r   r   r  r  r)  rE  rL  rU  rd  rz  r  r  r  r;   r   r   <module>r     sj   & '  '  	 	 = 4 C : 5 3 + * 
*Z3 Z3z3Lt|| 3LlE	) E	Pv \1 \1~9&7 9&xk B(k (@!I; !IH1$ 1*( *>YJ. YJx)- ):)& )B' 61) 1h+:* +:\D' D<6&! 6&rY&! Y&r   