'Sets up the command'

def func(self):

    caller = self.caller
    if (not self.args):
        string = '@lock    <object>[    =    <lockstring>]    or    @lock[/switch]    <object>/<access_type>'
        caller.msg(string)
        return
    if ('/' in self.lhs):
        (objname, access_type) = [p.strip() for p in self.lhs.split('/', 1)]
        obj = caller.search(objname)
        if (not obj):
            return
        lockdef = obj.locks.get(access_type)
        string = ''
        if lockdef:
            if ('del' in self.switches):
                if (not (obj.access(caller, 'control') or obj.access(caller, 'edit'))):
                    caller.msg('You    are    not    allowed    to    do    that.')
                    return
                obj.locks.delete(access_type)
                string = ('deleted    lock    %s' % lockdef)
            else:
                string = lockdef
        else:
            string = ("%s    has    no    lock    of    access    type    '%s'." % (obj, access_type))
        caller.msg(string)
        return
    if self.rhs:
        if self.switches:
            swi = ',    '.join(self.switches)
            caller.msg(('Switch(es)    |w%s|n    can    not    be    used    with    a    lock    assignment.    Use    e.g.    |w@lock/del    objname/locktype|n    instead.' % swi))
            return
        (objname, lockdef) = (self.lhs, self.rhs)
        obj = caller.search(objname)
        if (not obj):
            return
        if (not (obj.access(caller, 'control') or obj.access(caller, 'edit'))):
            caller.msg('You    are    not    allowed    to    do    that.')
            return
        ok = False
        lockdef = re.sub('\\\'|\\"', '', lockdef)
        try:
            ok = obj.locks.add(lockdef)
        except LockException as e:
            caller.msg(str(e))
        if (('cmd' in lockdef.lower()) and inherits_from(obj, 'evennia.objects.objects.DefaultExit')):
            obj.at_init()
        if ok:
            caller.msg(("Added    lock    '%s'    to    %s." % (lockdef, obj)))
        return
    obj = caller.search(self.lhs)
    if (not obj):
        return
    caller.msg(obj.locks.all())
