Mercurial > dive4elements > river
changeset 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 | 2da74705c29d |
children | 974f0e3dcc28 |
files | flys-backend/contrib/shpimporter/importer.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
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