'Implement function'

def func(self):

    caller = self.caller
    switches = self.switches
    (lhs, rhs) = (self.lhs, self.rhs)
    if (not self.args):
        string = 'Usage:    @perm[/switch]    object    [    =    permission,    permission,    ...]'
        caller.msg(string)
        return
    playermode = (('player' in self.switches) or lhs.startswith('*'))
    lhs = lhs.lstrip('*')
    if playermode:
        obj = caller.search_player(lhs)
    else:
        obj = caller.search(lhs, global_search=True)
    if (not obj):
        return
    if (not rhs):
        if (not obj.access(caller, 'examine')):
            caller.msg('You    are    not    allowed    to    examine    this    object.')
            return
        string = ('Permissions    on    |w%s|n:    ' % obj.key)
        if (not obj.permissions.all()):
            string += '<None>'
        else:
            string += ',    '.join(obj.permissions.all())
            if (hasattr(obj, 'player') and hasattr(obj.player, 'is_superuser') and obj.player.is_superuser):
                string += '\n(...    but    this    object    is    currently    controlled    by    a    SUPERUSER!    '
                string += 'All    access    checks    are    passed    automatically.)'
        caller.msg(string)
        return
    locktype = ('edit' if playermode else 'control')
    if (not obj.access(caller, locktype)):
        caller.msg(("You    are    not    allowed    to    edit    this    %s's    permissions." % ('player' if playermode else 'object')))
        return
    caller_result = []
    target_result = []
    if ('del' in switches):
        for perm in self.rhslist:
            obj.permissions.remove(perm)
            if obj.permissions.get(perm):
                caller_result.append(('\nPermissions    %s    could    not    be    removed    from    %s.' % (perm, obj.name)))
            else:
                caller_result.append(('\nPermission    %s    removed    from    %s    (if    they    existed).' % (perm, obj.name)))
                target_result.append(('\n%s    revokes    the    permission(s)    %s    from    you.' % (caller.name, perm)))
    else:
        permissions = obj.permissions.all()
        for perm in self.rhslist:
            if ((perm.lower() in PERMISSION_HIERARCHY) and (not obj.locks.check_lockstring(caller, ('dummy:perm(%s)' % perm)))):
                caller.msg('You    cannot    assign    a    permission    higher    than    the    one    you    have    yourself.')
                return
            if (perm in permissions):
                caller_result.append(("\nPermission    '%s'    is    already    defined    on    %s." % (rhs, obj.name)))
            else:
                obj.permissions.add(perm)
                plystring = ('the    Player' if playermode else 'the    Object/Character')
                caller_result.append(("\nPermission    '%s'    given    to    %s    (%s)." % (rhs, obj.name, plystring)))
                target_result.append(("\n%s    gives    you    (%s,    %s)    the    permission    '%s'." % (caller.name, obj.name, plystring, rhs)))
    caller.msg(''.join(caller_result).strip())
    if target_result:
        obj.msg(''.join(target_result).strip())
