aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/odict.py
diff options
context:
space:
mode:
Diffstat (limited to 'netlib/odict.py')
-rw-r--r--netlib/odict.py25
1 files changed, 3 insertions, 22 deletions
diff --git a/netlib/odict.py b/netlib/odict.py
index 11d5d52a..1124b23a 100644
--- a/netlib/odict.py
+++ b/netlib/odict.py
@@ -1,6 +1,7 @@
from __future__ import (absolute_import, print_function, division)
import re
import copy
+import six
def safe_subn(pattern, repl, target, *args, **kwargs):
@@ -67,10 +68,10 @@ class ODict(object):
Sets the values for key k. If there are existing values for this
key, they are cleared.
"""
- if isinstance(valuelist, basestring):
+ if isinstance(valuelist, six.text_type) or isinstance(valuelist, six.binary_type):
raise ValueError(
"Expected list of values instead of string. "
- "Example: odict['Host'] = ['www.example.com']"
+ "Example: odict[b'Host'] = [b'www.example.com']"
)
kc = self._kconv(k)
new = []
@@ -134,13 +135,6 @@ class ODict(object):
def __repr__(self):
return repr(self.lst)
- def format(self):
- elements = []
- for itm in self.lst:
- elements.append(itm[0] + ": " + str(itm[1]))
- elements.append("")
- return "\r\n".join(elements)
-
def in_any(self, key, value, caseless=False):
"""
Do any of the values matching key contain value?
@@ -156,19 +150,6 @@ class ODict(object):
return True
return False
- def match_re(self, expr):
- """
- Match the regular expression against each (key, value) pair. For
- each pair a string of the following format is matched against:
-
- "key: value"
- """
- for k, v in self.lst:
- s = "%s: %s" % (k, v)
- if re.search(expr, s):
- return True
- return False
-
def replace(self, pattern, repl, *args, **kwargs):
"""
Replaces a regular expression pattern with repl in both keys and