mirror of
https://github.com/kennethreitz/env.git
synced 2026-06-05 23:10:16 +00:00
urlprase
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user