Browse Source

Add support for with statement in the Vector classes

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@55948 15284696-431f-4ddb-bdfa-cd5b030d7da7
Pietro Zambelli 12 years ago
parent
commit
3627d49d54
1 changed files with 7 additions and 0 deletions
  1. 7 0
      lib/python/pygrass/vector/abstract.py

+ 7 - 0
lib/python/pygrass/vector/abstract.py

@@ -90,6 +90,13 @@ class Info(object):
         self.date_fmt = '%a %b  %d %H:%M:%S %Y'
         self.layer = layer
 
+    def __enter__(self):
+        self.open('r')
+        return self
+
+    def __exit__(self, exc_type, exc_value, traceback):
+        self.close()
+
     def _get_name(self):
         """Private method to obtain the Vector name"""
         if self.exist() and self.is_open():