[GRASS-SVN] r69552 - grass/trunk/lib/python/pygrass/vector
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Sep 23 02:18:20 PDT 2016
Author: huhabla
Date: 2016-09-23 02:18:20 -0700 (Fri, 23 Sep 2016)
New Revision: 69552
Modified:
grass/trunk/lib/python/pygrass/vector/__init__.py
grass/trunk/lib/python/pygrass/vector/table.py
Log:
pygrass vector: Fixed vector rewrite test and $MAP in sqlite path substitution
Modified: grass/trunk/lib/python/pygrass/vector/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/__init__.py 2016-09-22 12:21:03 UTC (rev 69551)
+++ grass/trunk/lib/python/pygrass/vector/__init__.py 2016-09-23 09:18:20 UTC (rev 69552)
@@ -535,8 +535,8 @@
Generate a new vector map
- >>> test_vect = VectorTopo(test_vector_name)
- >>> test_vect.open('w', tab_name='newvect', tab_cols=cols,
+ >>> test_vect = VectorTopo('newvect_2')
+ >>> test_vect.open('w', tab_name='newvect_2', tab_cols=cols,
... overwrite=True)
import a geometry feature ::
@@ -554,12 +554,14 @@
>>> test_vect.write(point0, cat=1, attrs=('pub',))
>>> test_vect.write(point1, cat=2, attrs=('resturant',))
>>> test_vect.table.conn.commit() # save changes in the DB
+ >>> test_vect.table_to_dict()
+ {1: [1, u'pub'], 2: [2, u'resturant']}
>>> test_vect.close()
- Now rewrite on point of the vector map: ::
+ Now rewrite one point of the vector map: ::
>>> test_vect.open('rw')
- >>> test_vect.rewrite(point2, cat=1, attrs('Irish Pub'))
+ >>> test_vect.rewrite(point2, cat=1, attrs=('Irish Pub',))
>>> test_vect.table.conn.commit() # save changes in the DB
>>> test_vect.close()
@@ -571,6 +573,7 @@
>>> test_vect[1].attrs['name'] == 'Irish Pub'
True
>>> test_vect.close()
+ >>> test_vect.remove()
"""
if self.table is not None and attrs:
self.table.update(key=cat, values=attrs)
Modified: grass/trunk/lib/python/pygrass/vector/table.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/table.py 2016-09-22 12:21:03 UTC (rev 69551)
+++ grass/trunk/lib/python/pygrass/vector/table.py 2016-09-23 09:18:20 UTC (rev 69552)
@@ -48,19 +48,16 @@
:param path: The path with substitutional parameter
:param vect_name: The name of the vector map
- >>> path = '$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
- >>> new_path = get_path(path)
>>> from grass.script.core import gisenv
>>> import os
+ >>> path = '$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db'
+ >>> new_path = get_path(path)
>>> new_path2 = os.path.join(gisenv()['GISDBASE'], gisenv()['LOCATION_NAME'],
... gisenv()['MAPSET'], 'sqlite', 'sqlite.db')
>>> new_path.replace("//","/") == new_path2.replace("//","/")
True
-
>>> path = '$GISDBASE/$LOCATION_NAME/$MAPSET/vector/$MAP/sqlite.db'
>>> new_path = get_path(path, "test")
- >>> from grass.script.core import gisenv
- >>> import os
>>> new_path2 = os.path.join(gisenv()['GISDBASE'], gisenv()['LOCATION_NAME'],
... gisenv()['MAPSET'], 'vector', 'test', 'sqlite.db')
>>> new_path.replace("//","/") == new_path2.replace("//","/")
@@ -74,7 +71,8 @@
path = path.replace('$GISDBASE', mapset.gisdbase)
path = path.replace('$LOCATION_NAME', mapset.location)
path = path.replace('$MAPSET', mapset.name)
- path = path.replace('$MAP', vect_name)
+ if vect_name is not None:
+ path = path.replace('$MAP', vect_name)
return path
More information about the grass-commit
mailing list