def make_streams(name, value, boundary, encoding):
filename = None<EOL>mime = None<EOL>if isinstance(value, collections.Mapping) and "<STR_LIT:name>" in value and "<STR_LIT:value>" in value:<EOL><INDENT>filename = value["<STR_LIT:name>"]<EOL>try:<EOL><INDENT>mime = value["<STR_LIT>"]<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>value = value["<STR_LIT:value>"]<EOL><DEDENT>if not filename:<EOL><INDENT>filename = getattr(value, "<STR_LIT:name>", None)<EOL>if filename:<EOL><INDENT>filename = os.path.split(filename)[<NUM_LIT:1>]<EOL><DEDENT><DEDENT>mime = mime or "<STR_LIT>"<EOL>name, filename, mime = [escape_header(v) for v in (name, filename, mime)]<EOL>stream = BytesIO()<EOL>stream.write("<STR_LIT>".format(boundary).encode(encoding))<EOL>if not filename:<EOL><INDENT>stream.write(<EOL>'<STR_LIT>'.format(name).encode(<EOL>encoding<EOL>)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>stream.write(<EOL>'<STR_LIT>'.format(<EOL>name, filename<EOL>).encode(encoding)<EOL>)<EOL>if mime:<EOL><INDENT>stream.write("<STR_LIT>".format(mime).encode(encoding))<EOL><DEDENT><DEDENT>stream.write(b"<STR_LIT:\r\n>")<EOL>if hasattr(value, "<STR_LIT>"):<EOL><INDENT>stream.seek(<NUM_LIT:0>)<EOL>return stream, value, BytesIO("<STR_LIT:\r\n>".encode(encoding))<EOL><DEDENT>value = value if isinstance(value, (str, bytes)) else json.dumps(value)<EOL>if isinstance(value, bytes):<EOL><INDENT>stream.write(value)<EOL><DEDENT>else:<EOL><INDENT>stream.write(value.encode(encoding))<EOL><DEDENT>stream.write(b"<STR_LIT:\r\n>")<EOL>stream.seek(<NUM_LIT:0>)<EOL>return (stream,)<EOL>
Generates one or more streams for each name, value pair