<commit_before>from six import text_type
from six.moves.urllib.parse import (
    parse_qs,
    urlparse,
    unquote
)

from .utils import comma_separated_list


PARAMS = {
    'message_wait_seconds': float,
    'dpaste_minimum_response_length': int,
    'limit_access_to': comma_separated_list
}


def parse_irc_uri(uri):
    if not uri:
        return {}
    uri = uri.replace('#', '%23')

    parsed = urlparse(uri)
    result = {}

    if parsed.hostname:
        result['server'] = parsed.hostname
    if parsed.scheme:
        result['ssl'] = '+ssl' in parsed.scheme
    if parsed.path and len(parsed.path) > 1:
        result['channel'] = unquote(parsed.path[1:])
    if parsed.username:
        result['nickname'] = unquote(parsed.username)
    if parsed.password:
        result['password'] = unquote(parsed.password)
    if parsed.port:
        result['port'] = int(parsed.port)

    if parsed.query:
        for keyword, value_list in parse_qs(parsed.query).items():
            value = value_list[0]
            result[keyword] = PARAMS.get(keyword, text_type)(value)

    return result<commit_msg>Strip trailing '?' from channel to work around Python 2.6 urlparse behavior.<commit_after>from six import text_type
from six.moves.urllib.parse import (
    parse_qs,
    urlparse,
    unquote
)

from .utils import comma_separated_list


PARAMS = {
    'message_wait_seconds': float,
    'dpaste_minimum_response_length': int,
    'limit_access_to': comma_separated_list
}


def parse_irc_uri(uri):
    if not uri:
        return {}
    uri = uri.replace('#', '%23')

    parsed = urlparse(uri)
    result = {}

    if parsed.hostname:
        result['server'] = parsed.hostname
    if parsed.scheme:
        result['ssl'] = '+ssl' in parsed.scheme
    if parsed.path and len(parsed.path) > 1:
        result['channel'] = unquote(parsed.path[1:].strip('?'))
    if parsed.username:
        result['nickname'] = unquote(parsed.username)
    if parsed.password:
        result['password'] = unquote(parsed.password)
    if parsed.port:
        result['port'] = int(parsed.port)

    if parsed.query:
        for keyword, value_list in parse_qs(parsed.query).items():
            value = value_list[0]
            result[keyword] = PARAMS.get(keyword, text_type)(value)

    return result
{'fraction_non_alphanumeric': 0.12325783972125436, 'fraction_numerical': 0.005226480836236934, 'mean_word_length': 2.9264957264957263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5029374', 'n_tokens_mistral': 741, 'n_tokens_neox': 724, 'n_words': 161}