def dump(obj, fp, startindex=<NUM_LIT:1>, separator=DEFAULT, index_separator=DEFAULT):
if startindex < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(startindex))<EOL><DEDENT>try:<EOL><INDENT>firstkey = next(iter(obj.keys()))<EOL><DEDENT>except StopIteration:<EOL><INDENT>return<EOL><DEDENT>if isinstance(firstkey, six.text_type):<EOL><INDENT>converter = six.u<EOL><DEDENT>else:<EOL><INDENT>converter = six.b<EOL><DEDENT>default_separator = converter('<STR_LIT:|>')<EOL>default_index_separator = converter('<STR_LIT:_>')<EOL>newline = converter('<STR_LIT:\n>')<EOL>if separator is DEFAULT:<EOL><INDENT>separator = default_separator<EOL><DEDENT>if index_separator is DEFAULT:<EOL><INDENT>index_separator = default_index_separator<EOL><DEDENT>for key, value in six.iteritems(obj):<EOL><INDENT>if isinstance(value, (list, tuple, set)):<EOL><INDENT>for index, item in enumerate(value, start=startindex):<EOL><INDENT>fp.write(key)<EOL>fp.write(index_separator)<EOL>fp.write(converter(str(index)))<EOL>fp.write(separator)<EOL>fp.write(item)<EOL>fp.write(newline)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>fp.write(key)<EOL>fp.write(separator)<EOL>fp.write(value)<EOL>fp.write(newline)<EOL><DEDENT><DEDENT>
Dump an object in req format to the fp given.

    :param Mapping obj: The object to serialize.  Must have a keys method.
    :param fp: A writable that can accept all the types given.
    :param separator: The separator between key and value.  Defaults to u'|' or b'|', depending on the types.
    :param index_separator: The separator between key and index.  Defaults to u'_' or b'_', depending on the types.