[GRASS-SVN] r54882 - in grass/trunk/lib/python/pygrass: . gis modules raster vector

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 3 13:00:39 PST 2013


Author: lucadelu
Date: 2013-02-03 13:00:39 -0800 (Sun, 03 Feb 2013)
New Revision: 54882

Modified:
   grass/trunk/lib/python/pygrass/__init__.py
   grass/trunk/lib/python/pygrass/errors.py
   grass/trunk/lib/python/pygrass/functions.py
   grass/trunk/lib/python/pygrass/gis/__init__.py
   grass/trunk/lib/python/pygrass/gis/region.py
   grass/trunk/lib/python/pygrass/modules/__init__.py
   grass/trunk/lib/python/pygrass/orderdict.py
   grass/trunk/lib/python/pygrass/raster/__init__.py
   grass/trunk/lib/python/pygrass/raster/abstract.py
   grass/trunk/lib/python/pygrass/raster/buffer.py
   grass/trunk/lib/python/pygrass/raster/category.py
   grass/trunk/lib/python/pygrass/raster/history.py
   grass/trunk/lib/python/pygrass/raster/raster_type.py
   grass/trunk/lib/python/pygrass/raster/rowio.py
   grass/trunk/lib/python/pygrass/raster/segment.py
   grass/trunk/lib/python/pygrass/vector/__init__.py
   grass/trunk/lib/python/pygrass/vector/abstract.py
   grass/trunk/lib/python/pygrass/vector/basic.py
   grass/trunk/lib/python/pygrass/vector/geometry.py
   grass/trunk/lib/python/pygrass/vector/sql.py
   grass/trunk/lib/python/pygrass/vector/table.py
   grass/trunk/lib/python/pygrass/vector/vector_type.py
Log:
cleanup pygrass: change method of import, add newline at the end of files

Modified: grass/trunk/lib/python/pygrass/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/__init__.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/__init__.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -9,13 +9,9 @@
 import os as _os
 import sys as _sys
 
-_pygrasspath = _os.path.dirname(_os.path.realpath(__file__)).split(_os.sep)
-
-_sys.path.append(_os.path.join(_os.sep, *_pygrasspath[:-1]))
-
 import gis
 import raster
 import vector
 import modules
 import errors
-import functions
\ No newline at end of file
+import functions

Modified: grass/trunk/lib/python/pygrass/errors.py
===================================================================
--- grass/trunk/lib/python/pygrass/errors.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/errors.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -7,6 +7,7 @@
 
 from grass.script import warning
 
+
 class GrassError(Exception):
     def __init__(self, value):
         self.value = value
@@ -29,4 +30,4 @@
             return method(self, *args, **kargs)
         else:
             warning(_("The map is close!"))
-    return wrapper
\ No newline at end of file
+    return wrapper

Modified: grass/trunk/lib/python/pygrass/functions.py
===================================================================
--- grass/trunk/lib/python/pygrass/functions.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/functions.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -11,8 +11,8 @@
 import grass.lib.raster as libraster
 from grass.script import core as grasscore
 
-from pygrass.errors import GrassError
-from pygrass.gis.region import Region
+from grass.pygrass.errors import GrassError
+from grass.pygrass.gis.region import Region
 
 
 def looking(obj, filter_string):
@@ -83,7 +83,6 @@
 def coor2pixel((east, north), region):
     """Convert coordinates into a pixel row and col ::
 
-        >>> from pygrass.region import Region
         >>> reg = Region()
         >>> coor2pixel((reg.west, reg.north), reg)
         (0.0, 0.0)
@@ -97,7 +96,6 @@
 def pixel2coor((col, row), region):
     """Convert row and col of a pixel into a coordinates ::
 
-        >>> from pygrass.region import Region
         >>> reg = Region()
         >>> pixel2coor((0, 0), reg) == (reg.north, reg.west)
         True
@@ -124,4 +122,4 @@
     if point.num_primitive_of('point') == 0:
         raise GrassError(_("Vector doesn't contain points"))
     values = [raster.get_value(poi.coords, reg) for poi in point.viter('point')]
-    return values
\ No newline at end of file
+    return values

Modified: grass/trunk/lib/python/pygrass/gis/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/gis/__init__.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/gis/__init__.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -21,8 +21,9 @@
 script.gisenv()
 
 import grass.lib.gis as libgis
-from pygrass.functions import getenv
-from pygrass.errors import GrassError
+from grass.pygrass.functions import getenv
+from grass.pygrass.errors import GrassError
+import region
 
 
 #write dec to check if user have permissions or not
@@ -279,8 +280,3 @@
                 if pattern:
                     return fnmatch.filter(elist, pattern)
                 return elist
-
-
-if __name__ == "__main__":
-    import doctest
-    doctest.testmod(verbose=False)
\ No newline at end of file

Modified: grass/trunk/lib/python/pygrass/gis/region.py
===================================================================
--- grass/trunk/lib/python/pygrass/gis/region.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/gis/region.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -8,7 +8,7 @@
 import grass.lib.gis as libgis
 import grass.script as grass
 
-from pygrass.errors import GrassError
+from grass.pygrass.errors import GrassError
 
 
 class Region(object):
@@ -224,7 +224,7 @@
             raise GrassError("Cannot change region (WIND file).")
 
     def bbox(self):
-        from pygrass.vector.basic import Bbox
+        from grass.pygrass.vector.basic import Bbox
         return Bbox(north=self.north, south=self.south,
                     east=self.east, west=self.west,
-                    top=self.top, bottom=self.bottom)
\ No newline at end of file
+                    top=self.top, bottom=self.bottom)

Modified: grass/trunk/lib/python/pygrass/modules/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/__init__.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/modules/__init__.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -13,14 +13,14 @@
 try:
     from collections import OrderedDict
 except ImportError:
-    from pygrass.orderdict import OrderedDict
+    from grass.pygrass.orderdict import OrderedDict
 
 from itertools import izip_longest
 from xml.etree.ElementTree import fromstring
 
 import grass
 
-from pygrass.errors import GrassError
+from grass.pygrass.errors import GrassError
 
 #
 # this dictionary is used to extract the value of interest from the xml
@@ -662,4 +662,4 @@
 raster = MetaModule('r')
 raster3D = MetaModule('r3')
 temporal = MetaModule('t')
-vector = MetaModule('v')
\ No newline at end of file
+vector = MetaModule('v')

Modified: grass/trunk/lib/python/pygrass/orderdict.py
===================================================================
--- grass/trunk/lib/python/pygrass/orderdict.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/orderdict.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -256,4 +256,4 @@
 
     def viewitems(self):
         "od.viewitems() -> a set-like object providing a view on od's items"
-        return ItemsView(self)
\ No newline at end of file
+        return ItemsView(self)

Modified: grass/trunk/lib/python/pygrass/raster/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/__init__.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/raster/__init__.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -22,9 +22,9 @@
 #
 # import pygrass modules
 #
-from pygrass.errors import OpenError, must_be_open
-from pygrass.gis.region import Region
-from pygrass import functions
+from grass.pygrass.errors import OpenError, must_be_open
+from grass.pygrass.gis.region import Region
+from grass.pygrass import functions
 
 #
 # import raster classes
@@ -462,7 +462,7 @@
     * Overrides the open and close methods
     * Be aware of the 2Gig file size limit
 
-    >>> import pygrass
+    >>> import grass.pygrass as pygrass
     >>> elev = pygrass.raster.RasterNumpy('elevation')
     >>> elev.open()
     >>> elev[:5, :3]
@@ -687,8 +687,3 @@
         random_map.put_row(row_buf)
     random_map.close()
     return random_map
-
-
-if __name__ == "__main__":
-    import doctest
-    doctest.testmod()
\ No newline at end of file

Modified: grass/trunk/lib/python/pygrass/raster/abstract.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/abstract.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/raster/abstract.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -8,6 +8,8 @@
 
 import ctypes
 
+from numpy import isnan
+
 #
 # import GRASS modules
 #
@@ -21,9 +23,9 @@
 #
 # import pygrass modules
 #
-from pygrass import functions
-from pygrass.gis.region import Region
-from pygrass.errors import must_be_open
+from grass.pygrass import functions
+from grass.pygrass.gis.region import Region
+from grass.pygrass.errors import must_be_open
 
 #
 # import raster classes
@@ -368,4 +370,4 @@
     @must_be_open
     def set_cat(self, label, min_cat, max_cat=None, index=None):
         """Set or update a category"""
-        self.cats.set_cat(index, (label, min_cat, max_cat))
\ No newline at end of file
+        self.cats.set_cat(index, (label, min_cat, max_cat))

Modified: grass/trunk/lib/python/pygrass/raster/buffer.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/buffer.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/raster/buffer.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -39,4 +39,4 @@
             # there is not support for boolean maps, so convert into integer
             out_arr = out_arr.astype(np.int32)
         out_arr.p = out_arr.ctypes.data_as(out_arr.pointer_type)
-        return np.ndarray.__array_wrap__(self, out_arr, context)
\ No newline at end of file
+        return np.ndarray.__array_wrap__(self, out_arr, context)

Modified: grass/trunk/lib/python/pygrass/raster/category.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/category.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/raster/category.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -9,7 +9,7 @@
 
 import grass.lib.raster as libraster
 
-from pygrass.errors import GrassError
+from grass.pygrass.errors import GrassError
 
 from raster_type import TYPE as RTYPE
 
@@ -53,7 +53,7 @@
 
     >>> import grass.lib.raster as libraster
     >>> import ctypes
-    >>> import pygrass
+    >>> import grass.pygrass as pygrass
     >>> land = pygrass.raster.RasterRow('landcover_1m')
     >>> cats = pygrass.raster.Category()
     >>> cats.read(land) # or with cats.read(land.name, land.mapset, land.mtype)
@@ -345,4 +345,4 @@
         libraster.Rast_sort_cats(ctypes.byref(self._cats))
 
     def labels(self):
-        return map(itemgetter(0), self)
\ No newline at end of file
+        return map(itemgetter(0), self)

Modified: grass/trunk/lib/python/pygrass/raster/history.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/history.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/raster/history.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -15,7 +15,7 @@
 
     ::
 
-        >>> import pygrass
+        >>> import grass.pygrass as pygrass
         >>> hist = pygrass.raster.History()
         >>> hist.read('aspect')
         >>> hist.creator
@@ -233,4 +233,4 @@
         """Rast_short_history"""
         libraster.Rast_short_history(ctypes.c_char_p(name),
                                      ctypes.c_char_p(maptype),
-                                     ctypes.byref(self.hist))
\ No newline at end of file
+                                     ctypes.byref(self.hist))

Modified: grass/trunk/lib/python/pygrass/raster/raster_type.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/raster_type.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/raster/raster_type.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -25,4 +25,4 @@
         'DCELL': {'grass type':  libraster.DCELL_TYPE,
                   'grass def':   libraster.DCELL,
                   'numpy':       np.float64,
-                  'ctypes':      ctypes.c_double}}
\ No newline at end of file
+                  'ctypes':      ctypes.c_double}}

Modified: grass/trunk/lib/python/pygrass/raster/rowio.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/rowio.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/raster/rowio.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -9,7 +9,7 @@
 import grass.lib.rowio as librowio
 import grass.lib.raster as librast
 
-from pygrass.errors import GrassError
+from grass.pygrass.errors import GrassError
 from raster_type import TYPE as RTYPE
 
 
@@ -75,4 +75,4 @@
     def get(self, row_index, buf):
         rowio_buf = librowio.Rowio_get(ctypes.byref(self.crowio), row_index)
         ctypes.memmove(buf.p, rowio_buf, self.row_size)
-        return buf
\ No newline at end of file
+        return buf

Modified: grass/trunk/lib/python/pygrass/raster/segment.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/segment.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/raster/segment.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -126,4 +126,4 @@
         Releases the allocated memory associated with the segment file seg.
         Note: Does not close the file. Does not flush the data which may be
         pending from previous segment_put() calls."""
-        libseg.segment_release(ctypes.byref(self.cseg))
\ No newline at end of file
+        libseg.segment_release(ctypes.byref(self.cseg))

Modified: grass/trunk/lib/python/pygrass/vector/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/__init__.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/vector/__init__.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -12,7 +12,7 @@
 #
 # import pygrass modules
 #
-from pygrass.errors import GrassError, must_be_open
+from grass.pygrass.errors import GrassError, must_be_open
 
 import geometry
 from abstract import Info
@@ -52,7 +52,7 @@
 class Vector(Info):
     """ ::
 
-        >>> from pygrass.vector import Vector
+        >>> from grass.pygrass.vector import Vector
         >>> municip = Vector('boundary_municp_sqlite')
         >>> municip.is_open()
         False
@@ -151,7 +151,7 @@
             >>> new.open('w', tab_name='newvect', tab_cols=cols)
 
         import a geometry feature ::
-            >>> from pygrass.vector.geometry import Point
+            >>> from grass.pygrass.vector.geometry import Point
 
         create two points ::
 

Modified: grass/trunk/lib/python/pygrass/vector/abstract.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/abstract.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/vector/abstract.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -9,8 +9,8 @@
 import grass.lib.vector as libvect
 from vector_type import MAPTYPE
 
-from pygrass import functions
-from pygrass.errors import GrassError, OpenError, must_be_open
+from grass.pygrass import functions
+from grass.pygrass.errors import GrassError, OpenError, must_be_open
 from table import DBlinks, Link
 
 #=============================================
@@ -354,4 +354,4 @@
         if libvect.Vect_build(self.c_mapinfo) != 1:
             str_err = 'Error when trying build topology with Vect_build'
             raise GrassError(str_err)
-        libvect.Vect_close(self.c_mapinfo)
\ No newline at end of file
+        libvect.Vect_close(self.c_mapinfo)

Modified: grass/trunk/lib/python/pygrass/vector/basic.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/basic.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/vector/basic.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -456,4 +456,4 @@
     def __contains__(self, cat):
         """Check if category number is in list.
         int 	Vect_cat_in_cat_list (int cat, const struct cat_list *list)"""
-        return bool(libvect.Vect_cat_in_cat_list(cat, self.c_cat_list))
\ No newline at end of file
+        return bool(libvect.Vect_cat_in_cat_list(cat, self.c_cat_list))

Modified: grass/trunk/lib/python/pygrass/vector/geometry.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/geometry.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/vector/geometry.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -13,7 +13,7 @@
 import grass.lib.gis as libgis
 import grass.lib.vector as libvect
 
-from pygrass.errors import GrassError
+from grass.pygrass.errors import GrassError
 
 from basic import Ilist, Bbox, Cats
 import sql
@@ -1354,4 +1354,4 @@
 
         """
         border = self.points()
-        return libvect.Vect_area_perimeter(border.c_points)
\ No newline at end of file
+        return libvect.Vect_area_perimeter(border.c_points)

Modified: grass/trunk/lib/python/pygrass/vector/sql.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/sql.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/vector/sql.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -48,4 +48,4 @@
 
 
 # GET INFO
-PRAGMA = "PRAGMA table_info({tname});"
\ No newline at end of file
+PRAGMA = "PRAGMA table_info({tname});"

Modified: grass/trunk/lib/python/pygrass/vector/table.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/table.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/vector/table.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -12,10 +12,10 @@
 try:
     from collections import OrderedDict
 except:
-    from pygrass.orderdict import OrderedDict
+    from grass.pygrass.orderdict import OrderedDict
 
 import grass.lib.vector as libvect
-from pygrass.gis import Mapset
+from grass.pygrass.gis import Mapset
 
 import sql
 
@@ -665,7 +665,7 @@
 class DBlinks(object):
     """Interface containing link to the table DB. ::
 
-        >>> from pygrass.vector import VectorTopo
+        >>> from grass.pygrass.vector import VectorTopo
         >>> municip = VectorTopo('boundary_municp_sqlite')
         >>> municip.open()
         >>> dblinks = DBlinks(municip.c_mapinfo)
@@ -722,7 +722,7 @@
     def add(self, link):
         """Add a new link. ::
 
-            >>> from pygrass.vector import VectorTopo
+            >>> from grass.pygrass.vector import VectorTopo
             >>> municip = VectorTopo('boundary_municp_sqlite')
             >>> municip.open()
             >>> dblinks = DBlinks(municip.c_mapinfo)
@@ -744,7 +744,7 @@
     def remove(self, key):
         """Remove a link. ::
 
-            >>> from pygrass.vector import VectorTopo
+            >>> from grass.pygrass.vector import VectorTopo
             >>> municip = VectorTopo('boundary_municp_sqlite')
             >>> municip.open()
             >>> dblinks = DBlinks(municip.c_mapinfo)
@@ -871,4 +871,4 @@
         cur = self.conn.cursor()
         vals = list(values)
         vals.append(key)
-        return cur.execute(self.columns.update_str, vals)
\ No newline at end of file
+        return cur.execute(self.columns.update_str, vals)

Modified: grass/trunk/lib/python/pygrass/vector/vector_type.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/vector_type.py	2013-02-03 20:05:54 UTC (rev 54881)
+++ grass/trunk/lib/python/pygrass/vector/vector_type.py	2013-02-03 21:00:39 UTC (rev 54882)
@@ -29,4 +29,4 @@
            libvect.GV_FACE:     {'label': 'face',     'obj': None},
            libvect.GV_KERNEL:   {'label': 'kernel',   'obj': None},
            libvect.GV_AREA:     {'label': 'area',     'obj': geo.Area},
-           libvect.GV_VOLUME:   {'label': 'volume',   'obj': None}, }
\ No newline at end of file
+           libvect.GV_VOLUME:   {'label': 'volume',   'obj': None}, }



More information about the grass-commit mailing list