root/galaxy-central/eggs/PasteDeploy-1.3.3-py2.6.egg/paste/deploy/converters.py @ 3

リビジョン 3, 1.0 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
2# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
3def asbool(obj):
4    if isinstance(obj, (str, unicode)):
5        obj = obj.strip().lower()
6        if obj in ['true', 'yes', 'on', 'y', 't', '1']:
7            return True
8        elif obj in ['false', 'no', 'off', 'n', 'f', '0']:
9            return False
10        else:
11            raise ValueError(
12                "String is not true/false: %r" % obj)
13    return bool(obj)
14
15def asint(obj):
16    try:
17        return int(obj)
18    except (TypeError, ValueError), e:
19        raise ValueError(
20            "Bad integer value: %r" % obj)
21
22def aslist(obj, sep=None, strip=True):
23    if isinstance(obj, (str, unicode)):
24        lst = obj.split(sep)
25        if strip:
26            lst = [v.strip() for v in lst]
27        return lst
28    elif isinstance(obj, (list, tuple)):
29        return obj
30    elif obj is None:
31        return []
32    else:
33        return [obj]
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。