
    |h%                         d Z ddlZddlZddlZej                  dd dk  rej
                  Znej                  Zd Zd Z	d Z
d Zd	 Zy)
z3Provides parsing functionality used by Python Fire.    N   )      c                  *   t        j                  d      } | j                  ddd       | j                  ddd       | j                  d	d
       | j                  dddt               | j                  ddd       | j                  ddd       | S )NF)add_helpz	--verbosez-v
store_true)actionz--interactivez-iz--separator-)defaultz--completion?bash)nargsconsttypez--helpz-hz--tracez-t)argparseArgumentParseradd_argumentstr)parsers    J/var/www/html/test/engine/venv/lib/python3.12/site-packages/fire/parser.pyCreateParserr      s    ""E2&k4=otLAmS1nCvCHh\:il;	-    c                     d| v r7t        |       dz
  | ddd   j                  d      z
  }| |dz   d }| d| } | |fS | g fS )a  Splits a list of args into those for Flags and those for Fire.

  If an isolated '--' arg is not present in the arg list, then all of the args
  are for Fire. If there is an isolated '--', then the args after the final '--'
  are flag args, and the rest of the args are fire args.

  Args:
    args: The list of arguments received by the Fire command.
  Returns:
    A tuple with the Fire args (a list), followed by the Flag args (a list).
  z--   N)lenindex)argsseparator_index	flag_argss      r   SeparateFlagArgsr!   '   sb     
T\$i!md4R4j&6&6t&<<O_q()*I !D?	r/r   c                 H    	 t        |       S # t        t        f$ r | cY S w xY w)a  The default argument parsing function used by Fire CLIs.

  If the value is made of only Python literals and containers, then the value
  is parsed as it's Python value. Otherwise, provided the value contains no
  quote, escape, or parenthetical characters, the value is treated as a string.

  Args:
    value: A string from the command line to be parsed for use in a Fire CLI.
  Returns:
    The parsed value, of the type determined most appropriate.
  )_LiteralEvalSyntaxError
ValueError)values    r   DefaultParseValuer'   ;   s+    
z	" Ls   
 !!c                 &   t        j                  | d      }t        |j                  t         j                        rt        |       t        j                  |      D ]  }t        j                  |      D ]  \  }}t        |t              r=t        |      D ].  \  }}t        |t         j                        s!t        |      ||<   0 St        |t         j                        snt        |      }t        |||         t        j                  |      S )a  Parse value as a Python literal, or container of containers and literals.

  First the AST of the value is updated so that bare-words are turned into
  strings. Then the resulting AST is evaluated as a literal or container of
  only containers and literals.

  This allows for the YAML-like syntax {a: b} to represent the dict {'a': 'b'}

  Args:
    value: A string to be parsed as a literal or container of containers and
      literals.
  Returns:
    The Python value representing the value arg.
  Raises:
    ValueError: If the value is not an expression with only containers and
      literals.
    SyntaxError: If the value string has a syntax error.
  eval)mode)astparse
isinstancebodyBinOpr%   walkiter_fieldslist	enumerateName_Replacementsetattrliteral_eval)r&   rootnodefieldchildr   subchildreplacements           r   r#   r#   O   s    & 
5v	&$		399%
U
hhtn 	*d- *u	E4	 (/ 	2OE8#((+'1E%L	2 eSXX&"5)e[)*	* 
		$	r   c                 <    | j                   }|dv r| S t        |      S )a#  Returns a node to use in place of the supplied node in the AST.

  Args:
    node: A node of type Name. Could be a variable, or builtin constant.
  Returns:
    A node to use in place of the supplied Node. Either the same node, or a
    String node whose value matches the Name node's id.
  )TrueFalseNone)id_StrNode)r9   r&   s     r   r5   r5   w   s%     ''%
''K	%r   )__doc__r   r+   sysversion_infoStrrC   Constantr   r!   r'   r#   r5    r   r   <module>rJ      sT    :  
 
Aa6!WW(\\(	((% Pr   