
    `j                     x    d Z ddlmZmZ ddlZdZdZdZd Zd Z	d	 Z
d
eeef         fdZd
eeef         fdZdS )zThese decorators provide function metadata to Python Fire.

SetParseFn and SetParseFns allow you to set the functions Fire uses for parsing
command line arguments to client code.
    )AnyDictNFIRE_METADATAFIRE_PARSE_FNSACCEPTS_POSITIONAL_ARGSc                       fd}|S )al  Sets the fn for Fire to use to parse args when calling the decorated fn.

  Args:
    fn: The function to be used for parsing arguments.
    *arguments: The arguments for which to use the parse fn. If none are listed,
      then this will set the default parse function.
  Returns:
    The decorated function, which now has metadata telling Fire how to perform.
  c                     t          |           }s|d<   nD ]}|d         |<   t          | t          |           | S )Ndefaultnamed)GetParseFns_SetMetadatar   )func	parse_fnsargument	argumentsfns      S/home/jworkman/hermes-web-chat/venv/lib/python3.11/site-packages/fire/decorators.py
_DecoratorzSetParseFn.<locals>._Decorator'   s]    D!!I *i	 * *(')	'8$$~y111K     )r   r   r   s   `` r   
SetParseFnr      s*          
r   c                        fd}|S )a  Set the fns for Fire to use to parse args when calling the decorated fn.

  Returns a decorator, which when applied to a function adds metadata to the
  function telling Fire how to turn string command line arguments into proper
  Python arguments with which to call the function.

  A parse function should accept a single string argument and return a value to
  be used in its place when calling the decorated function.

  Args:
    *positional: The functions to be used for parsing positional arguments.
    **named: The functions to be used for parsing named arguments.
  Returns:
    The decorated function, which now has metadata telling Fire how to perform.
  c                     t          |           }|d<   |d                                        t          | t          |           | S )N
positionalr   )r   updater   r   )r   r   r   r   s     r   r   zSetParseFns.<locals>._DecoratorD   sH    BI(Ilge$$$^Y///Ir   r   )r   r   r   s   `` r   SetParseFnsr   4   s*           
r   c                 Z    t          |           }|||<   t          | t          |           d S )N)GetMetadatasetattrr   )r   	attributevaluemetadatas       r   r   r   N   s/    __((9	"mX&&&&&r   returnc                     t           t          j        |           i}	 t          | t          |          }t           |v r|S |S #  |cY S xY w)zGets metadata attached to the function `fn` as an attribute.

  Args:
    fn: The function from which to retrieve the function metadata.
  Returns:
    A dictionary mapping property strings to their value.
  )r   inspect	isroutinegetattrr   )r   r
   r"   s      r   r   r   T   sX     w044'r='22H(**onNNNs    A  A   Ac                 b    t          |           }d g i d}|                    t          |          S )N)r
   r   r   )r   getr   )r   r"   r
   s      r   r   r   k   s0    __(B<<'	ng	.	..r   )__doc__typingr   r   r%   r   r   r   r   r   r   strr   r   r   r   r   <module>r-      s             !3   .  4' ' 'tCH~    ./tCH~ / / / / / /r   