コード例 #1
0
ファイル: base.py プロジェクト: ankitrajshree/python-ocrlab
 def validate(self):
     super(FileNode, self).validate()
     if self._params.get("path") is None:
         raise exceptions.ValidationError("'path' not set", self)
     path = self._params.get("path", "")
     if isinstance(path, basestring) and not os.path.exists(path):
         raise exceptions.ValidationError("'path': file not found", self)
コード例 #2
0
 def validate(self):
     super(PilScale, self).validate()
     if not self._params.get("scale"):
         raise exceptions.ValidationError("'scale' is not set", self)
     try:
         num = float(self._params.get("scale"))
     except ValueError:
         raise exceptions.ValidationError("'float' must be a float", self)
コード例 #3
0
 def validate(self):
     super(Rotate90, self).validate()
     if not self._params.get("num"):
         raise exceptions.ValidationError("'num' is not set", self)
     try:
         num = int(self._params.get("num"))
     except ValueError:
         raise exceptions.ValidationError("'num' must be an integer", self)
コード例 #4
0
 def validate(self):
     """Check we're in a good state."""
     super(OcropusRecognizer, self).validate()
     if self._params.get("character_model", "").strip() == "":
         raise exceptions.ValidationError("no character model given.", self)
     if self._params.get("language_model", "").strip() == "":
         raise exceptions.ValidationError(
             "no language model given: %s" % self._params, self)
コード例 #5
0
 def validate(self):
     project_pk = self._params.get("project")
     try:
         pk = int(project_pk)
     except ValueError:
         raise exceptions.ValidationError("Project primary key not set.",
                                          self)
     val = self._params.get("pid")
     if not val.strip():
         raise exceptions.ValidationError("Pid not set", self)
コード例 #6
0
 def validate(self):
     super(FindReplace, self).validate()
     try:
         re.compile(self._params.get("find"))
     except Exception, err:
         raise exceptions.ValidationError(
             "find: regular expression error: %s" % err, self)
コード例 #7
0
 def validate(self):
     """Check state of the inputs."""
     self.logger.debug("%s: validating...", self)
     super(OcropusBase, self).validate()
     for i in range(len(self._inputs)):
         if self._inputs[i] is None:
             raise exceptions.ValidationError("missing input '%d'" % i,
                                              self)
コード例 #8
0
ファイル: fedora.py プロジェクト: ankitrajshree/python-ocrlab
 def validate(self):
     missing = []
     for pname in [p["name"] for p in self.parameters]:
         if not self._params.get(pname, "").strip():
             missing.append(pname)
     if missing:
         raise exceptions.ValidationError(
             "Missing parameter(s): %s" % ", ".join(missing), self)
コード例 #9
0
 def validate(self):
     """Check params are OK."""
     if self._params.get("path") is None:
         raise exceptions.ValidationError("'path' not set", self)
コード例 #10
0
 def validate(self):
     super(FileNode, self).validate()
     if self._params.get("path") is None:
         raise exceptions.ValidationError("'path' not set", self)
     if not os.path.exists(self._params.get("path", "")):
         raise exceptions.ValidationError("'path': file not found", self)