code: def parse_boolean_envvar(val):
      
      if not val or val.lower() in {'false', '0'}:
          return False
      elif val.lower() in {'true', '1'}:
          return True
      else:
          raise ValueError('Invalid boolean environment variable: %s' % val)
docs: Parse a boolean environment variable.