This commit is contained in:
Kenneth Reitz
2012-05-08 10:32:25 -04:00
parent be30fc808e
commit 043342e090
+16
View File
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from os import environ
from urlparse import urlparse as _urlparse
def lower_dict(d):
"""Lower cases string keys in given dict."""
@@ -16,6 +18,20 @@ def lower_dict(d):
return _d
def urlparse(d, keys=None):
"""Returns a copy of the given dictionary with url values parsed."""
d = d.copy()
if keys is None:
keys = d.keys()
for key in keys:
d[key] = _urlparse(d[key])
return d
def prefix(prefix):
"""Returns a dictionary of all environment variables starting with
the given prefix, lower cased and stripped.