def METHOD_NAME(self, perms):
    """
    Sets the state of this instance via the 'perms' string.
    Returns 'self'. Also used by the constructor which
    takes a string.
    """
    import re
    base = r"([rR\-_])([aAwW\-_])"
    regex = re.compile(r"^(L?)%s$" % (base*3))
    match = regex.match(perms)
    if match is None:
        raise ValueError("Invalid permission string: %s" % perms)
    ur = match.group(2)
    uw = match.group(3)
    gr = match.group(4)
    gw = match.group(5)
    wr = match.group(6)
    ww = match.group(7)
    # User
    self.setUserRead(ur.lower() == "r")
    self.setUserAnnotate(uw.lower() == "a")
    if uw.lower() == "w":
        self.setUserAnnotate(True)  # w implies a
        self.setUserWrite(True)
    else:
        self.setUserWrite(False)
    # Group
    self.setGroupRead(gr.lower() == "r")
    self.setGroupAnnotate(gw.lower() == "a")
    if gw.lower() == "w":
        self.setGroupAnnotate(True)  # w implies a
        self.setGroupWrite(True)
    else:
        self.setGroupWrite(False)
    # World
    self.setWorldRead(wr.lower() == "r")
    self.setWorldAnnotate(ww.lower() == "a")
    if ww.lower() == "w":
        self.setWorldAnnotate(True)  # w implies a
        self.setWorldWrite(True)
    else:
        self.setWorldWrite(False)
    return self