[GRASS-SVN] r59907 - in grass/trunk/lib/python/pygrass: . gis modules modules/grid modules/interface raster shell vector
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Apr 23 09:08:36 PDT 2014
Author: lucadelu
Date: 2014-04-23 09:08:36 -0700 (Wed, 23 Apr 2014)
New Revision: 59907
Modified:
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/modules/grid/__init__.py
grass/trunk/lib/python/pygrass/modules/grid/grid.py
grass/trunk/lib/python/pygrass/modules/grid/split.py
grass/trunk/lib/python/pygrass/modules/interface/__init__.py
grass/trunk/lib/python/pygrass/modules/interface/flag.py
grass/trunk/lib/python/pygrass/modules/interface/module.py
grass/trunk/lib/python/pygrass/modules/interface/parameter.py
grass/trunk/lib/python/pygrass/modules/shortcuts.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/rowio.py
grass/trunk/lib/python/pygrass/raster/segment.py
grass/trunk/lib/python/pygrass/shell/__init__.py
grass/trunk/lib/python/pygrass/vector/__init__.py
grass/trunk/lib/python/pygrass/vector/abstract.py
grass/trunk/lib/python/pygrass/vector/find.py
grass/trunk/lib/python/pygrass/vector/geometry.py
grass/trunk/lib/python/pygrass/vector/table.py
grass/trunk/lib/python/pygrass/vector/vector_type.py
Log:
update doctest for pygrass, some should be fixed. please check #2261
Modified: grass/trunk/lib/python/pygrass/functions.py
===================================================================
--- grass/trunk/lib/python/pygrass/functions.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/functions.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -154,7 +154,7 @@
True
>>> is_clean_name('0census')
True
- >>> is_clean_name('census&')
+ >>> is_clean_name('census?')
False
>>> is_clean_name('cénsus')
False
@@ -203,6 +203,7 @@
>>> ele = RasterRow('elevation')
>>> copy('schools','myschools','vect')
>>> sch = VectorTopo('myschools')
+ >>> sch.open()
>>> get_raster_for_points(sch, ele) # doctest: +ELLIPSIS
[(1, 633649.2856743174, 221412.94434781274, 145.06602)...
>>> sch.table.columns.add('elevation','double precision')
@@ -211,7 +212,7 @@
>>> get_raster_for_points(sch, ele, 'elevation')
True
>>> sch.table.filters.select('NAMESHORT','elevation')
- Filters('SELECT NAMESHORT, elevation FROM myschools;')
+ Filters(u'SELECT NAMESHORT, elevation FROM myschools;')
>>> cur = sch.table.execute()
>>> cur.fetchall() # doctest: +ELLIPSIS
[(u'SWIFT CREEK', 145.06602), ... (u'9TH GRADE CTR', None)]
@@ -293,19 +294,19 @@
"""Split a list in chunk.
>>> for chunk in split_in_chunk(range(25)): print chunk
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
- [20, 21, 22, 23, 24]
+ (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+ (10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
+ (20, 21, 22, 23, 24)
>>> for chunk in split_in_chunk(range(25), 3): print chunk
- [0, 1, 2]
- [3, 4, 5]
- [6, 7, 8]
- [9, 10, 11]
- [12, 13, 14]
- [15, 16, 17]
- [18, 19, 20]
- [21, 22, 23]
- [24]
+ (0, 1, 2)
+ (3, 4, 5)
+ (6, 7, 8)
+ (9, 10, 11)
+ (12, 13, 14)
+ (15, 16, 17)
+ (18, 19, 20)
+ (21, 22, 23)
+ (24,)
"""
it = iter(iterable)
while True:
Modified: grass/trunk/lib/python/pygrass/gis/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/gis/__init__.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/gis/__init__.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -4,7 +4,7 @@
from __future__ import (nested_scopes, generators, division, absolute_import,
with_statement, print_function, unicode_literals)
from os import listdir
-from os.path import join, exists, isdir
+from os.path import join, isdir
import shutil
import ctypes as ct
import fnmatch
@@ -25,7 +25,6 @@
import grass.lib.gis as libgis
from grass.pygrass.functions import getenv
from grass.pygrass.errors import GrassError
-from . import region
#write dec to check if user have permissions or not
Modified: grass/trunk/lib/python/pygrass/gis/region.py
===================================================================
--- grass/trunk/lib/python/pygrass/gis/region.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/gis/region.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -19,8 +19,9 @@
"""::
>>> default = Region(default=True)
+ >>> current_good = Region()
>>> current = Region()
- >>> current_good = Region()
+ >>> current.align('elevation')
>>> default == current
True
>>> current.cols
Modified: grass/trunk/lib/python/pygrass/modules/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/__init__.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/modules/__init__.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -5,10 +5,10 @@
@author: pietro
"""
-from . import interface
-from .interface import Module, ParallelModuleQueue
+from grass.pygrass.modules import interface
+from grass.pygrass.modules.interface import Module, ParallelModuleQueue
-from . import grid
-from .grid.grid import GridModule
+from grass.pygrass.modules import grid
+from grass.pygrass.modules.grid.grid import GridModule
-from . import shortcuts
+from grass.pygrass.modules import shortcuts
Modified: grass/trunk/lib/python/pygrass/modules/grid/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/grid/__init__.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/modules/grid/__init__.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -4,8 +4,8 @@
@author: pietro
"""
-from . import split
-from . import patch
-from . import grid
-from .grid import GridModule
+from grass.pygrass.modules.grid import split
+from grass.pygrass.modules.grid import patch
+from grass.pygrass.modules.grid import grid
+from grass.pygrass.modules.grid.grid import GridModule
Modified: grass/trunk/lib/python/pygrass/modules/grid/grid.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/grid/grid.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/modules/grid/grid.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -105,11 +105,11 @@
>>> copy_mapset(mset, path)
Mapset('user1')
>>> sorted(os.listdir(path))
- ['PERMANENT', 'user1']
+ [u'PERMANENT', u'user1']
>>> sorted(os.listdir(os.path.join(path, 'PERMANENT')))
- ['DEFAULT_WIND', 'PROJ_INFO', 'PROJ_UNITS', 'VAR', 'WIND']
+ [u'DEFAULT_WIND', u'PROJ_INFO', u'PROJ_UNITS', u'VAR', u'WIND']
>>> sorted(os.listdir(os.path.join(path, 'user1')))
- ['CURGROUP', 'SEARCH_PATH', 'VAR', 'WIND']
+ [u'CURGROUP', u'SEARCH_PATH', u'VAR', u'WIND']
>>> import shutil
>>> shutil.rmtree(path)
@@ -139,7 +139,7 @@
>>> import os
>>> read_gisrc(os.environ['GISRC']) # doctest: +ELLIPSIS
- ('user1', ...)
+ (u'user1', ...)
"""
with open(gisrc, 'r') as gfile:
gis = dict([(k.strip(), v.strip())
Modified: grass/trunk/lib/python/pygrass/modules/grid/split.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/grid/split.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/modules/grid/split.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -36,10 +36,10 @@
1500
>>> reg.rows
1350
- >>> split_region_tiles(region=reg, width=1000, height=700, overlap=0)
+ >>> split_region_tiles(region=reg, width=1000, height=700, overlap=0) # doctest: +NORMALIZE_WHITESPACE
[[Bbox(1350.0, 650.0, 1000.0, 0.0), Bbox(1350.0, 650.0, 1500.0, 1000.0)],
[Bbox(650.0, 0.0, 1000.0, 0.0), Bbox(650.0, 0.0, 1500.0, 1000.0)]]
- >>> split_region_tiles(region=reg, width=1000, height=700, overlap=10)
+ >>> split_region_tiles(region=reg, width=1000, height=700, overlap=10) # doctest: +NORMALIZE_WHITESPACE
[[Bbox(1350.0, 640.0, 1010.0, 0.0), Bbox(1350.0, 640.0, 1500.0, 990.0)],
[Bbox(660.0, 0.0, 1010.0, 0.0), Bbox(660.0, 0.0, 1500.0, 990.0)]]
"""
@@ -71,10 +71,10 @@
1500
>>> reg.rows
1350
- >>> split_region_tiles(region=reg, width=1000, height=700, overlap=0)
+ >>> split_region_tiles(region=reg, width=1000, height=700, overlap=0) # doctest: +NORMALIZE_WHITESPACE
[[Bbox(1350.0, 650.0, 1000.0, 0.0), Bbox(1350.0, 650.0, 1500.0, 1000.0)],
[Bbox(650.0, 0.0, 1000.0, 0.0), Bbox(650.0, 0.0, 1500.0, 1000.0)]]
- >>> split_region_tiles(region=reg, width=1000, height=700, overlap=10)
+ >>> split_region_tiles(region=reg, width=1000, height=700, overlap=10) # doctest: +NORMALIZE_WHITESPACE
[[Bbox(1350.0, 640.0, 1010.0, 0.0), Bbox(1350.0, 640.0, 1500.0, 990.0)],
[Bbox(660.0, 0.0, 1010.0, 0.0), Bbox(660.0, 0.0, 1500.0, 990.0)]]
"""
Modified: grass/trunk/lib/python/pygrass/modules/interface/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/__init__.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/modules/interface/__init__.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -4,10 +4,10 @@
@author: pietro
"""
-from . import flag
-from . import parameter
-from . import module
-from . import typedict
-from . import read
+from grass.pygrass.modules.interface import flag
+from grass.pygrass.modules.interface import parameter
+from grass.pygrass.modules.interface import module
+from grass.pygrass.modules.interface import typedict
+from grass.pygrass.modules.interface import read
-from .module import Module, ParallelModuleQueue
+from grass.pygrass.modules.interface.module import Module, ParallelModuleQueue
Modified: grass/trunk/lib/python/pygrass/modules/interface/flag.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/flag.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/modules/interface/flag.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -6,7 +6,7 @@
"""
from __future__ import (nested_scopes, generators, division, absolute_import,
with_statement, print_function, unicode_literals)
-from . import read
+from grass.pygrass.modules.interface import read
class Flag(object):
Modified: grass/trunk/lib/python/pygrass/modules/interface/module.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/module.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/modules/interface/module.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -13,38 +13,38 @@
>>> region.flags["u"].value = True
>>> region.flags["3"].value = True
>>> region.get_bash()
-'g.region -p -u -3'
+u'g.region -p -3 -u'
>>> new_region = copy.deepcopy(region)
>>> new_region.inputs["res"].value = "10"
>>> new_region.get_bash()
-'g.region res=10 -p -3'
+u'g.region res=10 -p -3 -u'
>>> neighbors = pymod.Module("r.neighbors")
>>> neighbors.inputs["input"].value = "mapA"
>>> neighbors.outputs["output"].value = "mapB"
>>> neighbors.inputs["size"].value = 5
>>> neighbors.get_bash()
-'r.neighbors input=mapA method=average size=5 quantile=0.5 output=mapB'
+u'r.neighbors input=mapA method=average size=5 quantile=0.5 output=mapB'
>>> new_neighbors1 = copy.deepcopy(neighbors)
>>> new_neighbors1.inputs["input"].value = "mapD"
>>> new_neighbors1.inputs["size"].value = 3
>>> new_neighbors1.get_bash()
-'r.neighbors input=mapD method=average size=3 quantile=0.5 output=mapB'
+u'r.neighbors input=mapD method=average size=3 quantile=0.5 output=mapB'
>>> new_neighbors2 = copy.deepcopy(neighbors)
>>> new_neighbors2(input="mapD", size=3, run_=False)
>>> new_neighbors2.get_bash()
-'r.neighbors input=mapD method=average size=3 quantile=0.5 output=mapB'
+u'r.neighbors input=mapD method=average size=3 quantile=0.5 output=mapB'
>>> neighbors = pymod.Module("r.neighbors")
>>> neighbors.get_bash()
-'r.neighbors method=average size=3 quantile=0.5'
+u'r.neighbors method=average size=3 quantile=0.5'
>>> new_neighbors3 = copy.deepcopy(neighbors)
>>> new_neighbors3(input="mapA", size=3, output="mapB", run_=False)
>>> new_neighbors3.get_bash()
-'r.neighbors input=mapA method=average size=3 quantile=0.5 output=mapB'
+u'r.neighbors input=mapA method=average size=3 quantile=0.5 output=mapB'
@endcode
"""
@@ -61,10 +61,10 @@
from grass.script.core import Popen, PIPE
from grass.pygrass.errors import GrassError, ParameterError
-from .parameter import Parameter
-from .flag import Flag
-from .typedict import TypeDict
-from .read import GETFROMTAG, DOC
+from grass.pygrass.modules.interface.parameter import Parameter
+from grass.pygrass.modules.interface.flag import Flag
+from grass.pygrass.modules.interface.typedict import TypeDict
+from grass.pygrass.modules.interface.read import GETFROMTAG, DOC
class ParallelModuleQueue(object):
@@ -242,7 +242,12 @@
and keyword arguments to the grass module.
"""
def __init__(self, cmd, *args, **kargs):
- self.name = cmd
+ if isinstance(cmd, unicode):
+ self.name = str(cmd)
+ elif isinstance(cmd, str):
+ self.name = cmd
+ else:
+ raise GrassError("Problem initializing the module {s}".format(s=cmd))
try:
# call the command with --interface-description
get_cmd_xml = Popen([cmd, "--interface-description"], stdout=PIPE)
Modified: grass/trunk/lib/python/pygrass/modules/interface/parameter.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/parameter.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/modules/interface/parameter.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -9,7 +9,7 @@
import re
-from .read import GETTYPE, element2dict, DOC
+from grass.pygrass.modules.interface.read import GETTYPE, element2dict, DOC
class Parameter(object):
@@ -116,7 +116,14 @@
raise ValueError(values_error % (self.name, self.values))
else:
self._value = value
- # was: elif self.type is str and isinstance(value, unicode):
+ elif self.type is str and isinstance(value, unicode):
+ if hasattr(self, 'values'):
+ if value in self.values:
+ self._value = str(value)
+ else:
+ raise ValueError(values_error % (self.name, self.values))
+ else:
+ self._value = str(value)
elif self.type is str and isinstance(value, str):
if hasattr(self, 'values'):
if value in self.values:
Modified: grass/trunk/lib/python/pygrass/modules/shortcuts.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/shortcuts.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/modules/shortcuts.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -10,7 +10,7 @@
from grass.script.core import get_commands
-from .interface import Module
+from grass.pygrass.modules.interface import Module
_CMDS = list(get_commands()[0])
_CMDS.sort()
@@ -24,7 +24,7 @@
>>> g_mlist.name
'g.mlist'
>>> g_mlist.required
- [Parameter <type> (required:yes, type:string, multiple:yes)]
+ ['type']
>>> g_mlist.inputs.type = 'rast'
>>> g_mlist.stdout_ = -1
>>> g_mlist.run()
Modified: grass/trunk/lib/python/pygrass/raster/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/__init__.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/raster/__init__.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -30,11 +30,11 @@
#
# import raster classes
#
-from .abstract import RasterAbstractBase, Info
-from .raster_type import TYPE as RTYPE, RTYPE_STR
-from .buffer import Buffer
-from .segment import Segment
-from .rowio import RowIO
+from grass.pygrass.raster.abstract import RasterAbstractBase
+from grass.pygrass.raster.raster_type import TYPE as RTYPE, RTYPE_STR
+from grass.pygrass.raster.buffer import Buffer
+from grass.pygrass.raster.segment import Segment
+from grass.pygrass.raster.rowio import RowIO
class RasterRow(RasterAbstractBase):
@@ -62,53 +62,42 @@
True
>>> elev.is_open()
False
- >>> elev.cols
+ >>> elev.info.cols
>>> elev.open()
>>> elev.is_open()
True
- >>> type(elev.cols)
+ >>> type(elev.info.cols)
<type 'int'>
>>> elev.has_cats()
False
>>> elev.mode
- 'r'
+ u'r'
>>> elev.mtype
'FCELL'
>>> elev.num_cats()
0
- >>> elev.range
- (55.578792572021484, 156.32986450195312)
+ >>> elev.info.range
+ (56, 156)
Each Raster map have an attribute call ``cats`` that allow user
to interact with the raster categories. ::
- >>> land = RasterRow('landcover_1m')
+ >>> land = RasterRow('geology')
>>> land.open()
- >>> land.cats
- []
- >>> land.read_cats()
- >>> land.cats
- [('pond', 1, None),
- ('forest', 2, None),
- ('developed', 3, None),
- ('bare', 4, None),
- ('paved road', 5, None),
- ('dirt road', 6, None),
- ('vineyard', 7, None),
- ('agriculture', 8, None),
- ('wetland', 9, None),
- ('bare ground path', 10, None),
- ('grass', 11, None)]
+ >>> land.cats # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
+ [('Zml', 1.0, None),
+ ...
+ ('Tpyw', 1832.0, None)]
Open a raster map using the *with statement*: ::
- >>> with RasterRow('elevation') as elev:
+ >>> with RasterRow('elevation') as elev:
... for row in elev[:3]:
- ... print row[:4]
+ ... row[:4]
...
- [ 141.99613953 141.27848816 141.37904358 142.29821777]
- [ 142.90461731 142.39450073 142.68611145 143.59086609]
- [ 143.81854248 143.54707336 143.83972168 144.59527588]
+ Buffer([ 141.99613953, 141.27848816, 141.37904358, 142.29821777], dtype=float32)
+ Buffer([ 142.90461731, 142.39450073, 142.68611145, 143.59086609], dtype=float32)
+ Buffer([ 143.81854248, 143.54707336, 143.83972168, 144.59527588], dtype=float32)
>>> elev.is_open()
False
@@ -484,20 +473,18 @@
>>> elev.open()
>>> elev[:5, :3]
RasterNumpy([[ 141.99613953, 141.27848816, 141.37904358],
- [ 142.90461731, 142.39450073, 142.68611145],
- [ 143.81854248, 143.54707336, 143.83972168],
- [ 144.56524658, 144.58493042, 144.86477661],
- [ 144.99488831, 145.22894287, 145.57142639]], dtype=float32)
+ [ 142.90461731, 142.39450073, 142.68611145],
+ [ 143.81854248, 143.54707336, 143.83972168],
+ [ 144.56524658, 144.58493042, 144.86477661],
+ [ 144.99488831, 145.22894287, 145.57142639]], dtype=float32)
>>> el = elev < 144
>>> el[:5, :3]
- RasterNumpy([[ True, True, True],
- [ True, True, True],
- [ True, True, True],
- [False, False, False],
- [False, False, False]], dtype=bool)
+ RasterNumpy([[1, 1, 1],
+ [1, 1, 1],
+ [1, 1, 1],
+ [0, 0, 0],
+ [0, 0, 0]], dtype=int32)
>>> el._write()
- 0
-
"""
def __new__(cls, name, mapset="", mtype='CELL', mode='r+',
overwrite=False):
@@ -581,7 +568,7 @@
if kind in FLAGS[size]:
return size, FLAGS[size][kind]
else:
- raise ValueError(_('Invalid type {0}'.forma(kind)))
+ raise ValueError(_('Invalid type {0}'.format(kind)))
else:
raise ValueError(_('Invalid size {0}'.format(size)))
@@ -596,7 +583,6 @@
for i in range(len(rst)):
self[i] = rst.get_row(i, buff)
-
def _write(self):
"""
r.in.bin input=/home/pietro/docdat/phd/thesis/gis/north_carolina/user1/.tmp/eraclito/14325.0 output=new title='' bytes=1,anull='' --verbose --overwrite north=228500.0 south=215000.0 east=645000.0 west=630000.0 rows=1350 cols=1500
Modified: grass/trunk/lib/python/pygrass/raster/abstract.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/abstract.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/raster/abstract.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -27,9 +27,9 @@
#
# import raster classes
#
-from .raster_type import TYPE as RTYPE
-from .category import Category
-from .history import History
+from grass.pygrass.raster.raster_type import TYPE as RTYPE
+from grass.pygrass.raster.category import Category
+from grass.pygrass.raster.history import History
## Define global variables to not exceed the 80 columns
@@ -182,7 +182,7 @@
>>> ele = RasterAbstractBase('elevation')
>>> ele.name
- 'elevation'
+ u'elevation'
>>> ele.exist()
True
>>> ele.mapset
@@ -368,7 +368,7 @@
>>> ele = RasterAbstractBase('elevation')
>>> ele.name_mapset()
- 'elevation at PERMANENT'
+ u'elevation at PERMANENT'
"""
if name is None:
Modified: grass/trunk/lib/python/pygrass/raster/buffer.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/buffer.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/raster/buffer.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -4,7 +4,7 @@
@author: pietro
"""
-from .raster_type import TYPE as RTYPE
+from grass.pygrass.raster.raster_type import TYPE as RTYPE
import ctypes
import numpy as np
Modified: grass/trunk/lib/python/pygrass/raster/category.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/category.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/raster/category.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -11,7 +11,7 @@
from grass.pygrass.errors import GrassError
-from .raster_type import TYPE as RTYPE
+from grass.pygrass.raster.raster_type import TYPE as RTYPE
class Category(list):
@@ -54,7 +54,7 @@
>>> import grass.lib.raster as libraster
>>> import ctypes
>>> import grass.pygrass as pygrass
- >>> land = pygrass.raster.RasterRow('landcover_1m')
+ >>> land = pygrass.raster.RasterRow('geology')
>>> cats = pygrass.raster.Category()
>>> cats.read(land) # or with cats.read(land.name, land.mapset, land.mtype)
>>> cats.labels()
Modified: grass/trunk/lib/python/pygrass/raster/rowio.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/rowio.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/raster/rowio.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -10,7 +10,7 @@
import grass.lib.raster as librast
from grass.pygrass.errors import GrassError
-from .raster_type import TYPE as RTYPE
+from grass.pygrass.raster.raster_type import TYPE as RTYPE
CMPFUNC = ctypes.CFUNCTYPE(ctypes.c_int,
Modified: grass/trunk/lib/python/pygrass/raster/segment.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/segment.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/raster/segment.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -8,7 +8,7 @@
import grass.lib.gis as libgis
import grass.lib.raster as libraster
import grass.lib.segment as libseg
-from .raster_type import TYPE as RTYPE
+from grass.pygrass.raster.raster_type import TYPE as RTYPE
class Segment(object):
Modified: grass/trunk/lib/python/pygrass/shell/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/shell/__init__.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/shell/__init__.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -5,6 +5,6 @@
@author: pietro
"""
-from . import conversion
-from . import show
+from grass.pygrass.shell import conversion
+from grass.pygrass.shell import show
Modified: grass/trunk/lib/python/pygrass/vector/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/__init__.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/vector/__init__.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -5,7 +5,7 @@
@author: pietro
"""
import grass.lib.vector as libvect
-from .vector_type import VTYPE
+from grass.pygrass.vector.vector_type import VTYPE
from os.path import join, exists
#
@@ -14,11 +14,11 @@
from grass.pygrass.errors import GrassError, must_be_open
from grass.pygrass.gis import Location
-from .geometry import GEOOBJ as _GEOOBJ
-from .geometry import read_line, read_next_line
-from .geometry import Area as _Area
-from .abstract import Info
-from .basic import Bbox, Cats, Ilist
+from grass.pygrass.vector.geometry import GEOOBJ as _GEOOBJ
+from grass.pygrass.vector.geometry import read_line, read_next_line
+from grass.pygrass.vector.geometry import Area as _Area
+from grass.pygrass.vector.abstract import Info
+from grass.pygrass.vector.basic import Bbox, Cats, Ilist
_NUMOF = {"areas": libvect.Vect_get_num_areas,
Modified: grass/trunk/lib/python/pygrass/vector/abstract.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/abstract.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/vector/abstract.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -7,12 +7,12 @@
import ctypes
import datetime
import grass.lib.vector as libvect
-from .vector_type import MAPTYPE
+from grass.pygrass.vector.vector_type import MAPTYPE
from grass.pygrass import functions
from grass.pygrass.errors import GrassError, OpenError, must_be_open
-from .table import DBlinks, Link
-from .find import PointFinder, BboxFinder, PolygonFinder
+from grass.pygrass.vector.table import DBlinks, Link
+from grass.pygrass.vector.find import PointFinder, BboxFinder, PolygonFinder
def is_open(c_mapinfo):
Modified: grass/trunk/lib/python/pygrass/vector/find.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/find.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/vector/find.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -8,8 +8,8 @@
from grass.pygrass.errors import must_be_open
-from .basic import Ilist, BoxList
-from .geometry import read_line, Isle, Area, Point
+from grass.pygrass.vector.basic import Ilist, BoxList
+from grass.pygrass.vector.geometry import read_line, Isle, Area, Point
class AbstractFinder(object):
Modified: grass/trunk/lib/python/pygrass/vector/geometry.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/geometry.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/vector/geometry.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -15,8 +15,8 @@
from grass.pygrass.errors import GrassError
-from .basic import Ilist, Bbox, Cats
-from . import sql
+from grass.pygrass.vector.basic import Ilist, Bbox, Cats
+from grass.pygrass.vector import sql
WKT = {'POINT\((.*)\)': 'point', # 'POINT\(\s*([+-]*\d+\.*\d*)+\s*\)'
@@ -211,7 +211,7 @@
>>> schools.open('r')
>>> school = schools[1]
>>> attrs = Attrs(school.cat, schools.table)
- >>> attrs.values() # doctest: +ELLIPSIS
+ >>> attrs.values() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
(1,
...
None)
@@ -230,10 +230,10 @@
>>> schools.open('r')
>>> school = schools[1]
>>> attrs = Attrs(school.cat, schools.table)
- >>> attrs.keys() # doctest: +ELLIPSIS
- (u'cat',
+ >>> attrs.keys() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
+ [u'cat',
...
- u'NOTES')
+ u'NOTES']
"""
return self.table.columns.names()
@@ -320,7 +320,7 @@
>>> pnt
Point(0.000000, 0.000000, 0.000000)
>>> print(pnt)
- POINT(0.000000, 0.000000, 0.000000)
+ POINT(0.000000 0.000000 0.000000)
..
"""
Modified: grass/trunk/lib/python/pygrass/vector/table.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/table.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/vector/table.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -31,9 +31,8 @@
from grass.script.db import db_table_in_vector
from grass.script.core import warning
-from . import sql
+from grass.pygrass.vector import sql
-
DRIVERS = ('sqlite', 'pg')
@@ -65,13 +64,13 @@
>>> filter = Filters('table')
>>> filter.get_sql()
- 'SELECT * FROM table;'
+ u'SELECT * FROM table;'
>>> filter.where("area<10000").get_sql()
- 'SELECT * FROM table WHERE area<10000;'
+ u'SELECT * FROM table WHERE area<10000;'
>>> filter.select("cat", "area").get_sql()
- 'SELECT cat, area FROM table WHERE area<10000;'
+ u'SELECT cat, area FROM table WHERE area<10000;'
>>> filter.order_by("area").limit(10).get_sql()
- 'SELECT cat, area FROM table WHERE area<10000 ORDER BY area LIMIT 10;'
+ u'SELECT cat, area FROM table WHERE area<10000 ORDER BY area LIMIT 10;'
..
"""
@@ -100,7 +99,7 @@
def order_by(self, orderby):
"""Create the order by condition"""
- if not isinstance(orderby, str):
+ if not isinstance(orderby, unicode):
orderby = ', '.join(orderby)
self._orderby = 'ORDER BY {orderby}'.format(orderby=orderby)
return self
@@ -115,7 +114,7 @@
def group_by(self, groupby):
"""Create the group by condition"""
- if not isinstance(groupby, str):
+ if not isinstance(groupby, unicode):
groupby = ', '.join(groupby)
self._groupby = 'GROUP BY {groupby}'.format(groupby=groupby)
return self
@@ -159,7 +158,7 @@
>>> cols_sqlite = Columns('census',
... sqlite3.connect(get_path(path)))
>>> cols_sqlite.tname
- 'census'
+ u'census'
For a postgreSQL table: ::
@@ -265,7 +264,7 @@
>>> cols_sqlite = Columns('census',
... sqlite3.connect(get_path(path)))
>>> cols_sqlite.sql_descr() # doctest: +ELLIPSIS
- u'cat INTEGER, OBJECTID INTEGER, AREA DOUBLE PRECISION, ...'
+ u'cat integer, OBJECTID integer, AREA double precision, ...'
>>> import psycopg2 as pg # doctest: +SKIP
>>> cols_pg = Columns('boundary_municp_pg',
... pg.connect('host=localhost dbname=grassdb')) # doctest: +SKIP
@@ -287,7 +286,7 @@
>>> cols_sqlite = Columns('census',
... sqlite3.connect(get_path(path)))
>>> cols_sqlite.types() # doctest: +ELLIPSIS
- [u'INTEGER', u'INTEGER', ...]
+ [u'integer', u'integer', ...]
>>> import psycopg2 as pg # doctest: +SKIP
>>> cols_pg = Columns('boundary_municp_pg',
... pg.connect('host=localhost dbname=grassdb')) # doctest: +SKIP
@@ -336,7 +335,7 @@
>>> cols_sqlite = Columns('census',
... sqlite3.connect(get_path(path)))
>>> cols_sqlite.items() # doctest: +ELLIPSIS
- [(u'cat', u'INTEGER'), ...]
+ [(u'cat', u'integer'), ...]
>>> import psycopg2 as pg # doctest: +SKIP
>>> cols_pg = Columns('boundary_municp_pg',
... pg.connect('host=localhost dbname=grassdb')) # doctest: +SKIP
@@ -356,7 +355,7 @@
>>> copy('census','mycensus','vect')
>>> cols_sqlite = Columns('mycensus',
... sqlite3.connect(get_path(path)))
- >>> cols_sqlite.add('n_pizza', 'INT')
+ >>> cols_sqlite.add(['n_pizza'], ['INT'])
>>> 'n_pizza' in cols_sqlite
True
>>> import psycopg2 as pg # doctest: +SKIP
@@ -376,7 +375,7 @@
str_err = "Type is not supported, supported types are: %s"
raise TypeError(str_err % ", ".join(valid_type))
- if isinstance(col_name, str):
+ if isinstance(col_name, unicode):
check_col(col_type)
else:
if len(col_name) == len(col_type):
@@ -406,7 +405,7 @@
>>> copy('census','mycensus','vect')
>>> cols_sqlite = Columns('mycensus',
... sqlite3.connect(get_path(path)))
- >>> cols_sqlite.add('n_pizza', 'INT')
+ >>> cols_sqlite.add(['n_pizza'], ['INT'])
>>> 'n_pizza' in cols_sqlite
True
>>> cols_sqlite.rename('n_pizza', 'n_pizzas') # doctest: +ELLIPSIS
@@ -456,11 +455,11 @@
>>> copy('census','mycensus','vect')
>>> cols_sqlite = Columns('mycensus',
... sqlite3.connect(get_path(path)))
- >>> cols_sqlite.add('n_pizzas', 'INT')
+ >>> cols_sqlite.add(['n_pizzas'], ['INT'])
>>> cols_sqlite.cast('n_pizzas', 'float8') # doctest: +ELLIPSIS
Traceback (most recent call last):
...
- DBError: 'SQLite does not support to cast columns.'
+ DBError: u'SQLite does not support to cast columns.'
>>> import psycopg2 as pg # doctest: +SKIP
>>> cols_pg = Columns('boundary_municp_pg',
... pg.connect('host=localhost dbname=grassdb')) # doctest: +SKIP
@@ -705,7 +704,7 @@
... 'sqlite')
>>> table = link.table()
>>> table.filters.select('cat', 'TOTAL_POP', 'PERIMETER')
- Filters('SELECT cat, TOTAL_POP, PERIMETER FROM census;')
+ Filters(u'SELECT cat, TOTAL_POP, PERIMETER FROM census;')
>>> cur = table.execute()
>>> cur.fetchone()
(1, 44, 757.669)
@@ -842,7 +841,7 @@
link = self.by_name(key)
table = link.table()
table.drop(force=force)
- if isinstance(key, str):
+ if isinstance(key, unicode):
key = self.from_name_to_num(key)
libvect.Vect_map_del_dblink(self.c_mapinfo, key)
@@ -861,7 +860,7 @@
>>> tab_sqlite = Table(name='census',
... connection=sqlite3.connect(get_path(path)))
>>> tab_sqlite.name
- 'census'
+ u'census'
>>> import psycopg2 # doctest: +SKIP
>>> tab_pg = Table('boundary_municp_pg',
... psycopg2.connect('host=localhost dbname=grassdb',
@@ -903,7 +902,7 @@
>>> tab_sqlite = Table(name='census',
... connection=sqlite3.connect(get_path(path)))
>>> tab_sqlite
- Table('census')
+ Table(u'census')
..
"""
@@ -958,7 +957,7 @@
>>> tab_sqlite = Table(name='census',
... connection=sqlite3.connect(get_path(path)))
>>> tab_sqlite.filters.select('cat', 'TOTAL_POP').order_by('AREA')
- Filters('SELECT cat, TOTAL_POP FROM census ORDER BY AREA;')
+ Filters(u'SELECT cat, TOTAL_POP FROM census ORDER BY AREA;')
>>> cur = tab_sqlite.execute()
>>> cur.fetchone()
(1856, 0)
Modified: grass/trunk/lib/python/pygrass/vector/vector_type.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/vector_type.py 2014-04-23 14:53:28 UTC (rev 59906)
+++ grass/trunk/lib/python/pygrass/vector/vector_type.py 2014-04-23 16:08:36 UTC (rev 59907)
@@ -6,7 +6,7 @@
"""
import grass.lib.vector as libvect
-from . import geometry as geo
+from grass.pygrass.vector import geometry as geo
MAPTYPE = {libvect.GV_FORMAT_NATIVE: "native",
libvect.GV_FORMAT_OGR: "OGR",
More information about the grass-commit
mailing list