in packages/autorest.python/autorest/jsonrpc/__init__.py [0:0]
def get_boolean_value(self, key: str, default: Optional[bool] = None) -> Optional[bool]:
"""Check if value is present on the line, and interpret it as bool if it was.
If value is not not on the line, return the "default".
If the value is present, will also accept "true" or 1 as True.
For autorest, empty dict means "it was on the line", so we want it to true.
:returns: A boolean if it was present, or None if not
:rtype: Optional[bool]
"""
result = self.get_value(key)
if result is None:
return default
if result == {}: # autorest received --myoption
return True
if isinstance(result, bool):
return result
# Try as a string
try:
return result.lower() == "true"
except AttributeError: # not a string
pass
return result == 1