def _extend_object(parent, n, o, otype, fqdn):
    """Extends the specified object if it needs to be extended. The method
    attempts to add an attribute to the object; if it fails, a new object is
    created that inherits all of `o` attributes, but is now a regular object
    that can have attributes set.

    Args:
        parent: has `n` in its `__dict__` attribute.
        n (str): object name attribute.
        o (list): object instances to be extended.
        otype (str): object types; one of ["classes", "functions", "methods",
          "modules"].
        fqdn (str): fully qualified name of the package that the object belongs
          to.
    """
    from inspect import ismodule, isclass
    pmodule = parent if ismodule(parent) or isclass(parent) else None
    try:
        #The __acornext__ attribute references the original, unextended
        #object; if the object didn't need extended, then __acornext__ is
        #none.
        if otype == "methods":
            setattr(o.__func__, "__acornext__", None)
        else:
            setattr(o, "__acornext__", None)

        fqdn = _fqdn(o, recheck=True, pmodule=pmodule)
        return o
    except (TypeError, AttributeError):
        #We have a built-in or extension type. 
        okey = id(o)
        if okey not in _extended_objs:
            #We need to generate an extension for this object and store it
            #in the extensions dict.
            xobj = _create_extension(o, otype, fqdn, pmodule)
            fqdn = _fqdn(xobj, recheck=True, pmodule=pmodule)
            if xobj is not None:
                _extended_objs[okey] = xobj
            #else: we can't handle this kind of object; it just won't be
            #logged...
        try:
            setattr(parent, n, _extended_objs[okey])
            return _extended_objs[okey]
        except KeyError: # pragma: no cover
            msg.warn("Object extension failed: {} ({}).".format(o, otype))
def _extend_object ( parent , n , o , otype , fqdn ) : from inspect import ismodule , isclass pmodule = parent if ismodule ( parent ) or isclass ( parent ) else None try : if otype == "methods" : setattr ( o . __func__ , "__acornext__" , None ) else : setattr ( o , "__acornext__" , None ) fqdn = _fqdn ( o , recheck = True , pmodule = pmodule ) return o except ( TypeError , AttributeError ) : okey = id ( o ) if okey not in _extended_objs : xobj = _create_extension ( o , otype , fqdn , pmodule ) fqdn = _fqdn ( xobj , recheck = True , pmodule = pmodule ) if xobj is not None : _extended_objs [ okey ] = xobj try : setattr ( parent , n , _extended_objs [ okey ] ) return _extended_objs [ okey ] except KeyError : msg . warn ( "Object extension failed: {} ({})." . format ( o , otype ) )
Extends the specified object if it needs to be extended. The method
    attempts to add an attribute to the object; if it fails, a new object is
    created that inherits all of `o` attributes, but is now a regular object
    that can have attributes set.

    Args:
        parent: has `n` in its `__dict__` attribute.
        n (str): object name attribute.
        o (list): object instances to be extended.
        otype (str): object types; one of ["classes", "functions", "methods",
          "modules"].
        fqdn (str): fully qualified name of the package that the object belongs
          to.