-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
################################################################ | ||
### Ocropy exceptions | ||
################################################################ | ||
|
||
class OcropusException(Exception): | ||
trace = 1 | ||
def __init__(self,*args,**kw): | ||
Exception.__init__(self,*args,**kw) | ||
|
||
class Unimplemented(OcropusException): | ||
trace = 1 | ||
"Exception raised when a feature is unimplemented." | ||
def __init__(self,s): | ||
Exception.__init__(self,inspect.stack()[1][3]) | ||
|
||
class Internal(OcropusException): | ||
trace = 1 | ||
"Exception raised when a feature is unimplemented." | ||
def __init__(self,s): | ||
Exception.__init__(self,inspect.stack()[1][3]) | ||
|
||
class RecognitionError(OcropusException): | ||
trace = 1 | ||
"Some kind of error during recognition." | ||
def __init__(self,explanation,**kw): | ||
self.context = kw | ||
s = [explanation] | ||
s += ["%s=%s"%(k,summary(kw[k])) for k in kw] | ||
message = " ".join(s) | ||
Exception.__init__(self,message) | ||
|
||
class Warning(OcropusException): | ||
trace = 0 | ||
def __init__(self,*args,**kw): | ||
OcropusException.__init__(self,*args,**kw) | ||
|
||
class BadClassLabel(OcropusException): | ||
trace = 0 | ||
"Exception for bad class labels in a dataset or input." | ||
def __init__(self,s): | ||
Exception.__init__(self,s) | ||
|
||
class BadImage(OcropusException): | ||
trace = 0 | ||
def __init__(self,*args,**kw): | ||
OcropusException.__init__(self,*args) | ||
|
||
class BadInput(OcropusException): | ||
trace = 0 | ||
def __init__(self,*args,**kw): | ||
OcropusException.__init__(self,*args,**kw) | ||
|
||
class FileNotFound(OcropusException): | ||
trace = 0 | ||
"""Some file-not-found error during OCRopus processing.""" | ||
def __init__(self,fname): | ||
self.fname = fname | ||
def __str__(self): | ||
return "file not found %s"%(self.fname,) |