@logs<EOL><INDENT>def _getPattern(self, ipattern, done=None):<DEDENT>
if ipattern is None:<EOL><INDENT>return None<EOL><DEDENT>if ipattern is True:<EOL><INDENT>if done is not None:<EOL><INDENT>return ([(None, None, done)], {})<EOL><DEDENT>return ([(<NUM_LIT:0>, False)], {})<EOL><DEDENT>def _getReverse(pm):<EOL><INDENT>return pm == '<STR_LIT:->'<EOL><DEDENT>def _getIndex(k):<EOL><INDENT>try:<EOL><INDENT>return int(k)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise InvalidPatternError(k, "<STR_LIT>")<EOL><DEDENT><DEDENT>def _getDone(p):<EOL><INDENT>v = p.split('<STR_LIT:=>')<EOL>if len(v) == <NUM_LIT:2>:<EOL><INDENT>try:<EOL><INDENT>return (Model.indexes[v[<NUM_LIT:0>]], v[<NUM_LIT:1>], done)<EOL><DEDENT>except KeyError:<EOL><INDENT>raise InvalidPatternError(v[<NUM_LIT:0>], '<STR_LIT>')<EOL><DEDENT><DEDENT>return (None, v[<NUM_LIT:0>], done)<EOL><DEDENT>ipattern1 = list()<EOL>ipattern2 = dict()<EOL>for s in ipattern.split('<STR_LIT:U+002C>'):<EOL><INDENT>if done is not None:<EOL><INDENT>v = done<EOL><DEDENT>else:<EOL><INDENT>v = _getReverse(s[-<NUM_LIT:1>])<EOL><DEDENT>k = s.split('<STR_LIT::>')<EOL>if len(k) == <NUM_LIT:1>:<EOL><INDENT>if done is not None:<EOL><INDENT>ipattern1.append(_getDone(k[<NUM_LIT:0>]))<EOL>continue<EOL><DEDENT>ko = k[<NUM_LIT:0>][:-<NUM_LIT:1>]<EOL>try:<EOL><INDENT>if len(k[<NUM_LIT:0>]) == <NUM_LIT:1>:<EOL><INDENT>k = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>k = Model.indexes[ko]<EOL><DEDENT><DEDENT>except KeyError:<EOL><INDENT>k = _getIndex(k[<NUM_LIT:0>][:-<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>ipattern1.append((k, v))<EOL>continue<EOL><DEDENT>v = (<NUM_LIT:0>, v)<EOL><DEDENT>elif len(k) == <NUM_LIT:2>:<EOL><INDENT>try:<EOL><INDENT>if done is not None:<EOL><INDENT>v = _getDone(k[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>v = (Model.indexes[k[<NUM_LIT:1>][:-<NUM_LIT:1>]], v)<EOL><DEDENT>k = _getIndex(k[<NUM_LIT:0>])<EOL><DEDENT>except KeyError:<EOL><INDENT>raise InvalidPatternError(k[<NUM_LIT:1>][:-<NUM_LIT:1>], '<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise InvalidPatternError(s, '<STR_LIT>')<EOL><DEDENT>ipattern2.setdefault(k, []).append(v)<EOL><DEDENT>return (ipattern1, ipattern2)<EOL>
Parses sort pattern.

        :ipattern: A pattern to parse.
        :done:  If :ipattern: refers to done|undone,
        use this to indicate proper state.
        :returns: A pattern suitable for Model.modify.