
    |h                     L    d Z ddlmZ dZdZd Zd Zd ZeefeefdZd	 Z	d
 Z
y)a  Custom descriptions and summaries for the builtin types.

The docstrings for objects of primitive types reflect the type of the object,
rather than the object itself. For example, the docstring for any dict is this:

> print({'key': 'value'}.__doc__)
dict() -> new empty dictionary
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs
dict(iterable) -> new dictionary initialized as if via:
    d = {}
    for k, v in iterable:
        d[k] = v
dict(**kwargs) -> new dictionary initialized with the name=value pairs
    in the keyword argument list.  For example:  dict(one=1, two=2)

As you can see, this docstring is more pertinent to the function `dict` and
would be suitable as the result of `dict.__doc__`, but is wholely unsuitable
as a description for the dict `{'key': 'value'}`.

This modules aims to resolve that problem, providing custom summaries and
descriptions for primitive typed values.
    )
formattingz""zThe string c                     t        |       }|t        t        t        fv s0|t        t
        t        fv s|t        t        t        t        t        fv ryy)a~  Whether the component should use a custom description and summary.

  Components of primitive type, such as ints, floats, dicts, lists, and others
  have messy builtin docstrings. These are inappropriate for display as
  descriptions and summaries in a CLI. This function determines whether the
  provided component has one of these docstrings.

  Note that an object such as `int` has the same docstring as an int like `3`.
  The docstring is OK for `int`, but is inappropriate as a docstring for `3`.

  Args:
    component: The component of interest.
  Returns:
    Whether the component should use a custom description and summary.
  TF)typestrintbytesfloatcomplexbooldicttuplelistset	frozenset)	componenttype_s     W/var/www/html/test/engine/venv/lib/python3.12/site-packages/fire/custom_descriptions.pyNeedsCustomDescriptionr   -   sD      y/%S%  	5'4(	(	4c95	5	    c                    t        |       t        t              z   |k  r| }nWt        t              t        t        j                        z   }||k  r|}t        j                  | |t        t              z
  |      }t        j
                  |      S )a  Returns a custom summary for string type objects.

  This function constructs a summary for string type objects by double quoting
  the string value. The double quoted string value will be potentially truncated
  with ellipsis depending on whether it has enough space available to show the
  full string value.

  Args:
    obj: The object to generate summary for.
    available_space: Number of character spaces available.
    line_length: The full width of the terminal, default is 80.

  Returns:
    A summary for the input object.
  )lenTWO_DOUBLE_QUOTESr   ELLIPSISEllipsisTruncateDoubleQuote)objavailable_spaceline_lengthcontentadditional_len_neededs        r   GetStringTypeSummaryr!   G   s~      	X%&&/9G 12S9L9L5MM..#o))_s#455{DG				((r   c           
      $   t        t              t        t              z   t        t        j                        z   }||k  r|}t        t        j
                  t        j                  | |t        t              z
  t        t              z
  |            z   S )a  Returns the predefined description for string obj.

  This function constructs a description for string type objects in the format
  of 'The string "<string_value>"'. <string_value> could be potentially
  truncated depending on whether it has enough space available to show the full
  string value.

  Args:
    obj: The object to generate description for.
    available_space: Number of character spaces available.
    line_length: The full width of the terminal, default if 80.

  Returns:
    A description for input object.
  )r   STRING_DESC_PREFIXr   r   r   r   r   )r   r   r   r    s       r   GetStringTypeDescriptionr$   b   s      01C5 z2234,,!O	j44!!
%7!88

 !"-/0 
0 0r   )r   unicodec                 |    t        |       j                  }|t        v rt        j                  |      d   | ||      S y )Nr   r   __name__CUSTOM_DESC_SUM_FN_DICTgetr   r   r   obj_type_names       r   
GetSummaryr-      C    s)$$---"&&}5a8o9DF F	r   c                 |    t        |       j                  }|t        v rt        j                  |      d   | ||      S y )N   r'   r+   s       r   GetDescriptionr1      r.   r   N)__doc__firer   r   r#   r   r!   r$   r)   r-   r1    r   r   <module>r5      sP   0  " 4)608 !":;$&>? r   