[GRASS-SVN] r68353 - in grass/trunk/lib/python/pygrass: rpc vector vector/testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 2 09:07:29 PDT 2016


Author: zarch
Date: 2016-05-02 09:07:29 -0700 (Mon, 02 May 2016)
New Revision: 68353

Modified:
   grass/trunk/lib/python/pygrass/rpc/__init__.py
   grass/trunk/lib/python/pygrass/vector/__init__.py
   grass/trunk/lib/python/pygrass/vector/table.py
   grass/trunk/lib/python/pygrass/vector/testsuite/test_table.py
Log:
pygrass: fix python2 and python3 syntax

Modified: grass/trunk/lib/python/pygrass/rpc/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/rpc/__init__.py	2016-05-02 16:07:20 UTC (rev 68352)
+++ grass/trunk/lib/python/pygrass/rpc/__init__.py	2016-05-02 16:07:29 UTC (rev 68353)
@@ -21,7 +21,7 @@
 from grass.pygrass.vector import *
 from grass.pygrass.raster import *
 import grass.lib.gis as libgis
-from base import RPCServerBase
+from .base import RPCServerBase
 from grass.pygrass.gis.region import Region
 import grass.pygrass.utils as utils
 import logging

Modified: grass/trunk/lib/python/pygrass/vector/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/__init__.py	2016-05-02 16:07:20 UTC (rev 68352)
+++ grass/trunk/lib/python/pygrass/vector/__init__.py	2016-05-02 16:07:29 UTC (rev 68353)
@@ -1,4 +1,6 @@
 # -*- coding: utf-8 -*-
+from __future__ import print_function
+
 from os.path import join, exists
 import grass.lib.gis as libgis
 libgis.G_gisinit('')
@@ -188,7 +190,7 @@
                 cur = self.table.conn.cursor()
                 cur.execute(self.table.columns.insert_str, attr)
                 cur.close()
-        
+
         if cat is not None:
             cats = Cats(geo_obj.c_cats)
             cats.reset()
@@ -246,7 +248,7 @@
 
         >>> with VectorTopo(test_vector_name, mode='r') as test_vect:
         ...     for feature in test_vect[:7]:
-        ...         print feature.attrs['name']
+        ...         print(feature.attrs['name'])
         ...
         point
         point
@@ -396,7 +398,7 @@
             >>> from operator import methodcaller as method
             >>> areas.sort(key=method('area'), reverse=True)  # sort the list
             >>> for area in areas[:3]:
-            ...     print area, area.area()
+            ...     print(area, area.area())
             Area(1) 12.0
             Area(2) 8.0
             Area(4) 8.0
@@ -533,8 +535,8 @@
             attr.extend(attrs)
             self.table.update(key=line, values=attr)
         elif self.table is None and attrs:
-            print "Table for vector {name} does not exist, attributes not" \
-                  " loaded".format(name=self.name)
+            print("Table for vector {name} does not exist, attributes not"
+                  " loaded".format(name=self.name))
         libvect.Vect_cat_set(geo_obj.c_cats, self.layer, line)
         result = libvect.Vect_rewrite_line(self.c_mapinfo,
                                            line, geo_obj.gtype,

Modified: grass/trunk/lib/python/pygrass/vector/table.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/table.py	2016-05-02 16:07:20 UTC (rev 68352)
+++ grass/trunk/lib/python/pygrass/vector/table.py	2016-05-02 16:07:29 UTC (rev 68353)
@@ -194,7 +194,7 @@
         return item in self.names()
 
     def __repr__(self):
-        return "Columns(%r)" % self.items()
+        return "Columns(%r)" % list(self.items())
 
     def __getitem__(self, key):
         return self.odict[key]

Modified: grass/trunk/lib/python/pygrass/vector/testsuite/test_table.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/testsuite/test_table.py	2016-05-02 16:07:20 UTC (rev 68352)
+++ grass/trunk/lib/python/pygrass/vector/testsuite/test_table.py	2016-05-02 16:07:29 UTC (rev 68353)
@@ -4,6 +4,12 @@
 
 @author: pietro
 """
+try:
+    from builtins import long
+except ImportError:
+    # python3
+    long = int
+
 import os
 import sqlite3
 import tempfile as tmp



More information about the grass-commit mailing list