[Python-checkins] CVS: distutils/distutils util.py,1.46,1.47
Greg Ward
python-dev@python.org
Sun, 24 Sep 2000 18:25:16 -0700
- Previous message: [Python-checkins] CVS: distutils/distutils dist.py,1.36,1.37
- Next message: [Python-checkins] CVS: distutils/distutils/command bdist_dumb.py,1.14,1.15 bdist_rpm.py,1.20,1.21 bdist_wininst.py,1.14,1.15 build.py,1.27,1.28 build_clib.py,1.19,1.20 build_ext.py,1.65,1.66 build_py.py,1.29,1.30 build_scripts.py,1.4,1.5 clean.py,1.9,1.10 install.py,1.47,1.48 install_data.py,1.13,1.14 install_headers.py,1.5,1.6 install_lib.py,1.30,1.31 install_scripts.py,1.8,1.9 sdist.py,1.47,1.48
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/distutils/distutils
In directory slayer.i.sourceforge.net:/tmp/cvs-serv2664
Modified Files:
util.py
Log Message:
Added 'strtobool()' function: convert strings like "yes", "1",
"no", "0", etc. to true/false.
Index: util.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/util.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** util.py 2000/09/22 01:05:43 1.46
--- util.py 2000/09/25 01:25:06 1.47
***************
*** 274,275 ****
--- 274,290 ----
# execute()
+
+
+ def strtobool (val):
+ """Convert a string representation of truth to true (1) or false (0).
+ True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
+ are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
+ 'val' is anything else.
+ """
+ val = string.lower(val)
+ if val in ('y', 'yes', 't', 'true', 'on', '1'):
+ return 1
+ elif val in ('n', 'no', 'f', 'false', 'off', '0'):
+ return 0
+ else:
+ raise ValueError, "invalid truth value %s" % `val`
- Previous message: [Python-checkins] CVS: distutils/distutils dist.py,1.36,1.37
- Next message: [Python-checkins] CVS: distutils/distutils/command bdist_dumb.py,1.14,1.15 bdist_rpm.py,1.20,1.21 bdist_wininst.py,1.14,1.15 build.py,1.27,1.28 build_clib.py,1.19,1.20 build_ext.py,1.65,1.66 build_py.py,1.29,1.30 build_scripts.py,1.4,1.5 clean.py,1.9,1.10 install.py,1.47,1.48 install_data.py,1.13,1.14 install_headers.py,1.5,1.6 install_lib.py,1.30,1.31 install_scripts.py,1.8,1.9 sdist.py,1.47,1.48
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]