Commit f5a744b8 authored by Hamza Dely's avatar Hamza Dely

[note_kfet/utils] Implémentation d'une fonction to_bool()

parent dd49cc1b
......@@ -5,6 +5,8 @@
from itertools import chain
from collections import OrderedDict
from distutils.util import strtobool
class CumulativeDict(OrderedDict):
"""
Dictionnaires permettant de renvoyer toutes les valeurs
......@@ -42,3 +44,12 @@ class CumulativeDict(OrderedDict):
if key not in self:
raise KeyError
self[key].append(value)
def to_bool(value):
"""
Convertit une chaine de caractères représentant un booléen en un booléen Python
"""
try:
return bool(strtobool(value))
except ValueError:
return None
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment