Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
weboob
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
182
Issues
182
List
Boards
Labels
Milestones
Merge Requests
50
Merge Requests
50
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
weboob
weboob
Commits
717e9fb9
Commit
717e9fb9
authored
Feb 09, 2021
by
Sylvie Ye
Committed by
Vincent A
Feb 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/captcha/virtkeyboard: allow to use custom tile in SimpleVirtualKeyboard
and reindent some lines
parent
9998a984
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
12 deletions
+20
-12
weboob/tools/captcha/virtkeyboard.py
weboob/tools/captcha/virtkeyboard.py
+20
-12
No files found.
weboob/tools/captcha/virtkeyboard.py
View file @
717e9fb9
...
...
@@ -368,6 +368,7 @@ class SimpleVirtualKeyboard(object):
tile_margin
=
None
symbols
=
None
convert
=
None
tile_klass
=
Tile
def
__init__
(
self
,
file
,
cols
,
rows
,
matching_symbols
=
None
,
matching_symbols_coords
=
None
,
browser
=
None
):
self
.
cols
=
cols
...
...
@@ -380,8 +381,10 @@ def __init__(self, file, cols, rows, matching_symbols=None, matching_symbols_coo
self
.
load_image
(
file
,
self
.
margin
,
self
.
convert
)
# Get self.tiles
self
.
get_tiles
(
matching_symbols
=
matching_symbols
,
matching_symbols_coords
=
matching_symbols_coords
)
self
.
get_tiles
(
matching_symbols
=
matching_symbols
,
matching_symbols_coords
=
matching_symbols_coords
)
# Tiles processing
self
.
cut_tiles
(
self
.
tile_margin
)
...
...
@@ -424,11 +427,12 @@ def cut_margin(self, image, margin):
assert
((
margin
[
0
]
+
margin
[
2
])
<
height
)
&
((
margin
[
1
]
+
margin
[
3
])
<
width
),
\
"Margin is too high, there is not enough pixel to cut."
image
=
image
.
crop
((
0
+
margin
[
3
],
0
+
margin
[
0
],
width
-
margin
[
1
],
height
-
margin
[
2
]
))
image
=
image
.
crop
((
0
+
margin
[
3
],
0
+
margin
[
0
],
width
-
margin
[
1
],
height
-
margin
[
2
]
))
return
image
def
get_tiles
(
self
,
matching_symbols
=
None
,
matching_symbols_coords
=
None
):
...
...
@@ -437,9 +441,12 @@ def get_tiles(self, matching_symbols=None, matching_symbols_coords=None):
# Tiles coords are given
if
matching_symbols_coords
:
for
matching_symbol
in
matching_symbols_coords
:
self
.
tiles
.
append
(
Tile
(
matching_symbol
=
matching_symbol
,
coords
=
matching_symbols_coords
[
matching_symbol
]
))
self
.
tiles
.
append
(
self
.
tile_klass
(
matching_symbol
=
matching_symbol
,
coords
=
matching_symbols_coords
[
matching_symbol
]
)
)
return
assert
(
not
self
.
width
%
self
.
cols
)
&
(
not
self
.
height
%
self
.
rows
),
\
...
...
@@ -501,6 +508,7 @@ def get_string_code(self, password):
else
:
# Dump file only if the symbol is not found
self
.
dump_tiles
(
self
.
path
)
raise
VirtKeyboardError
(
"Symbol '
%
s' not found; all symbol hashes are available in
%
s"
%
(
digit
,
self
.
path
))
raise
VirtKeyboardError
(
"Symbol '
%
s' not found; all symbol hashes are available in
%
s"
%
(
digit
,
self
.
path
)
)
return
self
.
codesep
.
join
(
word
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment