# Path: asn1crypto/_errors.py
# def unwrap(string, *params):
#     """
#     Takes a multi-line string and does the following:
# 
#      - dedents
#      - converts newlines with text before and after into a single line
#      - strips leading and trailing whitespace
# 
#     :param string:
#         The string to format
# 
#     :param *params:
#         Params to interpolate into the string
# 
#     :return:
#         The formatted string
#     """
# 
#     output = textwrap.dedent(string)
# 
#     # Unwrap lines, taking into account bulleted lists, ordered lists and
#     # underlines consisting of = signs
#     if output.find('\n') != -1:
#         output = re.sub('(?<=\\S)\n(?=[^ \n\t\\d\\*\\-=])', ' ', output)
# 
#     if params:
#         output = output % params
# 
#     output = output.strip()
# 
#     return output


from encodings import idna  # noqa
from ._errors import unwrap
from ._types import byte_cls, str_cls, type_name, bytes_to_list, int_types
    from urlparse import urlsplit, urlunsplit
    from urllib import (
        quote as urlquote,
        unquote as unquote_to_bytes,
    )
    from urllib.parse import (
        quote as urlquote,
        unquote_to_bytes,
        urlsplit,
        urlunsplit,
    )
import codecs
import re
import sys
    # RFC 3986 allows the query to contain sub-delims, plus "@", ":" , "/" and "?"
    query = _urlquote(parsed.query, safe='/?!$&\'()*+,;=@:')
    # RFC 3986 allows the fragment to contain sub-delims, plus "@", ":" , "/" and "?"
    fragment = _urlquote(parsed.fragment, safe='/?!$&\'()*+,;=@:')

    if normalize and query is None and fragment is None and path == b'/':
        path = None

    # Python 2.7 compat
    if path is None:
        path = ''

    output = urlunsplit((scheme, netloc, path, query, fragment))
    if isinstance(output, str_cls):
        output = output.encode('latin1')
    return output


def uri_to_iri(value):
    """
    Converts an ASCII URI byte string into a unicode IRI

    :param value:
        An ASCII-encoded byte string of the URI

    :return:
        A unicode string of the IRI
    """

    if not isinstance(value, byte_cls):

# Path: asn1crypto/_errors.py
# def unwrap(string, *params):
#     """
#     Takes a multi-line string and does the following:
# 
#      - dedents
#      - converts newlines with text before and after into a single line
#      - strips leading and trailing whitespace
# 
#     :param string:
#         The string to format
# 
#     :param *params:
#         Params to interpolate into the string
# 
#     :return:
#         The formatted string
#     """
# 
#     output = textwrap.dedent(string)
# 
#     # Unwrap lines, taking into account bulleted lists, ordered lists and
#     # underlines consisting of = signs
#     if output.find('\n') != -1:
#         output = re.sub('(?<=\\S)\n(?=[^ \n\t\\d\\*\\-=])', ' ', output)
# 
#     if params:
#         output = output % params
# 
#     output = output.strip()
# 
#     return output


# Path: asn1crypto/_iri.py
from encodings import idna  # noqa
from ._errors import unwrap
from ._types import byte_cls, str_cls, type_name, bytes_to_list, int_types
    from urlparse import urlsplit, urlunsplit
    from urllib import (
        quote as urlquote,
        unquote as unquote_to_bytes,
    )
    from urllib.parse import (
        quote as urlquote,
        unquote_to_bytes,
        urlsplit,
        urlunsplit,
    )
import codecs
import re
import sys

    # RFC 3986 allows the query to contain sub-delims, plus "@", ":" , "/" and "?"
    query = _urlquote(parsed.query, safe='/?!$&\'()*+,;=@:')
    # RFC 3986 allows the fragment to contain sub-delims, plus "@", ":" , "/" and "?"
    fragment = _urlquote(parsed.fragment, safe='/?!$&\'()*+,;=@:')

    if normalize and query is None and fragment is None and path == b'/':
        path = None

    # Python 2.7 compat
    if path is None:
        path = ''

    output = urlunsplit((scheme, netloc, path, query, fragment))
    if isinstance(output, str_cls):
        output = output.encode('latin1')
    return output


def uri_to_iri(value):
    """
    Converts an ASCII URI byte string into a unicode IRI

    :param value:
        An ASCII-encoded byte string of the URI

    :return:
        A unicode string of the IRI
    """

    if not isinstance(value, byte_cls):

        raise TypeError(unwrap(