MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / as_boolean

Function as_boolean

keepercommander/commands/base.py:712–729  ·  view source on GitHub ↗
(value, default=None)

Source from the content-addressed store, hash-verified

710
711
712def as_boolean(value, default=None): # type: (Any, Optional[bool]) -> bool
713 if isinstance(value, bool):
714 return value
715
716 if isinstance(value, int):
717 return value > 0
718
719 if isinstance(value, str) and len(value) > 0:
720 value = value.lower()
721 if value in ('yes', 'y', 'on', '1', 'true', 't'):
722 return True
723 if value in ('no', 'n', 'off', '0', 'false', 'f'):
724 return False
725
726 if default is not None and isinstance(default, bool):
727 return default
728
729 raise Exception("Unknown value. Available values 'yes'/'no', 'y'/'n', 'on'/'off', '1'/'0', 'true'/'false'")
730
731
732class CliCommand(abc.ABC):

Callers 2

add_clientMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected