summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2014-11-17 20:29:29 -0500
committerBarry Warsaw2014-11-17 20:29:29 -0500
commit0e9df01a559ee7c6bb0d4d307159ef29497e79c9 (patch)
treeeb15c3c742adeb64d6d14bdfe9567b0d8bf53dec /src
parent639f3bcceded70867062c2ee4cf9a666b0f72516 (diff)
downloadmailman-0e9df01a559ee7c6bb0d4d307159ef29497e79c9.tar.gz
mailman-0e9df01a559ee7c6bb0d4d307159ef29497e79c9.tar.zst
mailman-0e9df01a559ee7c6bb0d4d307159ef29497e79c9.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/utilities/i18n.py2
-rw-r--r--src/mailman/utilities/string.py45
-rw-r--r--src/mailman/utilities/tests/test_import.py9
3 files changed, 4 insertions, 52 deletions
diff --git a/src/mailman/utilities/i18n.py b/src/mailman/utilities/i18n.py
index 40dce936b..e22bd6c18 100644
--- a/src/mailman/utilities/i18n.py
+++ b/src/mailman/utilities/i18n.py
@@ -49,7 +49,7 @@ class TemplateNotFoundError(MailmanException):
def __init__(self, template_file):
self.template_file = template_file
- def __str__(self):
+ def __str__(self): # pragma: no cover
return self.template_file
diff --git a/src/mailman/utilities/string.py b/src/mailman/utilities/string.py
index 0ed7cdf95..d6f0da286 100644
--- a/src/mailman/utilities/string.py
+++ b/src/mailman/utilities/string.py
@@ -23,22 +23,16 @@ __metaclass__ = type
__all__ = [
'expand',
'oneline',
- 'uncanonstr',
- 'websafe',
'wrap',
]
-import cgi
import logging
from email.errors import HeaderParseError
from email.header import decode_header, make_header
from string import Template, whitespace
from textwrap import TextWrapper, dedent
-from zope.component import getUtility
-
-from mailman.interfaces.languages import ILanguageManager
EMPTYSTRING = ''
@@ -92,45 +86,6 @@ def oneline(s, cset='us-ascii', in_unicode=False):
-def websafe(s):
- return cgi.escape(s, quote=True)
-
-
-
-# The opposite of canonstr() -- sorta. I.e. it attempts to encode s in the
-# charset of the given language, which is the character set that the page will
-# be rendered in, and failing that, replaces non-ASCII characters with their
-# html references. It always returns a byte string.
-def uncanonstr(s, lang=None):
- if s is None:
- s = u''
- if lang is None:
- charset = 'us-ascii'
- else:
- charset = getUtility(ILanguageManager)[lang].charset
- # See if the string contains characters only in the desired character
- # set. If so, return it unchanged, except for coercing it to a byte
- # string.
- try:
- if isinstance(s, unicode):
- return s.encode(charset)
- else:
- unicode(s, charset)
- return s
- except UnicodeError:
- # Nope, it contains funny characters, so html-ref it
- a = []
- for c in s:
- o = ord(c)
- if o > 127:
- a.append('&#%3d;' % o)
- else:
- a.append(c)
- # Join characters together and coerce to byte string
- return str(EMPTYSTRING.join(a))
-
-
-
def wrap(text, column=70, honor_leading_ws=True):
"""Wrap and fill the text to the specified column.
diff --git a/src/mailman/utilities/tests/test_import.py b/src/mailman/utilities/tests/test_import.py
index be09a3256..42608ae45 100644
--- a/src/mailman/utilities/tests/test_import.py
+++ b/src/mailman/utilities/tests/test_import.py
@@ -289,16 +289,13 @@ class TestBasicImport(unittest.TestCase):
except Import21Error as error:
# Check the message.
self.assertIn('[language.xx_XX]', str(error))
- else:
+ else: # pragma: no cover
self.fail('Import21Error was not raised')
def test_encode_ascii_prefixes(self):
self._pckdict['encode_ascii_prefixes'] = 2
self.assertEqual(self._mlist.encode_ascii_prefixes, False)
- try:
- self._import()
- except IntegrityError as e:
- self.fail(e)
+ self._import()
self.assertEqual(self._mlist.encode_ascii_prefixes, True)
@@ -653,7 +650,7 @@ class TestRosterImport(unittest.TestCase):
import_config_pck(self._mlist, self._pckdict)
except Import21Error as error:
self.assertIn('[language.xx_XX]', str(error))
- else:
+ else: # pragma: no cover
self.fail('Import21Error was not raised')
def test_username(self):