<commit_before>"""Various helper functions"""

import asyncio
import base64
import binascii
import datetime
import functools
import io
import os
import re

from collections import namedtuple
from http.cookies import SimpleCookie, Morsel
from math import ceil
from pathlib import Path
from urllib.parse import quote, urlencode, urlsplit

from multidict import MultiDict, MultiDictProxy

from . import hdrs
from .abc import AbstractCookieJar
from .errors import InvalidURL
try:
    from asyncio import ensure_future
except ImportError:
    ensure_future = asyncio.async


__all__ = ('BasicAuth', 'create_future', 'FormData', 'parse_mimetype',
           'Timeout', 'CookieJar')


class BasicAuth(namedtuple('BasicAuth', ['login', 'password', 'encoding'])):
    """Http basic authentication helper.

    :param str login: Login
    :param str password: Password
    :param str encoding: (optional) encoding ('latin1' by default)
    """

    def __new__(cls, login, password='', encoding='latin1'):
        if login is None:
            raise ValueError('None is not allowed as login value')

        if password is None:
            raise ValueError('None is not allowed as password value')

        return super().__new__(cls, login, password, encoding)

    @classmethod
    def decode(cls, auth_header, encoding='latin1'):
        """Create a :class:`BasicAuth` object from an ``Authorization`` HTTP
        header."""<commit_msg>Add ensure_future to public list<commit_after>"""Various helper functions"""

import asyncio
import base64
import binascii
import datetime
import functools
import io
import os
import re

from collections import namedtuple
from http.cookies import SimpleCookie, Morsel
from math import ceil
from pathlib import Path
from urllib.parse import quote, urlencode, urlsplit

from multidict import MultiDict, MultiDictProxy

from . import hdrs
from .abc import AbstractCookieJar
from .errors import InvalidURL
try:
    from asyncio import ensure_future
except ImportError:
    ensure_future = asyncio.async


__all__ = ('BasicAuth', 'create_future', 'FormData', 'parse_mimetype',
           'Timeout', 'CookieJar', 'ensure_future')


class BasicAuth(namedtuple('BasicAuth', ['login', 'password', 'encoding'])):
    """Http basic authentication helper.

    :param str login: Login
    :param str password: Password
    :param str encoding: (optional) encoding ('latin1' by default)
    """

    def __new__(cls, login, password='', encoding='latin1'):
        if login is None:
            raise ValueError('None is not allowed as login value')

        if password is None:
            raise ValueError('None is not allowed as password value')

        return super().__new__(cls, login, password, encoding)

    @classmethod
    def decode(cls, auth_header, encoding='latin1'):
        """Create a :class:`BasicAuth` object from an ``Authorization`` HTTP
        header."""
{'fraction_non_alphanumeric': 0.09282263630089717, 'fraction_numerical': 0.003450655624568668, 'mean_word_length': 3.9982758620689656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5129451', 'n_tokens_mistral': 788, 'n_tokens_neox': 769, 'n_words': 298}