<commit_before># -*- coding: utf-8 -*-
import socket

from raiden.utils import (
    host_port_to_endpoint,
    isaddress,
    pex,
    split_endpoint,
)
from raiden.exceptions import InvalidAddress


class Discovery(object):
    """ Mock mapping address: host, port """

    def __init__(self):
        self.nodeid_hostport = dict()

    def register(self, node_address, host, port):
        if not isaddress(node_address):
            raise ValueError('node_address must be a valid address')

        try:
            socket.inet_pton(socket.AF_INET, host)
        except OSError:
            raise ValueError('invalid ip address provided: {}'.format(host))

        if not isinstance(port, (int, long)):
            raise ValueError('port must be a valid number')

        self.nodeid_hostport[node_address] = (host, port)

    def get(self, node_address):
        try:
            return self.nodeid_hostport[node_address]
        except KeyError:
            raise InvalidAddress('Unknown address {}'.format(pex(node_address)))

    def nodeid_by_host_port(self, host_port):
        for nodeid, value_hostport in self.nodeid_hostport.items():
            if value_hostport == host_port:<commit_msg>Rename discovery's nodeid_hostport<commit_after># -*- coding: utf-8 -*-
import socket

from raiden.utils import (
    host_port_to_endpoint,
    isaddress,
    pex,
    split_endpoint,
)
from raiden.exceptions import InvalidAddress


class Discovery(object):
    """ Mock mapping address: host, port """

    def __init__(self):
        self.nodeid_to_hostport = dict()

    def register(self, node_address, host, port):
        if not isaddress(node_address):
            raise ValueError('node_address must be a valid address')

        try:
            socket.inet_pton(socket.AF_INET, host)
        except OSError:
            raise ValueError('invalid ip address provided: {}'.format(host))

        if not isinstance(port, (int, long)):
            raise ValueError('port must be a valid number')

        self.nodeid_to_hostport[node_address] = (host, port)

    def get(self, node_address):
        try:
            return self.nodeid_to_hostport[node_address]
        except KeyError:
            raise InvalidAddress('Unknown address {}'.format(pex(node_address)))

    def nodeid_by_host_port(self, host_port):
        for nodeid, value_hostport in self.nodeid_to_hostport.items():
            if value_hostport == host_port:
{'fraction_non_alphanumeric': 0.0979909799097991, 'fraction_numerical': 0.0008200082000820008, 'mean_word_length': 2.830455259026688, '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': '2332282', 'n_tokens_mistral': 716, 'n_tokens_neox': 696, 'n_words': 183}