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