diff --git a/inotify/adapters.py b/inotify/adapters.py index e8301da..80a92e3 100644 --- a/inotify/adapters.py +++ b/inotify/adapters.py @@ -4,6 +4,7 @@ import struct import collections import time +from distutils.util import strtobool from errno import EINTR @@ -34,7 +35,15 @@ ]) _STRUCT_HEADER_LENGTH = struct.calcsize(_HEADER_STRUCT_FORMAT) -_IS_DEBUG = bool(int(os.environ.get('DEBUG', '0'))) + +def _cast_boolean(value): + """ + Helper to convert config values to boolean as ConfigParser do. + """ + value = str(value) + return bool(value) if value == '' else bool(strtobool(value)) + +_IS_DEBUG = _cast_boolean(os.environ.get('DEBUG', '0')) class EventTimeoutException(Exception):