remove limnoria/supybot

This commit is contained in:
Shivaram Lingamneni 2020-09-13 06:38:15 -04:00
parent 61941e2be0
commit 8851083a3e
4 changed files with 41 additions and 6 deletions

View File

@ -5,12 +5,11 @@ import tempfile
import unittest
import functools
import supybot.utils
from . import runner
from . import client_mock
from .irc_utils import capabilities
from .irc_utils import message_parser
from .irc_utils.junkdrawer import normalizeWhitespace
from .irc_utils.sasl import sasl_plain_blob
from .exceptions import ConnectionClosed
from .specifications import Specifications
@ -23,7 +22,7 @@ class _IrcTestCase(unittest.TestCase):
method_doc = self._testMethodDoc
if not method_doc:
return ''
return '\t'+supybot.utils.str.normalizeWhitespace(
return '\t'+normalizeWhitespace(
method_doc,
removeNewline=False,
).strip().replace('\n ', '\n\t')

View File

@ -1,4 +1,5 @@
import datetime
import re
from collections import namedtuple
HistoryMessage = namedtuple('HistoryMessage', ['time', 'msgid', 'target', 'text'])
@ -11,3 +12,38 @@ IRCV3_FORMAT_STRFTIME = "%Y-%m-%dT%H:%M:%S.%f%z"
def ircv3_timestamp_to_unixtime(timestamp):
return datetime.datetime.strptime(timestamp, IRCV3_FORMAT_STRFTIME).timestamp()
"""
Stolen from supybot:
"""
class MultipleReplacer:
"""Return a callable that replaces all dict keys by the associated
value. More efficient than multiple .replace()."""
# We use an object instead of a lambda function because it avoids the
# need for using the staticmethod() on the lambda function if assigning
# it to a class in Python 3.
def __init__(self, dict_):
self._dict = dict_
dict_ = dict([(re.escape(key), val) for key,val in dict_.items()])
self._matcher = re.compile('|'.join(dict_.keys()))
def __call__(self, s):
return self._matcher.sub(lambda m: self._dict[m.group(0)], s)
def normalizeWhitespace(s, removeNewline=True):
r"""Normalizes the whitespace in a string; \s+ becomes one space."""
if not s:
return str(s) # not the same reference
starts_with_space = (s[0] in ' \n\t\r')
ends_with_space = (s[-1] in ' \n\t\r')
if removeNewline:
newline_re = re.compile('[\r\n]+')
s = ' '.join(filter(bool, newline_re.split(s)))
s = ' '.join(filter(bool, s.split('\t')))
s = ' '.join(filter(bool, s.split(' ')))
if starts_with_space:
s = ' ' + s
if ends_with_space:
s += ' '
retur

View File

@ -1,6 +1,7 @@
import re
import collections
import supybot.utils
from .junkdrawer import MultipleReplacer
# http://ircv3.net/specs/core/message-tags-3.2.html#escaping-values
TAG_ESCAPE = [
@ -10,7 +11,7 @@ TAG_ESCAPE = [
('\r', r'\r'),
('\n', r'\n'),
]
unescape_tag_value = supybot.utils.str.MultipleReplacer(
unescape_tag_value = MultipleReplacer(
dict(map(lambda x:(x[1],x[0]), TAG_ESCAPE)))
# TODO: validate host

View File

@ -1,4 +1,3 @@
limnoria > 2012.08.04 # Needs MultipleReplacer, from 1a64f105
psutil >= 3.1.0 # Fixes #640
ecdsa
pyxmpp2_scram