From feb0e378dc97d8657d36db9d5fece45f2abf7c8a Mon Sep 17 00:00:00 2001 From: Bezleputh Date: Mon, 23 Jun 2014 18:50:09 +0200 Subject: [PATCH] [thumbnail] remove data field in to_dict method to avoid json crash during convertion --- weboob/capabilities/image.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/weboob/capabilities/image.py b/weboob/capabilities/image.py index 5d557e184e..7c1d736795 100644 --- a/weboob/capabilities/image.py +++ b/weboob/capabilities/image.py @@ -18,6 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with weboob. If not, see . +from weboob.tools.ordereddict import OrderedDict from .base import NotLoaded, Field, BytesField from .file import ICapFile, BaseFile @@ -47,6 +48,21 @@ def __repr__(self): def __iscomplete__(self): return self.data is not NotLoaded + def to_dict(self): + def iter_decorate(d): + for key, value in d: + if key == 'data': + continue + + if key == 'id' and self.backend is not None: + value = self.fullid + + yield key, value + + fields_iterator = self.iter_fields() + return OrderedDict(iter_decorate(fields_iterator)) + + class ICapImage(ICapFile): """ Image file provider -- GitLab