Commit 86f90b0c authored by Romain Bignon's avatar Romain Bignon

aum: fix compatibility with python3

parent 29c0cab6
Pipeline #1877 passed with stages
in 16 minutes and 35 seconds
......@@ -154,9 +154,9 @@ class AuMBrowser(DomainBrowser):
headers = kwargs.setdefault('headers', {})
if 'applications' not in url:
today = local2utc(datetime.now()).strftime('%Y-%m-%d')
token = sha256(self.username + self.APITOKEN + today).hexdigest()
token = sha256((self.username + self.APITOKEN + today).encode('utf-8')).hexdigest()
headers['Authorization'] = 'Basic %s' % (b64encode('%s:%s' % (self.username, self.password)))
headers['Authorization'] = 'Basic %s' % (b64encode(b'%s:%s' % (self.username.encode('utf-8'), self.password.encode('utf-8')))).decode('utf-8')
headers['X-Platform'] = 'android'
headers['X-Client-Version'] = self.APIVERSION
headers['X-AUM-Token'] = token
......@@ -181,8 +181,8 @@ class AuMBrowser(DomainBrowser):
return self.consts
self.consts = [{}, {}]
for key, sexes in self.request('values').iteritems():
for sex, values in sexes.iteritems():
for key, sexes in self.request('values').items():
for sex, values in sexes.items():
if sex in ('boy', 'both'):
self.consts[0][key] = values
if sex in ('girl', 'both'):
......
......@@ -26,6 +26,7 @@ from collections import OrderedDict
from weboob.capabilities.contact import Contact as _Contact, ProfileNode
from weboob.tools.html import html2text
from weboob.tools.compat import unicode, basestring
class FieldBase(object):
......@@ -242,7 +243,7 @@ class Contact(_Contact):
self.profile = OrderedDict()
if 'sex' in profile:
for section, d in self.TABLE.iteritems():
for section, d in self.TABLE.items():
flags = ProfileNode.SECTION
if section.startswith('_'):
flags |= ProfileNode.HEAD
......@@ -254,7 +255,7 @@ class Contact(_Contact):
s = ProfileNode(section, section.capitalize(), OrderedDict(), flags=flags)
for key, builder in d.iteritems():
for key, builder in d.items():
try:
value = builder.get_value(profile, consts[int(profile['sex'])])
except KeyError:
......
......@@ -36,6 +36,7 @@ from weboob.exceptions import BrowserUnavailable, BrowserHTTPNotFound
from weboob.tools.value import Value, ValueBool, ValueBackendPassword
from weboob.tools.date import local2utc
from weboob.tools.misc import to_unicode
from weboob.tools.compat import unicode, long, basestring
from .contact import Contact
from .antispam import AntiSpam
......@@ -104,7 +105,7 @@ class AuMModule(Module, CapMessages, CapMessagesPost, CapDating, CapChat, CapCon
all_events[u'baskets'] = (self.browser.get_baskets, 'You were put into %s\'s basket')
all_events[u'flashs'] = (self.browser.get_flashs, 'You sent a charm to %s')
all_events[u'visits'] = (self.browser.get_visits, 'Visited by %s')
for type, (events, message) in all_events.iteritems():
for type, (events, message) in all_events.items():
for event in events():
e = Event(event['who']['id'])
......@@ -343,7 +344,7 @@ class AuMModule(Module, CapMessages, CapMessagesPost, CapDating, CapChat, CapCon
if 'profile' in fields:
contact = self.get_contact(contact)
if contact and 'photos' in fields:
for name, photo in contact.photos.iteritems():
for name, photo in contact.photos.items():
if photo.url and not photo.data:
data = self.browser.openurl(photo.url).read()
contact.set_photo(name, data=data)
......
......@@ -14,6 +14,7 @@ anticaptcha
amundi
apec
arte
aum
avendrealouer
axabanque
bandcamp
......
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