<commit_before>from merc import errors
from merc import feature
from merc import message
from merc import util


class UserHostFeature(feature.Feature):
  NAME = __name__


install = UserHostFeature


class UserHostReply(message.Reply):
  NAME = "302"
  FORCE_TRAILING = True

  def __init__(self, user_hosts):
    self.user_hosts = user_hosts

  def as_reply_params(self, user):
    return [" ".join("{}={}{}".format(user_host.nickname,
                                      "*" if user_host.is_oper else "",
                                      "+" if not user_host.is_away else "-",
                                      user_host.hostmask)
            for user_host in self.user_hosts)]


@UserHostFeature.register_command
class UserHost(message.Command):
  NAME = "USERHOST"
  MIN_ARITY = 1

  def __init__(self, *nicknames):
    self.nicknames = nicknames[:5]

  @message.Command.requires_registration
  def handle_for(self, user, prefix):
    user_hosts = []
    for nickname in self.nicknames:
      try:
        target = user.server.get_user(nickname)
      except errors.NoSuchNick:
        pass
      else:
        user_host = util.Expando(nickname=nickname, is_away=False,
                                 is_oper=target.is_irc_operator,
                                 hostmask=target.hostmask)
        user.server.run_hooks("modify_userhost_entry", target, user_host)
        user_hosts.append(user_host)

    user.send_reply(UserHostReply(user_hosts))
<commit_msg>return correct userhost reply<commit_after>from merc import errors
from merc import feature
from merc import message
from merc import util


class UserHostFeature(feature.Feature):
  NAME = __name__


install = UserHostFeature


class UserHostReply(message.Reply):
  NAME = "302"
  FORCE_TRAILING = True

  def __init__(self, user_hosts):
    self.user_hosts = user_hosts

  def as_reply_params(self, user):
    return [" ".join("{}{}={}{}".format(user_host.nickname,
                                        "*" if user_host.is_oper else "",
                                        "+" if not user_host.is_away else "-",
                                        user_host.hostmask)
            for user_host in self.user_hosts)]


@UserHostFeature.register_command
class UserHost(message.Command):
  NAME = "USERHOST"
  MIN_ARITY = 1

  def __init__(self, *nicknames):
    self.nicknames = nicknames[:5]

  @message.Command.requires_registration
  def handle_for(self, user, prefix):
    user_hosts = []
    for nickname in self.nicknames:
      try:
        target = user.server.get_user(nickname)
      except errors.NoSuchNick:
        pass
      else:
        user_host = util.Expando(nickname=nickname, is_away=False,
                                 is_oper=target.is_irc_operator,
                                 hostmask=target.hostmask)
        user.server.run_hooks("modify_userhost_entry", target, user_host)
        user_hosts.append(user_host)

    user.send_reply(UserHostReply(user_hosts))

{'fraction_non_alphanumeric': 0.09176155391828533, 'fraction_numerical': 0.003348961821835231, 'mean_word_length': 2.356179775280899, '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': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3187931', 'n_tokens_mistral': 913, 'n_tokens_neox': 856, 'n_words': 181}