-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(actors): Allow boolean-like values for SKIP_DRY (#538)
* fix: Allow boolean-like values for SKIP_DRY * Fix SKIP_DRY reporting logic * fix exc type * chore: Use getenv * chore: bump version number
- Loading branch information
Showing
8 changed files
with
94 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,6 @@ | |
from kingpin.constants import REQUIRED, STATE | ||
|
||
|
||
__author__ = "Matt Wise <[email protected]>" | ||
|
||
|
||
class FakeHTTPClientClass(object): | ||
"""Fake HTTPClient object for testing""" | ||
|
||
|
@@ -280,21 +277,6 @@ def test_execute(self): | |
res = yield self.actor.execute() | ||
self.assertEqual(res, True) | ||
|
||
def test_str2bool(self): | ||
self.assertEqual(True, self.actor.str2bool("true")) | ||
self.assertEqual(True, self.actor.str2bool("junk text")) | ||
self.assertEqual(True, self.actor.str2bool("1")) | ||
self.assertEqual(True, self.actor.str2bool(True)) | ||
self.assertEqual(False, self.actor.str2bool("false")) | ||
self.assertEqual(False, self.actor.str2bool("0")) | ||
self.assertEqual(False, self.actor.str2bool(False)) | ||
|
||
def test_str2bool_strict(self): | ||
self.assertEqual(True, self.actor.str2bool("true")) | ||
self.assertEqual(False, self.actor.str2bool(False)) | ||
with self.assertRaises(exceptions.InvalidOptions): | ||
self.actor.str2bool("Junk", strict=True) | ||
|
||
@testing.gen_test | ||
def test_check_condition(self): | ||
conditions = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,6 @@ | |
from kingpin import exceptions | ||
|
||
|
||
__author__ = "Matt Wise ([email protected])" | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
# Constants for some of the utilities below | ||
|
@@ -277,10 +275,9 @@ def populate_with_tokens( | |
left_wrapper: the character to use as the START of a token | ||
right_wrapper: the character to use as the END of a token | ||
strict: (bool) whether or not to make sure all tokens were replaced | ||
escape_sequence: character string to use as the escape sequence for | ||
left and right wrappers | ||
remove_escape_sequence: (bool) whether or not to remove the escape | ||
sequence if it found. For example \\%FOO\\% would turn into %FOO%. | ||
escape_sequence: character string to use as the escape sequence for left and right wrappers | ||
remove_escape_sequence: (bool) whether or not to remove the escape sequence if it found. For example \\%FOO\\% would turn into %FOO%. | ||
Example: | ||
export ME=biz | ||
|
@@ -499,3 +496,25 @@ def diff_dicts(dict1, dict2): | |
dict2 = [line.replace("u'", "'") for line in dict2] | ||
|
||
return "\n".join(difflib.unified_diff(dict1, dict2, n=2)) | ||
|
||
|
||
def str2bool(v, strict=False) -> bool: | ||
"""Returns a Boolean from a variety of inputs. | ||
Args: | ||
value: String/Bool | ||
strict: Whether or not to _only_ convert the known words into booleans, or whether to allow "any" word to be considered True other than the known False words. | ||
Returns: | ||
A boolean | ||
""" | ||
false = ("no", "false", "f", "0") | ||
true = ("yes", "true", "t", "1") | ||
|
||
string = str(v).lower() | ||
|
||
if strict: | ||
if string not in true and string not in false: | ||
raise ValueError(f"Expected [{true}, {false}] but got: {string}") | ||
|
||
return string not in false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""Kingpin version number. You must bump this when creating a new release. | ||
""" | ||
|
||
__version__ = "3.2.0" | ||
__version__ = "3.3.0" |