Kaynağa Gözat

pygrass: 7.0 API now works even without using kwargs for Vector.write(), see https://trac.osgeo.org/grass/ticket/3010

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69809 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 8 yıl önce
ebeveyn
işleme
5eede7ad65
1 değiştirilmiş dosya ile 11 ekleme ve 0 silme
  1. 11 0
      lib/python/pygrass/vector/__init__.py

+ 11 - 0
lib/python/pygrass/vector/__init__.py

@@ -179,7 +179,18 @@ class Vector(Info):
 
         """
         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: