<commit_before>"""
Multipart/form-data encoded file streaming.
"""
from __future__ import absolute_import

import os
import fnmatch
from itertools import chain
from uuid import uuid4

from six.moves.urllib.parse import quote
import six

from . import utils

try:
    memoryview = getattr(globals()['__builtins__'], 'memoryview')
except:
    # Python 2.6
    memoryview = lambda x: x


CRLF = '\r\n'

default_chunk_size = 1024


def content_disposition(fn, disptype='file'):
    """
    Returns a dict containing the MIME content-disposition header for a
    file

    >>> content_disposition('example.txt')
    {'Content-Disposition': 'file; filename="example.txt"'}

    >>> content_disposition('example.txt', 'attachment')
    {'Content-Disposition': 'attachment; filename="example.txt"'}
    """
    disp = '%s; filename="%s"' % (
        disptype,
        quote(fn, safe='')
    )
    return {'Content-Disposition': disp}


def content_type(fn):
    """
    Guesses the mimetype associated with a filename and returns a dict
    containing the content-type header<commit_msg>change default chunk-size for upload to 4kB<commit_after>"""
Multipart/form-data encoded file streaming.
"""
from __future__ import absolute_import

import os
import fnmatch
from itertools import chain
from uuid import uuid4

from six.moves.urllib.parse import quote
import six

from . import utils

try:
    memoryview = getattr(globals()['__builtins__'], 'memoryview')
except:
    # Python 2.6
    memoryview = lambda x: x


CRLF = '\r\n'

default_chunk_size = 4096


def content_disposition(fn, disptype='file'):
    """
    Returns a dict containing the MIME content-disposition header for a
    file

    >>> content_disposition('example.txt')
    {'Content-Disposition': 'file; filename="example.txt"'}

    >>> content_disposition('example.txt', 'attachment')
    {'Content-Disposition': 'attachment; filename="example.txt"'}
    """
    disp = '%s; filename="%s"' % (
        disptype,
        quote(fn, safe='')
    )
    return {'Content-Disposition': disp}


def content_type(fn):
    """
    Guesses the mimetype associated with a filename and returns a dict
    containing the content-type header
{'fraction_non_alphanumeric': 0.12020109689213894, 'fraction_numerical': 0.006855575868372943, 'mean_word_length': 3.7794759825327513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3907663', 'n_tokens_mistral': 680, 'n_tokens_neox': 658, 'n_words': 193}