

def create_exit(self, exit_name, location, destination, exit_aliases=None, typeclass=None):
    '\n        Helper function to avoid code duplication.\n        At this point we know destination is a valid location\n\n        '
    caller = self.caller
    string = ''
    exit_obj = caller.search(exit_name, location=location, quiet=True, exact=True)
    if (len(exit_obj) > 1):
        caller.search(exit_name, location=location, exact=True)
        return
    if exit_obj:
        exit_obj = exit_obj[0]
        if (not exit_obj.destination):
            string = "'%s' already exists and is not an exit!\nIf you want to convert it "
            string += "to an exit, you must assign an object to the 'destination' property first."
            caller.msg((string % exit_name))
            return None
        old_destination = exit_obj.destination
        if old_destination:
            string = ('Exit %s already exists.' % exit_name)
            if (old_destination.id != destination.id):
                exit_obj.destination = destination
                [exit_obj.aliases.add(alias) for alias in exit_aliases]
                string += (" Rerouted its old destination '%s' to '%s' and changed aliases." % (old_destination.name, destination.name))
            else:
                string += ' It already points to the correct place.'
    else:
        if (not typeclass):
            typeclass = settings.BASE_EXIT_TYPECLASS
        exit_obj = create.create_object(typeclass, key=exit_name, location=location, aliases=exit_aliases, report_to=caller)
        if exit_obj:
            exit_obj.destination = destination
            string = ("Created new Exit '%s' from %s to %s (aliases: %s)." % (exit_name, location.name, destination.name, ', '.join([str(e) for e in exit_aliases])))
        else:
            string = ("Error: Exit '%s' not created." % exit_name)
    caller.msg(string)
    return exit_obj

dataset/ETHPy150Open evennia/evennia/evennia/commands/default/building.py CmdOpen.create_exit/original