
    iT
                     J    S r SSKJr  SSKrSSKJr  SSKJr  S	S jrS r	S r
g)
z%Common utility functions used by kgb.    )unicode_literalsN)	safe_repr)	iteritemsc                    U(       d  U R                   nX;   a  X1   $ [        R                  " U 5      (       d  [        U R                  U5      $ U R
                   H  n [        XA5      s  $    [        e! [         a     M&  f = f)a  Return a value as defined in a class, instance, or ancestor.

This will look for the real definition, and not the definition returned
when accessing the attribute or instantiating a class. This will bypass any
descriptors and return the actual definition from the instance or class
that defines it.

Args:
    owner (type or object):
        The owner of the attribute.

    name (unicode):
        The name of the attribute.

    ancestors_only (bool, optional):
        Whether to only look in ancestors of ``owner``, and not in
        ``owner`` itself.

Returns:
    object:
    The attribute value.

Raises:
    AttributeError:
        The attribute could not be found.
)__dict__inspectisclassget_defined_attr_value	__class__	__bases__AttributeError)ownernameancestors_onlyd
parent_clss        H/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/kgb/utils.pyr
   r
      sx    6 NN97N??5!! &eoot<<oo
	)*;; &   		s   
A33
B Bc                 :     [        XSS9  g! [         a     gf = f)zReturn whether an attribute is defined on an ancestor of a class.

Args:
    name (unicode):
        The name of the attribute.

Returns:
    bool:
    ``True`` if an ancestor defined the attribute. ``False`` if it did not.
T)r   F)r
   r   )clsr   s     r   is_attr_defined_on_ancestorr   ;   s&    s> s   
 
c           	      \    SSR                  S [        [        U 5      S S9 5       5      -  $ )a?  Format keyword arguments.

This will convert all keys to native strings, to help with showing
more reasonable output that's consistent. The keys will also be
provided in sorted order.

Args:
    kwargs (dict):
        The dictionary of keyword arguments.

Returns:
    unicode:
    The formatted string representation.
z{%s}z, c              3   n   #    U  H+  u  p[        [        U5      5      < S [        U5      < 3v   M-     g7f)z: N)r   str).0keyvalues      r   	<genexpr>$format_spy_kwargs.<locals>.<genexpr>\   s0      ;JC c#h'5)9:;s   35c                     U S   $ )Nr    )pairs    r   <lambda>#format_spy_kwargs.<locals>.<lambda>_   s    $q'    )r   )joinsortedr   )kwargss    r   format_spy_kwargsr(   M   s8     DII  6!2%9;   r$   )F)__doc__
__future__r   r   unittest.utilr   kgb.pycompatr   r
   r   r(   r    r$   r   <module>r-      s$    + '  # "-`$r$   