aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/utils.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-10-20 10:32:09 +1300
committerAldo Cortesi <aldo@nullcube.com>2016-10-20 10:32:09 +1300
commit95551265852e6ff05ab5e5204e1a919f66fa4eae (patch)
treea70edd6e89742e3b744d558a1b91138daa6454e6 /netlib/utils.py
parenta684585e7cf7099ea61f23b3176b492883f19f00 (diff)
downloadmitmproxy-95551265852e6ff05ab5e5204e1a919f66fa4eae.tar.gz
mitmproxy-95551265852e6ff05ab5e5204e1a919f66fa4eae.tar.bz2
mitmproxy-95551265852e6ff05ab5e5204e1a919f66fa4eae.zip
netlib.utils.BiDi -> mitmproxy.types.bidi.BiDi
Diffstat (limited to 'netlib/utils.py')
-rw-r--r--netlib/utils.py29
1 files changed, 0 insertions, 29 deletions
diff --git a/netlib/utils.py b/netlib/utils.py
index 12b94d74..779eaa27 100644
--- a/netlib/utils.py
+++ b/netlib/utils.py
@@ -16,35 +16,6 @@ def getbit(byte, offset):
return bool(byte & mask)
-class BiDi:
-
- """
- A wee utility class for keeping bi-directional mappings, like field
- constants in protocols. Names are attributes on the object, dict-like
- access maps values to names:
-
- CONST = BiDi(a=1, b=2)
- assert CONST.a == 1
- assert CONST.get_name(1) == "a"
- """
-
- def __init__(self, **kwargs):
- self.names = kwargs
- self.values = {}
- for k, v in kwargs.items():
- self.values[v] = k
- if len(self.names) != len(self.values):
- raise ValueError("Duplicate values not allowed.")
-
- def __getattr__(self, k):
- if k in self.names:
- return self.names[k]
- raise AttributeError("No such attribute: %s", k)
-
- def get_name(self, n, default=None):
- return self.values.get(n, default)
-
-
_label_valid = re.compile(b"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)