From a6a7130b31a888ea1830b1aa29d0dca2f4c45aab Mon Sep 17 00:00:00 2001 From: smurail Date: Mon, 20 Oct 2014 13:21:43 +0200 Subject: [PATCH] add ChecksumPage mixin --- weboob/browser/pages.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/weboob/browser/pages.py b/weboob/browser/pages.py index 27fcfcc8..094788e6 100644 --- a/weboob/browser/pages.py +++ b/weboob/browser/pages.py @@ -570,3 +570,17 @@ class LoggedPage(object): pages with a login form. """ logged = True + + +class ChecksumPage(object): + """ + Compute a checksum of raw content before parsing it. + """ + import hashlib + + hashfunc = hashlib.md5 + checksum = None + + def build_doc(self, content): + self.checksum = self.hashfunc(content).hexdigest() + return super(ChecksumPage, self).build_doc(content)