[GRASS-SVN] r69809 - grass/trunk/lib/python/pygrass/vector

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 13 14:51:53 PST 2016


Author: wenzeslaus
Date: 2016-11-13 14:51:53 -0800 (Sun, 13 Nov 2016)
New Revision: 69809

Modified:
   grass/trunk/lib/python/pygrass/vector/__init__.py
Log:
pygrass: 7.0 API now works even without using kwargs for Vector.write(), see #3010

Modified: grass/trunk/lib/python/pygrass/vector/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/__init__.py	2016-11-13 22:37:58 UTC (rev 69808)
+++ grass/trunk/lib/python/pygrass/vector/__init__.py	2016-11-13 22:51:53 UTC (rev 69809)
@@ -179,7 +179,18 @@
 
         """
         self.n_lines += 1
+        if not isinstance(cat, int) and not isinstance(cat, str):
+            # likely the case of using 7.0 API
+            import warnings
+            warnings.warn("Vector.write(geo_obj, attrs=(...)) is"
+                          " depreciated, specify cat explicitly",
+                          DeprecationWarning)
+            # try to accommodate
+            attrs = cat
+            cat = None
         if attrs and cat is None:
+            # TODO: this does not work as expected when there are
+            # already features in the map when we opened it
             cat = (self._cats[-1] if self._cats else 0) + 1
 
         if cat is not None and cat not in self._cats:



More information about the grass-commit mailing list