Skip to content

[boursorama] Fix the virtual keyboard

Woob Import requested to merge boursorama-fix-virtual-keyboard into master

The previous implementation relied on the presence, in the SVG, of an id representing the number. Unfortunately this id quickly disappeared, leaving us without an easy way to identify the number.

For a more reliable implementation, I choose to use a perceptual hash to allow for small differences in the image comparison. (The same approach that was in place before 69664cc4, but with a slightly different implementation)

However, SVG reading / rendering in python seems a complex issue, for which I unfortunately had to add some new dependencies:

(Note: cairosvg has itself some dependencies, that may be difficult to fetch, thus this should be taken into account when evaluating this MR)

dhash has not seen much changes since 2017, but is so simple that it may be stable enough for our use. We may also replace it with another perceptual hash implementation, the idea is to ease the comparison between a reference image, so that any (slight) variation of the SVG image can be worked around.

(I'm not so easy with a hash of the SVG 'content' as it's very easy to change the content of the SVG -thus changing the hash- without changing the resulting image. Thus I prefer to work on the resulting image, which means necessity to convert the SVG to a raster image. A perceptual hash is quicker than an OCR but should cope with slight modifications of the images.)

Merge request reports