weboob.tools.captcha.virtkeyboard

class weboob.tools.captcha.virtkeyboard.GridVirtKeyboard(symbols, cols, rows, image, color, convert=None)

Bases: weboob.tools.captcha.virtkeyboard.VirtKeyboard

Make a virtual keyboard where “keys” are distributed on a grid. For example: https://www.esgbl.com/part/fr/idehom.html

Parameters:
param symbols:Sequence of symbols, ordered in the grid from left to right and up to down
type symbols:iterable
param cols:Column count of the grid
type cols:int
param rows:Row count of the grid
type rows:int
param image:File-like object to be used as data source
type image:file
param color:Color of the meaningful pixels
type color:3-tuple
param convert:Mode to which convert color of pixels, see Image.Image.convert() for more information
Attributes:
attribute symbols:
 Association table between symbols and md5s
type symbols:dict
symbols = {}
class weboob.tools.captcha.virtkeyboard.MappedVirtKeyboard(file, document, img_element, color, map_attr='onclick', convert=None)

Bases: weboob.tools.captcha.virtkeyboard.VirtKeyboard

class weboob.tools.captcha.virtkeyboard.SimpleVirtualKeyboard(file, cols, rows, matching_symbols=None, matching_symbols_coords=None, browser=None)

Bases: object

Handle a virtual keyboard where “keys” are distributed on a simple grid.

Parameters:
param cols:Column count of the grid
type cols:int
param rows:Row count of the grid
type rows:int
param image:File-like object to be used as data source
type image:file
param convert:Mode to which convert color of pixels, see Image.Image.convert() for more information
param matching_symbols:
 symbol that match all case of image grid from left to right and top to down, European reading way.
type matching_symbols:
 iterable
param matching_symbols_coords:
 dict mapping matching website symbols to their image coords (x0, y0, x1, y1) on grid image from left to right and top to down, European reading way. It’s not symbols in the image.
type matching_symbols_coords:
 dict[str:4-tuple(int)]
param browser:Browser of weboob session. Allow to dump tiles files in same directory than session folder
type browser:obj(Browser)
Attributes:
attribute codesep:
 Output separator between matching symbols
type codesep:str
param margin:Useless image pixel to cut. See cut_margin().
type margin:4-tuple(int), same as HTML margin: (top, right, bottom, left). or 2-tuple(int), (top = bottom, right = left), or int, top = right = bottom = left
attribute tile_margin:
 Useless tile pixel to cut. See cut_margin().
attribute symbols:
 Association table between image symbols and md5s
type symbols:dict[str:str] or dict[str:n-tuple(str)]
attribute convert:
 Mode to which convert color of pixels, see Image.Image.convert() for more information
attribute alter:
 Allow custom main image alteration. Then overwrite alter_image().
type alter:boolean
alter_image()
build_path(browser=None)
codesep = ''
convert = None
cut_margin(image, margin)
cut_tiles(tile_margin=None)
dump_tiles(path)
get_string_code(password)
get_tile_coords_in_grid(case_index)
get_tiles(matching_symbols=None, matching_symbols_coords=None)
hash_md5_tiles()
load_image(file, margin=None, convert=None)
margin = None
symbols = None
tile_margin = None
class weboob.tools.captcha.virtkeyboard.SplitKeyboard(code_to_filedata)

Bases: object

Virtual keyboard for when the chars are in individual images, not a single grid

Create a SplitKeyboard

Parameters:code_to_filedata (dict[str, str]) – dict mapping site codes to images data
char_to_hash = None

dict mapping password characters to image hashes

checksum(buffer)
codesep = ''

Output separator between symbols

classmethod create_from_url(browser, code_to_url)
dump(files, path)
get_string_code(password)
class weboob.tools.captcha.virtkeyboard.Tile(matching_symbol, coords, image=None, md5=None)

Bases: object

Tile of a image grid for SimpleVirtualKeyboard

class weboob.tools.captcha.virtkeyboard.VirtKeyboard(file=None, coords=None, color=None, convert=None)

Bases: object

Handle a virtual keyboard.

Attribute margin:
 Margin used by get_symbol_coords() to reduce size of each “key” of the virtual keyboard. This attribute is always converted to a 4-tuple, and has the same semantic as the CSS margin property (top, right, bottom, right), in pixels.
check_color(pixel)
check_symbols(symbols, dirname)
checksum(coords)
codesep = ''

Output separator between code strings.

See get_string_code().

generate_MD5(dir)
get_string_code(string)
get_symbol_code(md5sum_list)
get_symbol_coords(coords)

Return narrow coordinates around symbol.

load_image(file, color, convert=None)
load_symbols(coords)
margin = None
exception weboob.tools.captcha.virtkeyboard.VirtKeyboardError

Bases: exceptions.Exception