瀏覽代碼

pygrass: rename functions to utils

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@62386 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 10 年之前
父節點
當前提交
67f36c038e

+ 1 - 1
lib/python/pygrass/Makefile

@@ -7,7 +7,7 @@ PYDIR = $(ETC)/python
 GDIR = $(PYDIR)/grass
 DSTDIR = $(GDIR)/pygrass
 
-MODULES = errors functions orderdict
+MODULES = errors utils orderdict
 
 CLEAN_SUBDIRS = messages modules raster vector gis shell tests
 

+ 1 - 1
lib/python/pygrass/gis/__init__.py

@@ -55,7 +55,7 @@ def _check(value, path, type):
     if value and CHECK_IS[type](join(path, value)):
         return value
     elif value is '':
-        from grass.pygrass.functions import getenv
+        from grass.pygrass.utils import getenv
         return getenv(type)
     else:
         raise GrassError("%s <%s> not found" % (type.title(),

+ 1 - 1
lib/python/pygrass/modules/grid/grid.py

@@ -11,7 +11,7 @@ from grass.script.setup import write_gisrc
 from grass.pygrass.gis import Mapset, Location
 from grass.pygrass.gis.region import Region
 from grass.pygrass.modules import Module
-from grass.pygrass.functions import get_mapset_raster, findmaps
+from grass.pygrass.utils import get_mapset_raster, findmaps
 
 from grass.pygrass.modules.grid.split import split_region_tiles
 from grass.pygrass.modules.grid.patch import rpatch_map

+ 1 - 1
lib/python/pygrass/modules/grid/patch.py

@@ -8,7 +8,7 @@ from __future__ import (nested_scopes, generators, division, absolute_import,
                         with_statement, print_function, unicode_literals)
 from grass.pygrass.gis.region import Region
 from grass.pygrass.raster import RasterRow
-from grass.pygrass.functions import coor2pixel
+from grass.pygrass.utils import coor2pixel
 
 
 def get_start_end_index(bbox_list):

+ 1 - 1
lib/python/pygrass/modules/interface/flag.py

@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 from __future__ import (nested_scopes, generators, division, absolute_import,
                         with_statement, print_function, unicode_literals)
-from grass.pygrass.functions import docstring_property
+from grass.pygrass.utils import docstring_property
 from grass.pygrass.modules.interface import read
 
 

+ 1 - 1
lib/python/pygrass/modules/interface/module.py

@@ -15,7 +15,7 @@ import time
 from grass.exceptions import CalledModuleError
 from grass.script.core import Popen, PIPE
 from grass.pygrass.errors import GrassError, ParameterError
-from grass.pygrass.functions import docstring_property
+from grass.pygrass.utils import docstring_property
 from grass.pygrass.modules.interface.parameter import Parameter
 from grass.pygrass.modules.interface.flag import Flag
 from grass.pygrass.modules.interface.typedict import TypeDict

+ 1 - 1
lib/python/pygrass/modules/interface/parameter.py

@@ -8,7 +8,7 @@ from __future__ import (nested_scopes, generators, division, absolute_import,
                         with_statement, print_function, unicode_literals)
 import re
 
-from grass.pygrass.functions import docstring_property
+from grass.pygrass.utils import docstring_property
 from grass.pygrass.modules.interface.read import GETTYPE, element2dict, DOC
 
 

+ 1 - 1
lib/python/pygrass/modules/interface/typedict.py

@@ -12,7 +12,7 @@ try:
 except ImportError:
     from grass.pygrass.orderdict import OrderedDict
 
-from grass.pygrass.functions import docstring_property
+from grass.pygrass.utils import docstring_property
 
 
 class TypeDict(OrderedDict):

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

@@ -22,7 +22,7 @@ libgis.G_gisinit('')
 #
 from grass.pygrass.errors import OpenError, must_be_open
 from grass.pygrass.gis.region import Region
-from grass.pygrass import functions
+from grass.pygrass import utils
 
 #
 # import raster classes
@@ -664,7 +664,7 @@ class RasterNumpy(np.memmap, RasterAbstractBase):
         """
         if not region:
             region = Region()
-        x, y = functions.coor2pixel(point.coords(), region)
+        x, y = utils.coor2pixel(point.coords(), region)
         return self[x][y]
 
 

+ 8 - 8
lib/python/pygrass/raster/abstract.py

@@ -18,7 +18,7 @@ import grass.lib.raster as libraster
 #
 # import pygrass modules
 #
-from grass.pygrass import functions
+from grass.pygrass import utils
 from grass.pygrass.gis.region import Region
 from grass.pygrass.errors import must_be_open
 from grass.pygrass.shell.conversion import dict2html
@@ -294,7 +294,7 @@ class RasterAbstractBase(object):
 
     def _set_name(self, newname):
         """Private method to change the Raster name"""
-        if not functions.is_clean_name(newname):
+        if not utils.is_clean_name(newname):
             str_err = _("Map name {0} not valid")
             raise ValueError(str_err.format(newname))
         if self.exist():
@@ -347,7 +347,7 @@ class RasterAbstractBase(object):
         return (self.__getitem__(irow) for irow in range(self._rows))
 
     def _repr_png_(self):
-        return raw_figure(functions.r_export(self))
+        return raw_figure(utils.r_export(self))
 
     def exist(self):
         """Return True if the map already exist, and
@@ -361,10 +361,10 @@ class RasterAbstractBase(object):
         """
         if self.name:
             if self.mapset == '':
-                mapset = functions.get_mapset_raster(self.name, self.mapset)
+                mapset = utils.get_mapset_raster(self.name, self.mapset)
                 self.mapset = mapset if mapset else ''
                 return True if mapset else False
-            return bool(functions.get_mapset_raster(self.name, self.mapset))
+            return bool(utils.get_mapset_raster(self.name, self.mapset))
         else:
             return False
 
@@ -391,7 +391,7 @@ class RasterAbstractBase(object):
         """Remove the map"""
         if self.is_open():
             self.close()
-        functions.remove(self.name, 'rast')
+        utils.remove(self.name, 'rast')
 
     def fullname(self):
         """Return the full name of a raster map: name@mapset"""
@@ -421,7 +421,7 @@ class RasterAbstractBase(object):
     def rename(self, newname):
         """Rename the map"""
         if self.exist():
-            functions.rename(self.name, newname, 'rast')
+            utils.rename(self.name, newname, 'rast')
         self._name = newname
 
     def set_from_rast(self, rastname='', mapset=''):
@@ -452,7 +452,7 @@ class RasterAbstractBase(object):
         """
         if not region:
             region = Region()
-        row, col = functions.coor2pixel(point.coords(), region)
+        row, col = utils.coor2pixel(point.coords(), region)
         if col < 0 or col > region.cols or row < 0 or row > region.rows:
             return None
         line = self.get_row(int(row))

lib/python/pygrass/functions.py → lib/python/pygrass/utils.py


+ 1 - 1
lib/python/pygrass/vector/__init__.py

@@ -212,7 +212,7 @@ class Vector(Info):
         False
 
         >>> cens.close()
-        >>> from grass.pygrass.functions import copy, remove
+        >>> from grass.pygrass.utils import copy, remove
         >>> copy('census','mycensus','vect')
         >>> from grass.pygrass.modules.shortcuts import vector as v
         >>> v.colors(map='mycensus', color='population', column='TOTAL_POP')

+ 7 - 7
lib/python/pygrass/vector/abstract.py

@@ -9,7 +9,7 @@ import datetime
 import grass.lib.vector as libvect
 from grass.pygrass.vector.vector_type import MAPTYPE
 
-from grass.pygrass import functions
+from grass.pygrass import utils
 from grass.pygrass.errors import GrassError, OpenError, must_be_open
 from grass.pygrass.vector.table import DBlinks, Link
 from grass.pygrass.vector.find import PointFinder, BboxFinder, PolygonFinder
@@ -104,7 +104,7 @@ class Info(object):
 
     def _set_name(self, newname):
         """Private method to change the Vector name"""
-        if not functions.is_clean_name(newname):
+        if not utils.is_clean_name(newname):
             str_err = _("Map name {0} not valid")
             raise ValueError(str_err.format(newname))
         if self.exist():
@@ -268,7 +268,7 @@ class Info(object):
         """
         if self.exist():
             if not self.is_open():
-                functions.rename(self.name, newname, 'vect')
+                utils.rename(self.name, newname, 'vect')
             else:
                 raise GrassError("The map is open, not able to renamed it.")
         self._name = newname
@@ -281,10 +281,10 @@ class Info(object):
         """Return if the Vector exists or not"""
         if self.name:
             if self.mapset == '':
-                mapset = functions.get_mapset_vector(self.name, self.mapset)
+                mapset = utils.get_mapset_vector(self.name, self.mapset)
                 self.mapset = mapset if mapset else ''
                 return True if mapset else False
-            return bool(functions.get_mapset_vector(self.name, self.mapset))
+            return bool(utils.get_mapset_vector(self.name, self.mapset))
         else:
             return False
 
@@ -388,7 +388,7 @@ class Info(object):
             self.layer = self.dblinks.by_layer(layer).layer
             self.table = self.dblinks.by_layer(layer).table()
             self.n_lines = self.table.n_rows()
-        self.writable = self.mapset == functions.getenv("MAPSET")
+        self.writable = self.mapset == utils.getenv("MAPSET")
         self.find = {'by_point': PointFinder(self.c_mapinfo, self.table,
                                              self.writable),
                      'by_box': BboxFinder(self.c_mapinfo, self.table,
@@ -417,7 +417,7 @@ class Info(object):
         """Remove vector map"""
         if self.is_open():
             self.close()
-        functions.remove(self.name, 'vect')
+        utils.remove(self.name, 'vect')
 
     def build(self):
         """Close the vector map and build vector Topology"""

+ 1 - 1
lib/python/pygrass/vector/geometry.py

@@ -176,7 +176,7 @@ class Attrs(object):
         """Set value of a given column of a table attribute.
 
         >>> from grass.pygrass.vector import VectorTopo
-        >>> from grass.pygrass.functions import copy, remove
+        >>> from grass.pygrass.utils import copy, remove
         >>> copy('schools', 'myschools', 'vect')
         >>> schools = VectorTopo('myschools')
         >>> schools.open('r')

+ 5 - 5
lib/python/pygrass/vector/table.py

@@ -25,7 +25,7 @@ except:
 import grass.lib.vector as libvect
 from grass.pygrass.gis import Mapset
 from grass.pygrass.errors import DBError
-from grass.pygrass.functions import table_exist
+from grass.pygrass.utils import table_exist
 from grass.script.db import db_table_in_vector
 from grass.script.core import warning
 
@@ -382,7 +382,7 @@ class Columns(object):
 
         >>> import sqlite3
         >>> path = '$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
-        >>> from grass.pygrass.functions import copy, remove
+        >>> from grass.pygrass.utils import copy, remove
         >>> copy('census','mycensus','vect')
         >>> cols_sqlite = Columns('mycensus',
         ...                       sqlite3.connect(get_path(path)))
@@ -441,7 +441,7 @@ class Columns(object):
 
         >>> import sqlite3
         >>> path = '$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
-        >>> from grass.pygrass.functions import copy, remove
+        >>> from grass.pygrass.utils import copy, remove
         >>> copy('census','mycensus','vect')
         >>> cols_sqlite = Columns('mycensus',
         ...                       sqlite3.connect(get_path(path)))
@@ -495,7 +495,7 @@ class Columns(object):
 
         >>> import sqlite3
         >>> path = '$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
-        >>> from grass.pygrass.functions import copy, remove
+        >>> from grass.pygrass.utils import copy, remove
         >>> copy('census','mycensus','vect')
         >>> cols_sqlite = Columns('mycensus',
         ...                       sqlite3.connect(get_path(path)))
@@ -536,7 +536,7 @@ class Columns(object):
 
         >>> import sqlite3
         >>> path = '$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
-        >>> from grass.pygrass.functions import copy, remove
+        >>> from grass.pygrass.utils import copy, remove
         >>> copy('census','mycensus','vect')
         >>> cols_sqlite = Columns('mycensus',
         ...                       sqlite3.connect(get_path(path)))

+ 1 - 1
lib/python/pygrass/vector/testsuite/test_vector3d.py

@@ -13,7 +13,7 @@ from grass.script.core import run_command
 from grass.pygrass.vector import VectorTopo
 from grass.pygrass.vector.geometry import Point
 from grass.pygrass.gis.region import Region
-from grass.pygrass.functions import get_mapset_vector
+from grass.pygrass.utils import get_mapset_vector
 
 
 def generate_coordinates(number, bbox=None, with_z=False):