示例#1
0
 def test_soft_eol(self):
     self.assertFalse(abnf.parse('JOIN #a\r', abnf.message))
     self.assertFalse(abnf.parse('JOIN #a\n', abnf.message))
     config.set('parser', 'soft_eol', 'true')
     self._test(abnf.message, {
         'JOIN #a\r': ['', 'JOIN', '#a'],
         'JOIN #a\n': ['', 'JOIN', '#a']
     })
示例#2
0
    def from_user(self, mask, o=None, *_):
        # TODO: If the "o" parameter is passed only operators are returned
        # according to the <mask> supplied.
        # TODO: If there is a list of parameters supplied
        # with a WHO message, a RPL_ENDOFWHO MUST be sent
        # after processing each list item with <name> being
        # the item.

        resp = []
        if Channel.exists(mask):
            channel = Channel.get(mask)
            for channel_user in channel.users:
                resp.append(
                    RPL_WHOREPLY(self.actor, channel_user, str(channel))
                )
        else:
            if mask == '0':
                mask = '*'
            parser = abnf.wildcard(mask)
            for user in User.all():
                # TODO: add check for servername
                if any([abnf.parse(str, parser)
                        for str
                        in [user.hostname, user.realname, user.nickname]]):
                    resp.append(RPL_WHOREPLY(self.actor, user, mask))
        #resp.append(RPL_ENDOFWHO(self.user, str(channel)))
        return resp
示例#3
0
 def test_regr01(self):
     """
     Regression in 119da40fc8a2ddfb885d6687b7dddd90144d2995
     Problem: Fails to parse \r\n terminated messages when soft_eol is on
     """
     config.set('parser', 'soft_eol', 'true')
     self.assertEqual(['', 'JOIN', '#a'],
                      abnf.parse('JOIN #a\r\n', abnf.message))
示例#4
0
 def test_regr01(self):
     """
     Regression in 119da40fc8a2ddfb885d6687b7dddd90144d2995
     Problem: Fails to parse \r\n terminated messages when soft_eol is on
     """
     config.set('parser', 'soft_eol', 'true')
     self.assertEqual(
         ['', 'JOIN', '#a'],
         abnf.parse('JOIN #a\r\n', abnf.message))
示例#5
0
    def __init__(self, name):
        if not self.is_valid_name(name):
            raise Error('Erroneous channel name')

        raw = abnf.parse(name, abnf.channel)
        self.mode = ChannelMode
        self.prefix = raw[0]
        self.id = raw[1] if self.prefix == '!' else None
        self.name = raw[2] if self.prefix == '!' else raw[1]

        self.users = []
        self.topic = None
示例#6
0
 def check_invalid_nick(self):
     parsed_nick = abnf.parse(self.params.nick, abnf.nickname)
     if len(self.params.nick) > 9 or parsed_nick != self.params.nick:
         nick = self.params.nick.replace(' ', '_')
         return ERR_ERRONEUSNICKNAME(nick, self.actor)
示例#7
0
 def is_valid_name(name):
     return bool(abnf.parse(name, abnf.channel))
示例#8
0
 def test_trailing_spaces_and_soft_eol(self):
     config.set('parser', 'soft_eol', 'true')
     config.set('parser', 'trailing_spaces', 'true')
     self.assertListEqual(
         ['', 'JOIN', '#a'],
         abnf.parse('JOIN #a   \r', abnf.message))
示例#9
0
 def _test(self, parser, cases):
     for input, expected in cases.items():
         actual = abnf.parse(input, parser)
         #print input, expected, actual
         self.assertEqual(expected, actual)
示例#10
0
 def test_trailing_spaces(self):
     self.assertFalse(abnf.parse('JOIN #a \r\n', abnf.message))
     config.set('parser', 'trailing_spaces', 'true')
     self.assertListEqual(
         ['', 'JOIN', '#a'],
         abnf.parse('JOIN #a   \r\n', abnf.message))
示例#11
0
 def check_invalid_nick(self):
     parsed_nick = abnf.parse(self.params.nick, abnf.nickname)
     if len(self.params.nick) > 9 or parsed_nick != self.params.nick:
         nick = self.params.nick.replace(' ', '_')
         return ERR_ERRONEUSNICKNAME(nick, self.actor)
示例#12
0
文件: nick.py 项目: Slach/python-ircd
 def check_invalid_nick(self):
     parsed_nick = abnf.parse(self.params.nick, abnf.nickname)
     log.debug('%s > 64 or %s != %s' % (len(self.params.nick), parsed_nick, self.params.nick))
     if len(self.params.nick) > 64 or parsed_nick != self.params.nick:
         nick = self.params.nick.replace(' ', '_')
         return ERR_ERRONEUSNICKNAME(nick, self.actor)