diff options
author | cce <devnull@localhost> | 2006-09-21 05:46:57 +0000 |
---|---|---|
committer | cce <devnull@localhost> | 2006-09-21 05:46:57 +0000 |
commit | 3559f127031598b0dcc2a243454d2c15309a109b (patch) | |
tree | adbc46bdde0022b8d751d173dfb0065c7319dcaa /paste/util | |
parent | 9e4f83947cdb42dffdff973d0b9b12a2f775e3b1 (diff) | |
download | paste-3559f127031598b0dcc2a243454d2c15309a109b.tar.gz |
Paste should not depend upon other paste modules, such
as Deploy. This patch moves 'converters' into paste.util
since it was being used within paste proper. I'll leave
it to those who know Deploy to update that.
- copied converters.py from paste.deploy to paste.util
- updated files that use paste.deploy.converters
Diffstat (limited to 'paste/util')
-rw-r--r-- | paste/util/converters.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/paste/util/converters.py b/paste/util/converters.py new file mode 100644 index 0000000..f0ad349 --- /dev/null +++ b/paste/util/converters.py @@ -0,0 +1,26 @@ +# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) +# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php +def asbool(obj): + if isinstance(obj, (str, unicode)): + obj = obj.strip().lower() + if obj in ['true', 'yes', 'on', 'y', 't', '1']: + return True + elif obj in ['false', 'no', 'off', 'n', 'f', '0']: + return False + else: + raise ValueError( + "String is not true/false: %r" % obj) + return bool(obj) + +def aslist(obj, sep=None, strip=True): + if isinstance(obj, (str, unicode)): + lst = obj.split(sep) + if strip: + lst = [v.strip() for v in lst] + return lst + elif isinstance(obj, (list, tuple)): + return obj + elif obj is None: + return [] + else: + return [obj] |