U
    ,ºcÄ
  ã                	   @   s”   d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlZe	ej
ejeeeeƒedƒeeƒfZdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ ZdS )zTypes of values.é    )Úabsolute_import)Údivision)Úprint_functionN)Úinspectutilsc                 C   s   t | ƒ ot| ƒ S ©N)Ú	IsCommandÚIsValue©Ú	component© r   ú4/tmp/pip-unpacked-wheel-1xt1w7un/fire/value_types.pyÚIsGroup   s    r   c                 C   s   t  | ¡pt  | ¡S r   )ÚinspectÚ	isroutineÚisclassr	   r   r   r   r   $   s    r   c                 C   s   t | tƒpt| ƒS r   )Ú
isinstanceÚVALUE_TYPESÚHasCustomStrr	   r   r   r   r   (   s    r   c                 C   s@   t | tƒst‚|  ¡ D ]$\}}t|ƒst |ttfƒs dS qdS )aZ  If a group is simple enough, then we treat it as a value in PrintResult.

  Only if a group contains all value types do we consider it simple enough to
  print as a value.

  Args:
    component: The group to check for value-group status.
  Returns:
    A boolean indicating if the group should be treated as a value for printing
    purposes.
  FT)r   ÚdictÚAssertionErrorÚitemsr   Úlist)r
   Z
unused_keyÚvaluer   r   r   ÚIsSimpleGroup,   s
    r   c                 C   s<   t | dƒr8t t| ƒ¡pi }| d¡}|r8|jtk	r8dS dS )a“  Determines if a component has a custom __str__ method.

  Uses inspect.classify_class_attrs to determine the origin of the object's
  __str__ method, if one is present. If it defined by `object` itself, then
  it is not considered custom. Otherwise it is. This means that the __str__
  methods of primitives like ints and floats are considered custom.

  Objects with custom __str__ methods are treated as values and can be
  serialized in places where more complex objects would have their help screen
  shown instead.

  Args:
    component: The object to check for a custom __str__ method.
  Returns:
    Whether `component` has a custom __str__ method.
  Ú__str__TF)Úhasattrr   ZGetClassAttrsDictÚtypeÚgetÚdefining_classÚobject)r
   Zclass_attrsZstr_attrr   r   r   r   ?   s    

r   )Ú__doc__Ú
__future__r   r   r   r   Zfirer   ÚsixÚboolÚstring_typesÚinteger_typesÚfloatÚcomplexr   ÚEllipsisÚNotImplementedr   r   r   r   r   r   r   r   r   r   Ú<module>   s      ÿ