diff flys-backend/contrib/shpimporter/importer.py @ 5386:6c2751c17869

Importer: Add function to search a value in all fields. I've also discovered that you can access fields of feature by using it as a dict. \o/
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 22 Mar 2013 17:31:48 +0100
parents 90f1c5f67698
children ff11b178f152
line wrap: on
line diff
--- a/flys-backend/contrib/shpimporter/importer.py	Fri Mar 22 17:30:10 2013 +0100
+++ b/flys-backend/contrib/shpimporter/importer.py	Fri Mar 22 17:31:48 2013 +0100
@@ -45,6 +45,15 @@
             return False # Avoids an Error in IsFieldSet
         return feat.IsFieldSet(feat.GetFieldIndex(name))
 
+    def searchValue(self, feat, regex):
+        """
+        Searches for a value that matches regx in all attribute
+        fields of a feature.
+        """
+        for val in feat.items():
+            match = re.match(regex, val, re.IGNORECASE)
+            return match != None
+
     def searchField(self, regex):
         """
         Searches for a field in the current src layer that matches

http://dive4elements.wald.intevation.org