From 7b7511e49387e469178e50e6570af60118aa6546 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Mon, 17 Feb 2014 22:07:42 +0100 Subject: [PATCH] =?UTF-8?q?[attributs]=20Possibilit=C3=A9=20de=20donner=20?= =?UTF-8?q?=C3=A0=20manger=20un=20dicrionnaire=20=C3=A0=20une=20blackliste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attributs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/attributs.py b/attributs.py index 60424c0..0d12bfe 100644 --- a/attributs.py +++ b/attributs.py @@ -1076,7 +1076,13 @@ class blacklist(Attr): python_type = dict def parse_value(self, blacklist): - bl_debut, bl_fin, bl_type, bl_comm = blacklist.split('$') + if isinstance(blacklist, self.python_type): + if set(blacklist.keys()).issuperset(['debut', 'fin', 'type', 'comm']): + bl_debut, bl_fin, bl_type, bl_comm = (blacklist['debut'], blacklist['fin'], blacklist['type'], blacklist['comm']) + else: + raise ValueError("A blacklist should contain the following keys : 'debut', 'fin', 'type', 'comm'") + else: + bl_debut, bl_fin, bl_type, bl_comm = blacklist.split('$') now = time.time() self.value = { 'debut' : bl_debut if bl_debut == '-' else int (bl_debut), 'fin' : bl_fin if bl_fin == '-' else int(bl_fin),