change currencies integer constants to ISO code strings
This commit is contained in:
parent
407774937d
commit
6099560b8c
11 changed files with 24 additions and 39 deletions
|
|
@ -61,7 +61,7 @@ class CitelisBrowser(BaseBrowser):
|
||||||
self.location('%s://%s/summarySearch.do?reqCode=search' % (self.PROTOCOL, self.DOMAIN))
|
self.location('%s://%s/summarySearch.do?reqCode=search' % (self.PROTOCOL, self.DOMAIN))
|
||||||
account = Account()
|
account = Account()
|
||||||
account.id = u'1'
|
account.id = u'1'
|
||||||
account.currency = Account.CUR_EUR
|
account.currency = 'EUR'
|
||||||
account.balance = self.page.get_balance()
|
account.balance = self.page.get_balance()
|
||||||
account.label = u'Synthèse financière'
|
account.label = u'Synthèse financière'
|
||||||
return [account]
|
return [account]
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,7 @@ class DashboardPage(BasePage):
|
||||||
account.balance = Decimal(FrenchTransaction.clean_amount(
|
account.balance = Decimal(FrenchTransaction.clean_amount(
|
||||||
get_field('accountTotal')))
|
get_field('accountTotal')))
|
||||||
account.label = get_field('accountLabel2')
|
account.label = get_field('accountLabel2')
|
||||||
account.currency = Account.TXT2CUR.get(get_field('accountDev'),
|
account.currency = account.get_currency(get_field('accountDev'))
|
||||||
Account.CUR_UNKNOWN)
|
|
||||||
|
|
||||||
return account
|
return account
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ from datetime import date, timedelta
|
||||||
import re
|
import re
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from weboob.capabilities.base import Currency
|
|
||||||
from weboob.capabilities.bank import Account, Transaction
|
from weboob.capabilities.bank import Account, Transaction
|
||||||
from weboob.capabilities.base import NotAvailable
|
from weboob.capabilities.base import NotAvailable
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
|
|
@ -59,7 +58,7 @@ class AccountsList(BasePage):
|
||||||
# TODO: no idea abount how proxy account are displayed
|
# TODO: no idea abount how proxy account are displayed
|
||||||
for a in self.document.xpath('//a[@class="mainclic"]'):
|
for a in self.document.xpath('//a[@class="mainclic"]'):
|
||||||
account = Account()
|
account = Account()
|
||||||
account.currency = Currency.CUR_EUR
|
account.currency = 'EUR'
|
||||||
account.id = unicode(a.find('span[@class="account-number"]').text)
|
account.id = unicode(a.find('span[@class="account-number"]').text)
|
||||||
account._id = account.id
|
account._id = account.id
|
||||||
account.label = unicode(a.find('span[@class="title"]').text)
|
account.label = unicode(a.find('span[@class="title"]').text)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
from weboob.capabilities.bill import ICapBill, SubscriptionNotFound,\
|
from weboob.capabilities.bill import ICapBill, SubscriptionNotFound,\
|
||||||
BillNotFound, Subscription, Bill
|
BillNotFound, Subscription, Bill
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||||
from weboob.capabilities.base import Currency
|
|
||||||
from weboob.tools.value import ValueBackendPassword
|
from weboob.tools.value import ValueBackendPassword
|
||||||
|
|
||||||
from .browser import Leclercmobile
|
from .browser import Leclercmobile
|
||||||
|
|
@ -106,5 +105,5 @@ class LeclercMobileBackend(BaseBackend, ICapBill):
|
||||||
balance = self.browser.get_balance()
|
balance = self.browser.get_balance()
|
||||||
balance.label = u"Balance %s" % subscription.id
|
balance.label = u"Balance %s" % subscription.id
|
||||||
balance.id = "%s-balance" % subscription.id
|
balance.id = "%s-balance" % subscription.id
|
||||||
balance.currency = Currency.CUR_EUR
|
balance.currency = 'EUR'
|
||||||
return balance
|
return balance
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
|
|
||||||
from weboob.capabilities.bill import ICapBill, Subscription, SubscriptionNotFound, Detail
|
from weboob.capabilities.bill import ICapBill, Subscription, SubscriptionNotFound, Detail
|
||||||
from weboob.capabilities.base import Currency
|
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||||
from weboob.tools.value import ValueBackendPassword
|
from weboob.tools.value import ValueBackendPassword
|
||||||
|
|
||||||
|
|
@ -80,5 +79,5 @@ class NettoKomBackend(BaseBackend, ICapBill):
|
||||||
balance.id = "%s-balance" % subscription.id
|
balance.id = "%s-balance" % subscription.id
|
||||||
balance.price = subscription._balance
|
balance.price = subscription._balance
|
||||||
balance.label = u"Balance %s" % subscription.id
|
balance.label = u"Balance %s" % subscription.id
|
||||||
balance.currency = Currency.CUR_EUR
|
balance.currency = 'EUR'
|
||||||
return balance
|
return balance
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
|
|
||||||
from weboob.capabilities.bill import ICapBill, Subscription, SubscriptionNotFound, Detail
|
from weboob.capabilities.bill import ICapBill, Subscription, SubscriptionNotFound, Detail
|
||||||
from weboob.capabilities.base import Currency
|
|
||||||
from weboob.tools.backend import BaseBackend, BackendConfig
|
from weboob.tools.backend import BaseBackend, BackendConfig
|
||||||
from weboob.tools.value import ValueBackendPassword
|
from weboob.tools.value import ValueBackendPassword
|
||||||
|
|
||||||
|
|
@ -76,5 +75,5 @@ class PoivyBackend(BaseBackend, ICapBill):
|
||||||
balance.id = "%s-balance" % subscription.id
|
balance.id = "%s-balance" % subscription.id
|
||||||
balance.price = subscription._balance
|
balance.price = subscription._balance
|
||||||
balance.label = u"Balance %s" % subscription.id
|
balance.label = u"Balance %s" % subscription.id
|
||||||
balance.currency = Currency.CUR_EUR
|
balance.currency = 'EUR'
|
||||||
return balance
|
return balance
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.base import Currency
|
|
||||||
from weboob.capabilities.bill import Subscription, Detail
|
from weboob.capabilities.bill import Subscription, Detail
|
||||||
from decimal import Decimal, InvalidOperation
|
from decimal import Decimal, InvalidOperation
|
||||||
from datetime import datetime, date, time
|
from datetime import datetime, date, time
|
||||||
|
|
@ -106,7 +105,7 @@ class HistoryPage(BasePage):
|
||||||
detail.price = Decimal(price)
|
detail.price = Decimal(price)
|
||||||
except InvalidOperation:
|
except InvalidOperation:
|
||||||
detail.price = Decimal(0) # free calls
|
detail.price = Decimal(0) # free calls
|
||||||
detail.currency = Currency.CUR_EUR
|
detail.currency = 'EUR'
|
||||||
|
|
||||||
yield detail
|
yield detail
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class Recipient(CapBaseObject, Currency):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
label = StringField('Name')
|
label = StringField('Name')
|
||||||
currency = IntField('Currency', default=Currency.CUR_UNKNOWN)
|
currency = StringField('Currency', default=None)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
CapBaseObject.__init__(self, 0)
|
CapBaseObject.__init__(self, 0)
|
||||||
|
|
|
||||||
|
|
@ -428,17 +428,11 @@ class CapBaseObject(object):
|
||||||
|
|
||||||
|
|
||||||
class Currency(object):
|
class Currency(object):
|
||||||
CUR_UNKNOWN = 0
|
CURRENCIES = {u'EUR': u'€',
|
||||||
CUR_EUR = 1
|
u'CHF': u'CHF',
|
||||||
CUR_CHF = 2
|
u'USD': u'$',
|
||||||
CUR_USD = 3
|
u'GBP': u'£',
|
||||||
|
}
|
||||||
TXT2CUR = OrderedDict(((u'€', CUR_EUR),
|
|
||||||
(u'EUR', CUR_EUR),
|
|
||||||
(u'CHF', CUR_CHF),
|
|
||||||
(u'$', CUR_USD),
|
|
||||||
(u'USD', CUR_USD),
|
|
||||||
))
|
|
||||||
|
|
||||||
EXTRACTOR = re.compile(r'[\d\s,\.\-]', re.UNICODE)
|
EXTRACTOR = re.compile(r'[\d\s,\.\-]', re.UNICODE)
|
||||||
|
|
||||||
|
|
@ -462,14 +456,11 @@ class Currency(object):
|
||||||
"""
|
"""
|
||||||
curtexts = klass.EXTRACTOR.sub(' ', text.upper()).split()
|
curtexts = klass.EXTRACTOR.sub(' ', text.upper()).split()
|
||||||
for curtext in curtexts:
|
for curtext in curtexts:
|
||||||
cur = klass.TXT2CUR.get(curtext)
|
for currency, symbol in klass.CURRENCIES.iteritems():
|
||||||
if cur is not None:
|
if curtext in (currency, symbol):
|
||||||
return cur
|
return currency
|
||||||
return klass.CUR_UNKNOWN
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def currency2txt(klass, currency):
|
def currency2txt(klass, currency):
|
||||||
for txt, value in klass.TXT2CUR.iteritems():
|
return klass.CURRENCIES.get(currency, u'')
|
||||||
if value == currency:
|
|
||||||
return txt
|
|
||||||
return u''
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
from .base import CapBaseObject, StringField, DateField, DecimalField, IntField, UserError, Currency
|
from .base import CapBaseObject, StringField, DateField, DecimalField, UserError
|
||||||
from .collection import ICapCollection
|
from .collection import ICapCollection
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ class Detail(CapBaseObject):
|
||||||
datetime = DateField('date information')
|
datetime = DateField('date information')
|
||||||
price = DecimalField('Total price, taxes included')
|
price = DecimalField('Total price, taxes included')
|
||||||
vat = DecimalField('Value added Tax')
|
vat = DecimalField('Value added Tax')
|
||||||
currency = IntField('Currency', default=Currency.CUR_UNKNOWN)
|
currency = StringField('Currency', default=None)
|
||||||
quantity = DecimalField('Number of units consumed')
|
quantity = DecimalField('Number of units consumed')
|
||||||
unit = StringField('Unit of the consumption')
|
unit = StringField('Unit of the consumption')
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ class Bill(CapBaseObject):
|
||||||
label = StringField('label of bill')
|
label = StringField('label of bill')
|
||||||
idparent = StringField('id of the parent subscription')
|
idparent = StringField('id of the parent subscription')
|
||||||
price = DecimalField('Price to pay')
|
price = DecimalField('Price to pay')
|
||||||
currency = IntField('Currency', default=Currency.CUR_UNKNOWN)
|
currency = StringField('Currency', default=None)
|
||||||
deadline = DateField('The latest day to pay')
|
deadline = DateField('The latest day to pay')
|
||||||
startdate = DateField('The first day the bill applies to')
|
startdate = DateField('The first day the bill applies to')
|
||||||
finishdate = DateField('The last day the bill applies to')
|
finishdate = DateField('The last day the bill applies to')
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from .base import IBaseCap, CapBaseObject, StringField, TimeField, DeltaField, \
|
from .base import IBaseCap, CapBaseObject, StringField, TimeField, DeltaField, \
|
||||||
DateField, DecimalField, IntField, Currency, UserError
|
DateField, DecimalField, UserError
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['Station', 'Departure', 'RoadStep', 'RoadmapError', 'RoadmapFilters', 'ICapTravel']
|
__all__ = ['Station', 'Departure', 'RoadStep', 'RoadmapError', 'RoadmapFilters', 'ICapTravel']
|
||||||
|
|
@ -54,7 +54,7 @@ class Departure(CapBaseObject):
|
||||||
information = StringField('Informations')
|
information = StringField('Informations')
|
||||||
plateform = StringField('Where the train will leave')
|
plateform = StringField('Where the train will leave')
|
||||||
price = DecimalField('Price of ticket')
|
price = DecimalField('Price of ticket')
|
||||||
currency = IntField('Currency', default=Currency.CUR_UNKNOWN)
|
currency = StringField('Currency', default=None)
|
||||||
|
|
||||||
def __init__(self, id, _type, _time):
|
def __init__(self, id, _type, _time):
|
||||||
CapBaseObject.__init__(self, id)
|
CapBaseObject.__init__(self, id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue