diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-09-17 16:31:50 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-09-17 16:31:50 +0200 |
commit | d798ed955dab4681a5285024b3648b1a3f13c24e (patch) | |
tree | a95d96953cd7688451c3a515e4b31f0465d6a7d3 /netlib/odict.py | |
parent | 8d71059d77c2dd1d9858d7971dd0b6b4387ed9f4 (diff) | |
download | mitmproxy-d798ed955dab4681a5285024b3648b1a3f13c24e.tar.gz mitmproxy-d798ed955dab4681a5285024b3648b1a3f13c24e.tar.bz2 mitmproxy-d798ed955dab4681a5285024b3648b1a3f13c24e.zip |
python3++
Diffstat (limited to 'netlib/odict.py')
-rw-r--r-- | netlib/odict.py | 25 |
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 |