From e1baccf1ec914563d3b2b845906cce024e7cd3b1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 13 Jan 2015 23:14:50 +0100 Subject: Replace 'except' with 'except Exception' --- module/plugins/captcha/LinksaveIn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/captcha/LinksaveIn.py') diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index 56cbd58a0..de6b0e7ff 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -79,7 +79,7 @@ class LinksaveIn(OCR): rgb_c = lut[pix[x, y]] try: cstat[rgb_c] += 1 - except: + except Exception: cstat[rgb_c] = 1 if rgb_bg == rgb_c: stat[bgpath] += 1 -- cgit v1.2.3 From de32c12bfc05b3d04df2686373e84494eefed44f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 24 Feb 2015 22:22:15 +0100 Subject: captcha -> OCR --- module/plugins/captcha/LinksaveIn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/captcha/LinksaveIn.py') diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index de6b0e7ff..b5cb0f608 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -9,13 +9,13 @@ from glob import glob from os import sep from os.path import abspath, dirname -from module.plugins.captcha.captcha import OCR +from module.plugins.captcha.OCR import OCR class LinksaveIn(OCR): __name__ = "LinksaveIn" __type__ = "ocr" - __version__ = "0.10" + __version__ = "0.11" __description__ = """Linksave.in ocr plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 7beb65e991bc6d1913c3b5bb2ef69e659d5b8342 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 01:55:52 +0100 Subject: Spare code cosmetics --- module/plugins/captcha/LinksaveIn.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/captcha/LinksaveIn.py') diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index b5cb0f608..a7ae715fe 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -46,7 +46,7 @@ class LinksaveIn(OCR): pix = frame.load() for x in xrange(frame.size[0]): for y in xrange(frame.size[1]): - if lut[pix[x, y]] != (0,0,0): + if lut[pix[x, y]] != (0, 0, 0): npix[x, y] = lut[pix[x, y]] frame_nr += 1 new.save(self.data_dir+"unblacked.png") @@ -112,7 +112,7 @@ class LinksaveIn(OCR): rgb_bg = bglut[bgpix[x, y]] rgb_c = lut[pix[x, y]] if rgb_c == rgb_bg: - orgpix[x, y] = (255,255,255) + orgpix[x, y] = (255, 255, 255) def eval_black_white(self): @@ -126,13 +126,13 @@ class LinksaveIn(OCR): r, g, b = rgb pix[x, y] = (255,255,255) if r > max(b, g)+thresh: - pix[x, y] = (0,0,0) + pix[x, y] = (0, 0, 0) if g < min(r, b): - pix[x, y] = (0,0,0) + pix[x, y] = (0, 0, 0) if g > max(r, b)+thresh: - pix[x, y] = (0,0,0) + pix[x, y] = (0, 0, 0) if b > max(r, g)+thresh: - pix[x, y] = (0,0,0) + pix[x, y] = (0, 0, 0) self.image = new self.pixels = self.image.load() -- cgit v1.2.3 From 589121e80835c63aea0880a53c6678de5c31c16e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 28 Mar 2015 01:59:01 +0100 Subject: Spare code cosmetics --- module/plugins/captcha/LinksaveIn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/captcha/LinksaveIn.py') diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index a7ae715fe..e256da502 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -124,7 +124,7 @@ class LinksaveIn(OCR): for y in xrange(new.size[1]): rgb = orgpix[x, y] r, g, b = rgb - pix[x, y] = (255,255,255) + pix[x, y] = (255, 255, 255) if r > max(b, g)+thresh: pix[x, y] = (0, 0, 0) if g < min(r, b): -- cgit v1.2.3 From 1ef93e913238275f7657d496ba3d2e7eeb5a30a2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 May 2015 01:06:01 +0200 Subject: Use 'import' instead 'from' --- module/plugins/captcha/LinksaveIn.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'module/plugins/captcha/LinksaveIn.py') diff --git a/module/plugins/captcha/LinksaveIn.py b/module/plugins/captcha/LinksaveIn.py index e256da502..95b107977 100644 --- a/module/plugins/captcha/LinksaveIn.py +++ b/module/plugins/captcha/LinksaveIn.py @@ -5,9 +5,8 @@ try: except ImportError: import Image -from glob import glob -from os import sep -from os.path import abspath, dirname +import glob +import os from module.plugins.captcha.OCR import OCR @@ -24,7 +23,7 @@ class LinksaveIn(OCR): def __init__(self): OCR.__init__(self) - self.data_dir = dirname(abspath(__file__)) + sep + "LinksaveIn" + sep + self.data_dir = os.path.dirname(os.path.abspath(__file__)) + os.sep + "LinksaveIn" + os.sep def load_image(self, image): @@ -59,7 +58,7 @@ class LinksaveIn(OCR): stat = {} cstat = {} img = self.image.convert("P") - for bgpath in glob(self.data_dir+"bg/*.gif"): + for bgpath in glob.glob(self.data_dir+"bg/*.gif"): stat[bgpath] = 0 bg = Image.open(bgpath) -- cgit v1.2.3