From 2310e8506f60acc0621404f87ff3887b8e32a462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Tue, 24 Jan 2012 22:31:00 +0100 Subject: [PATCH] MappedVirtKeyboard: set attribute to return MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rather than imposing onclick, the map attribute whose value is returned when retrieving a code is now a constructor argument For the sake of backward compatibility, default is set to onclick Signed-off-by: Pierre Mazière --- weboob/tools/captcha/virtkeyboard.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/weboob/tools/captcha/virtkeyboard.py b/weboob/tools/captcha/virtkeyboard.py index 72ab98a3..fe03e5ef 100644 --- a/weboob/tools/captcha/virtkeyboard.py +++ b/weboob/tools/captcha/virtkeyboard.py @@ -123,7 +123,9 @@ class VirtKeyboard(object): img.save(dir+"/"+self.md5[i]+".png") class MappedVirtKeyboard(VirtKeyboard): - def __init__(self,file,document,img_element,color): + def __init__(self,file,document,img_element,color,map_attr): + if map_attr is None: # for backward compatibility + map_attr="onclick" map_id=img_element.attrib.get("usemap")[1:] map=document.find("//map[@id='"+map_id+"']") if map is None: @@ -131,7 +133,7 @@ class MappedVirtKeyboard(VirtKeyboard): coords={} for area in map.getiterator("area"): - code=area.attrib.get("onclick") + code=area.attrib.get(map_attr) area_coords=[] for coord in area.attrib.get("coords").split(','): area_coords.append(int(coord))