def MI_parse_args(self, args, ingore_index2=False, allow_new=False):
empty = len(self.indices) == <NUM_LIT:0><EOL>if empty and not allow_new:<EOL><INDENT>raise KeyError('<STR_LIT>' % (args,))<EOL><DEDENT>names = force_list(self.indices.keys())<EOL>Nargs = len(args) if isinstance(args, tuple) else <NUM_LIT:1><EOL>_default = object()<EOL>index1 = index2 = _default<EOL>if isinstance(args, tuple):<EOL><INDENT>for _ in (<NUM_LIT:1>,):<EOL><INDENT>if ingore_index2:<EOL><INDENT>continue<EOL><DEDENT>if isinstance(args[<NUM_LIT:0>], slice):<EOL><INDENT>index1, key = args[<NUM_LIT:0>].start, args[<NUM_LIT:0>].stop<EOL>if Nargs == <NUM_LIT:2>:<EOL><INDENT>index2 = args[<NUM_LIT:1>]<EOL><DEDENT>elif Nargs > <NUM_LIT:2>:<EOL><INDENT>index2 = args[<NUM_LIT:1>:]<EOL><DEDENT>break<EOL><DEDENT>if Nargs > <NUM_LIT:1> and isinstance(args[<NUM_LIT:1>], (list, slice)):<EOL><INDENT>if Nargs == <NUM_LIT:2>:<EOL><INDENT>key, index2 = args<EOL>break<EOL><DEDENT>else:<EOL><INDENT>raise KeyError('<STR_LIT>' % (args[<NUM_LIT:2>:],))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>key = args<EOL><DEDENT><DEDENT>elif isinstance(args, slice):<EOL><INDENT>index1, key = args.start, args.stop<EOL><DEDENT>else:<EOL><INDENT>key = args<EOL><DEDENT>if empty: <EOL><INDENT>index1_last = False<EOL>exist_names = []  <EOL>if index1 is not _default:<EOL><INDENT>if index1 is None: <EOL><INDENT>index1_last = True<EOL>index1 = _default<EOL><DEDENT>elif isinstance(index1, int):<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' % (index1,))<EOL><DEDENT>else:<EOL><INDENT>MI_check_index_name(index1)<EOL>exist_names.append(index1)<EOL><DEDENT><DEDENT>if index2 is not _default:<EOL><INDENT>if isinstance(index2, (tuple, list)):<EOL><INDENT>map(MI_check_index_name, index2)<EOL>exist_names.extend(index2)<EOL><DEDENT>elif isinstance(index2, (int, slice)):<EOL><INDENT>raise TypeError('<STR_LIT>'<EOL>'<STR_LIT>' % (index2,))<EOL><DEDENT>else:<EOL><INDENT>MI_check_index_name(index2)<EOL>exist_names.append(index2)<EOL><DEDENT><DEDENT>if index1 is _default:<EOL><INDENT>if index1_last:<EOL><INDENT>if len(exist_names) > <NUM_LIT:1>: <EOL><INDENT>name1 = '<STR_LIT>' % (len(exist_names) + <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>name1 = '<STR_LIT>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>name1 = '<STR_LIT>'<EOL><DEDENT>index1 = get_unique_name(name1, exist_names)<EOL>exist_names.append(index1)<EOL><DEDENT>if index2 is _default:<EOL><INDENT>name2 = '<STR_LIT>' if index1_last else '<STR_LIT>'<EOL>index2 = get_unique_name(name2, exist_names)<EOL><DEDENT>return index1, key, index2, index1_last<EOL><DEDENT>if index1 is _default:  <EOL><INDENT>index1 = <NUM_LIT:0><EOL><DEDENT>elif index1 is None:  <EOL><INDENT>index1 = -<NUM_LIT:1><EOL><DEDENT>index1 = _key_to_index_single(names, index1)<EOL>try:<EOL><INDENT>item = MI_get_item(self, key, index1)<EOL><DEDENT>except KeyError:<EOL><INDENT>if allow_new:  <EOL><INDENT>item = None<EOL><DEDENT>else:<EOL><INDENT>raise KeyError('<STR_LIT>' %<EOL>(index1, names[index1], key))<EOL><DEDENT><DEDENT>if ingore_index2:  <EOL><INDENT>return item<EOL><DEDENT>if index2 is _default:  <EOL><INDENT>if len(names) == <NUM_LIT:1>:<EOL><INDENT>index2 = <NUM_LIT:0>  <EOL><DEDENT>else:<EOL><INDENT>index2 = force_list(range(len(names)))<EOL>index2.remove(index1)<EOL>if len(index2) == <NUM_LIT:1>:  <EOL><INDENT>index2 = index2[<NUM_LIT:0>]<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>index2 = _key_to_index(names, index2)<EOL><DEDENT>if item is None:  <EOL><INDENT>return index1, key, index2, None, None<EOL>
Parse the arguments for indexing in MIDict.

Full syntax: ``d[index1:key, index2]``.

``index2`` can be flexible indexing (int, list, slice etc.) as in ``IndexDict``.

Short syntax:

* d[key] <==> d[key,] <==> d[first_index:key, all_indice_except_first]
* d[:key] <==> d[:key,] <==> d[None:key] <==> d[last_index:key, all_indice_except_last]
* d[key, index2] <==> d[first_index:key, index2] # this is valid
  # only when index2 is a list or slice object
* d[index1:key, index2_1, index2_2, ...] <==> d[index1:key, (index2_1, index2_2, ...)]