Permalink
Browse files

py3k: Use new-style exceptions.

  • Loading branch information...
QuLogic authored and kba committed May 13, 2015
1 parent 2e62b8e commit 236fc3052b3c85d8e1c5f6c7aa90ebe91e382ad9
Showing with 7 additions and 7 deletions.
  1. +4 −4 ocrolib/extras/cairoextras.py
  2. +1 −1 ocrolib/toplevel.py
  3. +1 −1 ocropus-lpred
  4. +1 −1 ocropus-ltrain
@@ -25,7 +25,7 @@ def create_cairo_font_face_for_file(filename, faceindex=0, loadoptions=0):
# initialize freetype
_ft_lib = ctypes.c_void_p()
if FT_Err_Ok != _freetype_so.FT_Init_FreeType(ctypes.byref(_ft_lib)):
raise "Error initialising FreeType library."
raise OSError("Error initialising FreeType library.")
_surface = cairo.ImageSurface(cairo.FORMAT_A8, 0, 0)
_initialized = True
# create freetype face
@@ -34,14 +34,14 @@ def create_cairo_font_face_for_file(filename, faceindex=0, loadoptions=0):
cairo_t = PycairoContext.from_address(id(cairo_ctx)).ctx
_cairo_so.cairo_ft_font_face_create_for_ft_face.restype = ctypes.c_void_p
if FT_Err_Ok != _freetype_so.FT_New_Face(_ft_lib, filename, faceindex, ctypes.byref(ft_face)):
raise "Error creating FreeType font face for " + filename
raise Exception("Error creating FreeType font face for " + filename)
# create cairo font face for freetype face
cr_face = _cairo_so.cairo_ft_font_face_create_for_ft_face(ft_face, loadoptions)
if CAIRO_STATUS_SUCCESS != _cairo_so.cairo_font_face_status(cr_face):
raise "Error creating cairo font face for " + filename
raise Exception("Error creating cairo font face for " + filename)
_cairo_so.cairo_set_font_face(cairo_t, cr_face)
if CAIRO_STATUS_SUCCESS != _cairo_so.cairo_status(cairo_t):
raise "Error creating cairo font face for " + filename
raise Exception("Error creating cairo font face for " + filename)
face = cairo_ctx.get_font_face()
return face
View
@@ -62,7 +62,7 @@ def wrapper(*args,**kw):
result = f(*args,**kw)
print(" " * _trace1_depth, "LEAVE", name, ":", strc(result))
return result
except Exception,e:
except Exception as e:
print(" " * _trace1_depth, "ERROR", name, ":", e)
raise
finally:
View
@@ -96,7 +96,7 @@ for trial in range(len(inputs)):
err = edist.levenshtein(txt,gt)
errs += err
total += len(gt)
except e:
except Exception as e:
print(e)
if args.eval:
View
@@ -128,5 +128,5 @@ for trial in range(args.start,args.ntrain):
imshow(outputs.T,cmap=cm.hot,interpolation='bilinear',aspect='auto')
tight_layout()
ginput(1,0.01)
except e:
except Exception as e:
print(e)

0 comments on commit 236fc30

Please sign in to comment.