parse special cases
This commit is contained in:
parent
ac8e035d29
commit
c450ffde06
1 changed files with 17 additions and 3 deletions
|
|
@ -18,16 +18,20 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import re
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from weboob.tools.browser import BasePage
|
from weboob.tools.browser import BasePage
|
||||||
from weboob.capabilities.bank import Operation
|
from weboob.capabilities.bank import Operation
|
||||||
|
from weboob.capabilities.base import NotAvailable
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['AccountHistory']
|
__all__ = ['AccountHistory']
|
||||||
|
|
||||||
|
|
||||||
class AccountHistory(BasePage):
|
class AccountHistory(BasePage):
|
||||||
|
LABEL_PATTERNS = [(u'^CHEQUEN°(?P<no>.*)', u'CHEQUE', u'N°%(no)s')]
|
||||||
|
|
||||||
def on_loaded(self):
|
def on_loaded(self):
|
||||||
self.operations = []
|
self.operations = []
|
||||||
|
|
||||||
|
|
@ -44,11 +48,21 @@ class AccountHistory(BasePage):
|
||||||
if child.text: label += child.text
|
if child.text: label += child.text
|
||||||
if child.tail: label += child.tail
|
if child.tail: label += child.tail
|
||||||
if tds[1].tail: label += tds[1].tail
|
if tds[1].tail: label += tds[1].tail
|
||||||
|
|
||||||
label = label.strip()
|
label = label.strip()
|
||||||
|
category = NotAvailable
|
||||||
|
for pattern, _cat, _lab in self.LABEL_PATTERNS:
|
||||||
|
m = re.match(pattern, label)
|
||||||
|
if m:
|
||||||
|
category = _cat % m.groupdict()
|
||||||
|
label = _lab % m.groupdict()
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if ' ' in label:
|
||||||
|
category, useless, label = [part.strip() for part in label.partition(' ')]
|
||||||
|
|
||||||
amount = tds[2].text.replace('.', '').replace(',', '.')
|
amount = tds[2].text.replace('.', '').replace(',', '.')
|
||||||
(category, useless, label) = label.partition(' ')
|
|
||||||
category = category.strip()
|
|
||||||
label = label.strip()
|
|
||||||
# if we don't have exactly one '.', this is not a floatm try the next
|
# if we don't have exactly one '.', this is not a floatm try the next
|
||||||
operation = Operation(len(self.operations))
|
operation = Operation(len(self.operations))
|
||||||
if amount.count('.') != 1:
|
if amount.count('.') != 1:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue