

def func(self):
    'Implements command'
    caller = self.caller
    if (not self.args):
        caller.msg(('Usage: %s <object> [=<typeclass]' % self.cmdstring))
        return
    obj = caller.search(self.lhs)
    if (not obj):
        return
    if (not hasattr(obj, '__dbclass__')):
        string = ('%s is not a typed object.' % obj.name)
        caller.msg(string)
        return
    new_typeclass = (self.rhs or obj.path)
    if ('show' in self.switches):
        string = ("%s's current typeclass is %s." % (obj.name, obj.__class__))
        return
    if (self.cmdstring == '@swap'):
        self.switches.append('force')
        self.switches.append('reset')
    if (not obj.access(caller, 'edit')):
        caller.msg('You are not allowed to do that.')
        return
    if (not hasattr(obj, 'swap_typeclass')):
        caller.msg('This object cannot have a type at all!')
        return
    is_same = obj.is_typeclass(new_typeclass, exact=True)
    if (is_same and (not ('force' in self.switches))):
        string = ("%s already has the typeclass '%s'. Use /force to override." % (obj.name, new_typeclass))
    else:
        reset = ('reset' in self.switches)
        old_typeclass_path = obj.typeclass_path
        obj.swap_typeclass(new_typeclass, clean_attributes=reset)
        if is_same:
            string = ('%s updated its existing typeclass (%s).\n' % (obj.name, obj.path))
        else:
            string = ('%s changed typeclass from %s to %s.\n' % (obj.name, old_typeclass_path, obj.typeclass_path))
        string += 'Creation hooks were run.'
        if reset:
            string += ' All old attributes where deleted before the swap.'
        else:
            string += ' Attributes set before swap were not removed.'
    caller.msg(string)

dataset/ETHPy150Open evennia/evennia/evennia/commands/default/building.py CmdTypeclass.func/original