Prechádzať zdrojové kódy

move classes for errors in errors.py

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54903 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 12 rokov pred
rodič
commit
fb8ae109a0

+ 2 - 2
lib/python/pygrass/__init__.py

@@ -9,9 +9,9 @@ _libgis.G_gisinit('')
 import os as _os
 import sys as _sys
 
+import errors
 import gis
+import functions
 import raster
 import vector
 import modules
-import errors
-import functions

+ 18 - 6
lib/python/pygrass/errors.py

@@ -8,7 +8,7 @@ Created on Wed Aug 15 17:33:27 2012
 from grass.script import warning
 
 
-class GrassError(Exception):
+class AbstractError(Exception):
     def __init__(self, value):
         self.value = value
 
@@ -16,12 +16,24 @@ class GrassError(Exception):
         return repr(self.value)
 
 
-class OpenError(Exception):
-    def __init__(self, value):
-        self.value = value
+class ParameterError(Exception):
+    pass
 
-    def __str__(self):
-        return repr(self.value)
+
+class FlagError(Exception):
+    pass
+
+
+class DBError(AbstractError):
+    pass
+
+
+class GrassError(AbstractError):
+    pass
+
+
+class OpenError(AbstractError):
+    pass
 
 
 def must_be_open(method):

+ 1 - 9
lib/python/pygrass/modules/__init__.py

@@ -20,7 +20,7 @@ from xml.etree.ElementTree import fromstring
 
 import grass
 
-from grass.pygrass.errors import GrassError
+from grass.pygrass.errors import GrassError, ParameterError, FlagError
 
 #
 # this dictionary is used to extract the value of interest from the xml
@@ -54,14 +54,6 @@ _GETTYPE = {
 }
 
 
-class ParameterError(Exception):
-    pass
-
-
-class FlagError(Exception):
-    pass
-
-
 def _element2dict(xparameter):
     diz = dict(xparameter.items())
     for p in xparameter:

+ 1 - 8
lib/python/pygrass/vector/table.py

@@ -16,6 +16,7 @@ except:
 
 import grass.lib.vector as libvect
 from grass.pygrass.gis import Mapset
+from grass.pygrass.errors import DBError
 
 import sql
 
@@ -23,14 +24,6 @@ import sql
 DRIVERS = ('sqlite', 'pg')
 
 
-class DBError(Exception):
-    def __init__(self, value):
-        self.value = value
-
-    def __str__(self):
-        return repr(self.value)
-
-
 def get_path(path):
     if "$" not in path:
         return path