Commit fe93d9a0 authored by Vincent Ardisson's avatar Vincent Ardisson Committed by Romain Bignon

[ing] port to python3

parent 9d71f984
......@@ -42,7 +42,7 @@ def start_with_main_site(f):
browser = args[0]
if browser.url and browser.url.startswith('https://bourse.ingdirect.fr/'):
for i in xrange(3):
for i in range(3):
try:
browser.location('https://bourse.ingdirect.fr/priv/redirectIng.php?pageIng=COMPTE')
except ServerError:
......@@ -104,9 +104,6 @@ class IngBrowser(LoginBrowser):
self.cache["investments_data"] = {}
def do_login(self):
assert isinstance(self.username, basestring)
assert isinstance(self.password, basestring)
assert isinstance(self.birthday, basestring)
assert self.password.isdigit()
assert self.birthday.isdigit()
......@@ -214,14 +211,14 @@ class IngBrowser(LoginBrowser):
else:
history_function = AccountsList.get_transactions_others
index = 0
hashlist = []
hashlist = set()
while True:
i = index
for transaction in history_function(self.page, index=index):
transaction.id = hashlib.md5(transaction._hash).hexdigest()
while transaction.id in hashlist:
transaction.id = hashlib.md5(transaction.id + "1").hexdigest()
hashlist.append(transaction.id)
transaction.id = hashlib.md5((transaction.id + "1").encode('ascii')).hexdigest()
hashlist.add(transaction.id)
i += 1
yield transaction
# if there is no more transactions, it is useless to continue
......
......@@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import re
from decimal import Decimal
......@@ -28,6 +29,7 @@ from weboob.browser.elements import ListElement, TableElement, ItemElement, meth
from weboob.browser.filters.standard import CleanDecimal, CleanText, Date, TableCell, Regexp, Env, Async, AsyncLoad
from weboob.browser.filters.html import Link, Attr
from weboob.tools.capabilities.bank.transactions import FrenchTransaction
from weboob.tools.compat import unicode
class NetissimaPage(HTMLPage):
pass
......@@ -42,6 +44,9 @@ class TitreValuePage(LoggedPage, HTMLPage):
class TitrePage(LoggedPage, RawPage):
def build_doc(self, content):
return content.decode(self.encoding)
def get_balance(self):
return CleanDecimal(default=None, replace_dots=True).filter(self.doc.split('{')[0])
......@@ -69,15 +74,15 @@ class TitrePage(LoggedPage, RawPage):
_pl = columns[start].split('{')[1]
_id = columns[start].split('{')[2]
invest = Investment()
invest.label = unicode(columns[start].split('{')[-1])
invest.code = unicode(_id) if _id is not None else NotAvailable
invest.label = columns[start].split('{')[-1]
invest.code = _id or NotAvailable
if invest.code and ':' in invest.code:
invest.code = self.browser.titrevalue.open(val=invest.code,pl=_pl).get_isin()
# The code we got is not a real ISIN code.
if invest.code and not re.match('^[A-Z]{2}[\d]{10}$|^[A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4}$', invest.code):
m = re.search('\{([A-Z]{2}[\d]{10})\{|\{([A-Z]{2}[\d]{5}[A-Z]{1}[\d]{4})\{', line)
if m:
invest.code = unicode(m.group(1) or m.group(2))
invest.code = m.group(1) or m.group(2)
for x, attr in enumerate(['quantity', 'unitprice', 'unitvalue', 'valuation', 'diff'], 1):
currency = FrenchTransaction.Currency().filter(columns[start + x])
......@@ -106,8 +111,8 @@ class TitrePage(LoggedPage, RawPage):
#We also have to get the liquidity as an investment.
invest = Investment()
invest.label = unicode("Liquidités", 'utf-8')
invest.code = unicode("XX-liquidity")
invest.label = "Liquidités"
invest.code = "XX-liquidity"
invest.valuation = CleanDecimal(None, True).filter(message.split('&')[3].replace('euro;{','').strip())
invests.append(invest)
for invest in invests:
......
......@@ -125,7 +125,7 @@ class TransferPage(LoggedPage, HTMLPage):
form.submit()
form = self.get_form()
keys = [k for k in form.iterkeys() if '_link_hidden' in k or 'j_idcl' in k]
keys = [k for k in form if '_link_hidden' in k or 'j_idcl' in k]
for k in keys:
form.pop(k)
form['AJAXREQUEST'] = "_viewRoot"
......
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