From db230bcc36f31c54bd4803e4122a791dfd5fed3b Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sat, 3 Dec 2011 21:50:50 +0100 Subject: [PATCH] add a 'ratio' field --- weboob/backends/aum/contact.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/weboob/backends/aum/contact.py b/weboob/backends/aum/contact.py index a223758a..dd9fc80c 100644 --- a/weboob/backends/aum/contact.py +++ b/weboob/backends/aum/contact.py @@ -71,6 +71,15 @@ class FieldPopu(FieldBase): def get_value(self, profile, consts): return unicode(profile['popu'][self.key]) +class FieldPopuRatio(FieldBase): + def get_value(self, profile, consts): + v1 = float(profile['popu'][self.key]) + v2 = float(profile['popu'][self.key2]) + if v2 == 0.0: + return 'NaN' + else: + return '%.2f' % (v1 / v2) + class FieldOld(FieldBase): def get_value(self, profile, consts): birthday = parse_dt(profile[self.key]) @@ -140,6 +149,7 @@ class Contact(_Contact): ('invits', FieldPopu('invits')), ('bonus', FieldPopu('bonus')), ('score', FieldPopu('popu')), + ('ratio', FieldPopuRatio('mails', 'flashs')), ))), ('details', OrderedDict(( ('old', FieldOld('birthday')),