Compare commits

...

4 commits

Author SHA1 Message Date
b731c2d085 fix mise config 2024-11-30 10:17:21 +01:00
5bb5b38a2c fix headless 2024-11-29 21:40:30 +01:00
f6c14d98b1 fix lcl downloader 2024-11-29 21:37:03 +01:00
03e1196f88 update dependencies 2024-11-29 20:24:53 +01:00
6 changed files with 698 additions and 586 deletions

3
.mise.toml Normal file
View file

@ -0,0 +1,3 @@
[tools]
poetry = {version='latest', pyproject='pyproject.toml'}
python = '3.13' # must be after poetry so the poetry bin is first in PATH

View file

@ -1,2 +0,0 @@
python 3.11.2
poetry latest

View file

@ -7,7 +7,7 @@ RUN wget -q https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVE
&& tar xvf $GECKODRIVER_FILENAME \
&& rm $GECKODRIVER_FILENAME
FROM python:3.11-slim-bookworm AS final
FROM python:3.13-slim-bookworm AS final
RUN apt-get update && apt-get install -y firefox-esr
COPY --from=downloader /app/geckodriver /usr/local/bin/geckodriver
ARG OFX_VERSION

View file

@ -5,6 +5,7 @@ from pathlib import Path
import click
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
@ -77,10 +78,10 @@ class LclDownloader:
self._click(By.ID, "export-button")
end = datetime.date.today() - datetime.timedelta(days=1)
start = end - datetime.timedelta(days=9)
start = end - datetime.timedelta(days=30)
self._type_nth(By.ID, "mat-input-0", 0, start.strftime("%d/%m/%Y"))
self._type_nth(By.ID, "mat-input-1", 0, end.strftime("%d/%m/%Y"))
self._type_date(By.ID, "mat-input-0", start)
self._type_date(By.ID, "mat-input-1", end)
self._click(By.CSS_SELECTOR, "ui-desktop-select button")
self._click_nth(By.CSS_SELECTOR, "ui-select-list ul li", 2)
@ -100,8 +101,21 @@ class LclDownloader:
def _select(self, by: By, value: str, index: int):
Select(self.selenium.find_element(by, value)).select_by_index(index)
def _type_nth(self, by: By, value: str, idx: int, value_to_type: str):
self.selenium.find_elements(by, value)[idx].send_keys(value_to_type)
def _type(self, by: By, value: str, value_to_type: str):
self.selenium.find_element(by, value).send_keys(value_to_type)
def _clear(self, by: By, value: str):
self.selenium.find_element(by, value).clear()
def _type_date(self, by: By, value: str, _date: datetime.date):
# The new version of the form doesn't behave nicely when typing the date.
self._type(by, value, "1")
self._type(by, value, Keys.ARROW_LEFT*5)
self._type(by, value, Keys.BACKSPACE*5)
self._type(by, value, _date.strftime("%d/%m"))
self._type(by, value, Keys.ARROW_RIGHT*5)
self._type(by, value, Keys.BACKSPACE*4)
self._type(by, value, _date.strftime("%Y"))
def _get_last_download_file_name(self, wait_seconds: int = 30):
end_time = time.time() + wait_seconds

1251
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "ofx-processor"
version = "4.5.3"
version = "4.5.5"
description = "Personal ofx processor"
readme = "README.md"
authors = ["Gabriel Augendre <gabriel@augendre.info>"]