From 0068712203fd4cbe4d0821b120a5057bbef36c52 Mon Sep 17 00:00:00 2001 From: "ChangBo Guo(gcb)" Date: Fri, 30 Sep 2016 21:13:21 +0800 Subject: [PATCH] doc: Fix docstring of method bool_from_string Method bool_from_string accept boolean, string, and integer value. This commit adjusts the document to reflect acceptable argument type. Change-Id: I836d2bed89c22dc123052fbb580c0601076c12ab --- oslo_utils/strutils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/oslo_utils/strutils.py b/oslo_utils/strutils.py index d22a5b34..d0b9ad76 100644 --- a/oslo_utils/strutils.py +++ b/oslo_utils/strutils.py @@ -111,11 +111,14 @@ def int_from_bool_as_string(subject): def bool_from_string(subject, strict=False, default=False): - """Interpret a string as a boolean. + """Interpret a subject as a boolean. - A case-insensitive match is performed such that strings matching 't', - 'true', 'on', 'y', 'yes', or '1' are considered True and, when - `strict=False`, anything else returns the value specified by 'default'. + A subject can be a boolean, a string or an integer. Boolean type value + will be returned directly, otherwise the subject will be converted to + a string. A case-insensitive match is performed such that strings + matching 't','true', 'on', 'y', 'yes', or '1' are considered True and, + when `strict=False`, anything else returns the value specified by + 'default'. Useful for JSON-decoded stuff and config file parsing.