Repository URL to install this package:
|
Version:
1:7.26.0-1 ▾
|
datadog-agent
/
opt
/
datadog-agent
/
embedded
/
lib
/
python3.8
/
site-packages
/
datadog_checks
/
base
/
config.py
|
|---|
# (C) Datadog, Inc. 2018-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
def is_affirmative(value):
"""
Attempt to convert different type of values to a meaningful boolean
"""
# try string cast
if isinstance(value, str):
return value.lower() in {'yes', 'true', '1', 'y', 'on'}
# use object's implementation of `__bool__`, it's faster than cast.
# None -> False, 0 -> False, 1 -> True, etc.
return not not value
# Deprecated compatibility layer for Agent 5, will be removed in Agent 8
_is_affirmative = is_affirmative