# HG changeset patch # User Andre Heinecke # Date 1363969908 -3600 # Node ID 6c2751c17869b7a127a59484ac94116f213e0bc8 # Parent 2da74705c29d35d41d04de724dde070ed56a3a9b 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/ diff -r 2da74705c29d -r 6c2751c17869 flys-backend/contrib/shpimporter/importer.py --- 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