'Helper function that creates a nice report about an object.
returns a string.'

def format_output(self, obj, avail_cmdset):

    string = ('\n|wName/key|n:    |c%s|n    (%s)' % (obj.name, obj.dbref))
    if (hasattr(obj, 'aliases') and obj.aliases.all()):
        string += ('\n|wAliases|n:    %s' % ',    '.join(utils.make_iter(str(obj.aliases))))
    if (hasattr(obj, 'sessions') and obj.sessions.all()):
        string += ('\n|wSession    id(s)|n:    %s' % ',    '.join((('#%i' % sess.sessid) for sess in obj.sessions.all())))
    if (hasattr(obj, 'email') and obj.email):
        string += ('\n|wEmail|n:    |c%s|n' % obj.email)
    if (hasattr(obj, 'has_player') and obj.has_player):
        string += ('\n|wPlayer|n:    |c%s|n' % obj.player.name)
        perms = obj.player.permissions.all()
        if obj.player.is_superuser:
            perms = ['<Superuser>']
        elif (not perms):
            perms = ['<None>']
        string += ('\n|wPlayer    Perms|n:    %s' % ',    '.join(perms))
        if obj.player.attributes.has('_quell'):
            string += '    |r(quelled)|n'
    string += ('\n|wTypeclass|n:    %s    (%s)' % (obj.typename, obj.typeclass_path))
    if hasattr(obj, 'location'):
        string += ('\n|wLocation|n:    %s' % obj.location)
        if obj.location:
            string += ('    (#%s)' % obj.location.id)
    if hasattr(obj, 'home'):
        string += ('\n|wHome|n:    %s' % obj.home)
        if obj.home:
            string += ('    (#%s)' % obj.home.id)
    if (hasattr(obj, 'destination') and obj.destination):
        string += ('\n|wDestination|n:    %s' % obj.destination)
        if obj.destination:
            string += ('    (#%s)' % obj.destination.id)
    perms = obj.permissions.all()
    if perms:
        perms_string = ',    '.join(perms)
    else:
        perms_string = '<None>'
    if obj.is_superuser:
        perms_string += '    [Superuser]'
    string += ('\n|wPermissions|n:    %s' % perms_string)
    locks = str(obj.locks)
    if locks:
        locks_string = utils.fill(';    '.join([lock for lock in locks.split(';')]), indent=6)
    else:
        locks_string = '    Default'
    string += ('\n|wLocks|n:%s' % locks_string)
    if (not ((len(obj.cmdset.all()) == 1) and (obj.cmdset.current.key == '_EMPTY_CMDSET'))):
        stored_cmdsets = sorted(obj.cmdset.all(), key=(lambda x: x.priority), reverse=True)
        string += ('\n|wStored    Cmdset(s)|n:\n    %s' % '\n    '.join((('%s    [%s]    (%s,    prio    %s)' % (cmdset.path, cmdset.key, cmdset.mergetype, cmdset.priority)) for cmdset in stored_cmdsets if (cmdset.key != '_EMPTY_CMDSET'))))
        all_cmdsets = [(cmdset.key, cmdset) for cmdset in avail_cmdset.merged_from]
        if (hasattr(obj, 'player') and obj.player):
            all_cmdsets.extend([(cmdset.key, cmdset) for cmdset in obj.player.cmdset.all()])
            if obj.sessions.count():
                all_cmdsets.extend([(cmdset.key, cmdset) for cmdset in obj.player.sessions.all()[0].cmdset.all()])
        else:
            try:
                all_cmdsets.extend([(cmdset.key, cmdset) for cmdset in obj.get_session(obj.sessions.get()).cmdset.all()])
            except (TypeError, AttributeError):
                pass
        all_cmdsets = [cmdset for cmdset in dict(all_cmdsets).values()]
        all_cmdsets.sort(key=(lambda x: x.priority), reverse=True)
        string += ('\n|wMerged    Cmdset(s)|n:\n    %s' % '\n    '.join((('%s    [%s]    (%s,    prio    %s)' % (cmdset.path, cmdset.key, cmdset.mergetype, cmdset.priority)) for cmdset in all_cmdsets)))
        avail_cmdset = sorted([cmd.key for cmd in avail_cmdset if cmd.access(obj, 'cmd')])
        cmdsetstr = utils.fill(',    '.join(avail_cmdset), indent=2)
        string += ('\n|wCommands    available    to    %s    (result    of    Merged    CmdSets)|n:\n    %s' % (obj.key, cmdsetstr))
    if (hasattr(obj, 'scripts') and hasattr(obj.scripts, 'all') and obj.scripts.all()):
        string += ('\n|wScripts|n:\n    %s' % obj.scripts)
    string += self.format_attributes(obj)
    tags_string = utils.fill(',    '.join((('%s[%s]' % (tag, category)) for (tag, category) in obj.tags.all(return_key_and_category=True))), indent=5)
    if tags_string:
        string += ('\n|wTags[category]|n:    %s' % tags_string.strip())
    exits = []
    pobjs = []
    things = []
    if hasattr(obj, 'contents'):
        for content in obj.contents:
            if content.destination:
                exits.append(content)
            elif content.player:
                pobjs.append(content)
            else:
                things.append(content)
        if exits:
            string += ('\n|wExits|n:    %s' % ',    '.join([('%s(%s)' % (exit.name, exit.dbref)) for exit in exits]))
        if pobjs:
            string += ('\n|wCharacters|n:    %s' % ',    '.join([('|c%s|n(%s)' % (pobj.name, pobj.dbref)) for pobj in pobjs]))
        if things:
            string += ('\n|wContents|n:    %s' % ',    '.join([('%s(%s)' % (cont.name, cont.dbref)) for cont in obj.contents if ((cont not in exits) and (cont not in pobjs))]))
    separator = ('-' * _DEFAULT_WIDTH)
    return ('%s\n%s\n%s' % (separator, string.strip(), separator))
