]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/tokenizer/sanitizers/split_name_list.py
remove tests that differ between lua and gazetteer versions
[nominatim.git] / nominatim / tokenizer / sanitizers / split_name_list.py
index 3250c668a9d44b700c49f6c0903d1a064cad3810..7d0667b4e323ce1aa060c3f0ae2738505173a476 100644 (file)
@@ -9,23 +9,20 @@ Sanitizer that splits lists of names into their components.
 
 Arguments:
     delimiters: Define the set of characters to be used for
-                splitting the list. (default: `,;`)
+                splitting the list. (default: ',;')
 """
-import re
+from typing import Callable
 
-from nominatim.errors import UsageError
+from nominatim.tokenizer.sanitizers.base import ProcessInfo
+from nominatim.tokenizer.sanitizers.config import SanitizerConfig
 
-def create(func):
+def create(config: SanitizerConfig) -> Callable[[ProcessInfo], None]:
     """ Create a name processing function that splits name values with
         multiple values into their components.
     """
-    delimiter_set = set(func.get('delimiters', ',;'))
-    if not delimiter_set:
-        raise UsageError("Set of delimiters in split-name-list sanitizer is empty.")
+    regexp = config.get_delimiter()
 
-    regexp = re.compile('\\s*[{}]\\s*'.format(''.join('\\' + d for d in delimiter_set)))
-
-    def _process(obj):
+    def _process(obj: ProcessInfo) -> None:
         if not obj.names:
             return