瀏覽代碼

pygrass: simplify logic in _check function

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71336 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 7 年之前
父節點
當前提交
3b9274c11e
共有 1 個文件被更改,包括 4 次插入6 次删除
  1. 4 6
      lib/python/pygrass/gis/__init__.py

+ 4 - 6
lib/python/pygrass/gis/__init__.py

@@ -66,14 +66,12 @@ def _check_raise(value, path, type):
              if value is empty return environmental variable
              if value is empty return environmental variable
     :rtype: str
     :rtype: str
     """
     """
-    if value and is_valid(value, path, type):
-        return value
-    elif value is '':
+    if value is '':
         from grass.pygrass.utils import getenv
         from grass.pygrass.utils import getenv
         return getenv(type)
         return getenv(type)
-    else:
-        raise GrassError("%s <%s> not found" % (type.title(),
-                                                join(path, value)))
+    if is_valid(value, path, type):
+        return value
+    raise GrassError("%s <%s> not found" % (type.title(), join(path, value)))
 
 
 
 
 def set_current_mapset(mapset, location=None, gisdbase=None):
 def set_current_mapset(mapset, location=None, gisdbase=None):