aboutsummaryrefslogtreecommitdiffstats
path: root/netlib/utils.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-07-15 23:17:57 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-07-15 23:17:57 -0700
commit3602fd7a36d963311339ab11ed36ff00df860f71 (patch)
tree5834a98b35c02639c876544bc645f205068fac99 /netlib/utils.py
parenta3c7c84d49c3e6563e7f37ef60c989f99ed96788 (diff)
parent17305643bc482c0b185eec5c64d506790cd26587 (diff)
downloadmitmproxy-3602fd7a36d963311339ab11ed36ff00df860f71.tar.gz
mitmproxy-3602fd7a36d963311339ab11ed36ff00df860f71.tar.bz2
mitmproxy-3602fd7a36d963311339ab11ed36ff00df860f71.zip
Merge remote-tracking branch 'origin/master' into message-body-encoding
Diffstat (limited to 'netlib/utils.py')
-rw-r--r--netlib/utils.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/netlib/utils.py b/netlib/utils.py
index 79340cbd..9eebf22c 100644
--- a/netlib/utils.py
+++ b/netlib/utils.py
@@ -56,6 +56,13 @@ class Data(object):
dirname = os.path.dirname(inspect.getsourcefile(m))
self.dirname = os.path.abspath(dirname)
+ def push(self, subpath):
+ """
+ Change the data object to a path relative to the module.
+ """
+ self.dirname = os.path.join(self.dirname, subpath)
+ return self
+
def path(self, path):
"""
Returns a path to the package data housed at 'path' under this
@@ -73,11 +80,9 @@ _label_valid = re.compile(b"(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
def is_valid_host(host):
+ # type: (bytes) -> bool
"""
Checks if a hostname is valid.
-
- Args:
- host (bytes): The hostname
"""
try:
host.decode("idna")