root/galaxy-central/eggs/Beaker-1.4-py2.6.egg/beaker/converters.py @ 3

リビジョン 3, 0.8 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 aslist(obj, sep=None, strip=True):
16    if isinstance(obj, (str, unicode)):
17        lst = obj.split(sep)
18        if strip:
19            lst = [v.strip() for v in lst]
20        return lst
21    elif isinstance(obj, (list, tuple)):
22        return obj
23    elif obj is None:
24        return []
25    else:
26        return [obj]
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。