

def func(self):
    'Sets up the command'
    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 objname.switches):
                if (not obj.access(caller, 'control')):
                    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')):
            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 ok:
            caller.msg(("Added lock '%s' to %s." % (lockdef, obj)))
        return
    obj = caller.search(self.lhs)
    if (not obj):
        return
    caller.msg(obj.locks)

dataset/ETHPy150Open evennia/evennia/evennia/commands/default/building.py CmdLock.func/VarMisuse@124/174 `self`->`objname`