[amazon] Add French Support and Shopoob compatibilities

This commit is contained in:
Kitof 2015-02-18 13:04:31 +01:00 committed by Romain Bignon
commit 2012ac3690
5 changed files with 453 additions and 10 deletions

27
modules/amazon/module.py Normal file → Executable file
View file

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# Copyright(C) 2014 Oleg Plakhotniuk
#
@ -18,11 +18,13 @@
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from weboob.capabilities.shop import CapShop
from weboob.capabilities.shop import CapShop, Order
from weboob.tools.backend import Module, BackendConfig
from weboob.tools.value import ValueBackendPassword
from weboob.tools.value import Value, ValueBackendPassword
from weboob.tools.ordereddict import OrderedDict
from .browser import Amazon
from .fr.browser import AmazonFR
__all__ = ['AmazonModule']
@ -33,12 +35,24 @@ class AmazonModule(Module, CapShop):
VERSION = '1.1'
LICENSE = 'AGPLv3+'
DESCRIPTION = u'Amazon'
website_choices = OrderedDict([(k, u'%s (%s)' % (v, k)) for k, v in sorted({
'www.amazon.com': u'Amazon.com',
'www.amazon.fr': u'Amazon France',
}.iteritems())])
BROWSERS = {
'www.amazon.com': Amazon,
'www.amazon.fr': AmazonFR,
}
CONFIG = BackendConfig(
Value('website', label=u'Website', choices=website_choices, default='www.amazon.com'),
ValueBackendPassword('email', label='Username', masked=False),
ValueBackendPassword('password', label='Password'))
BROWSER = Amazon
def create_default_browser(self):
self.BROWSER = self.BROWSERS[self.config['website'].get()]
return self.create_browser(self.config['email'].get(),
self.config['password'].get())
@ -49,10 +63,15 @@ class AmazonModule(Module, CapShop):
return self.browser.get_order(id_)
def iter_orders(self):
return self.browser.iter_orders()
def iter_payments(self, order):
if not isinstance(order, Order):
order = self.get_order(order)
return self.browser.iter_payments(order)
def iter_items(self, order):
if not isinstance(order, Order):
order = self.get_order(order)
return self.browser.iter_items(order)