2 Sanitizer that splits lists of names into their components.
5 delimiters: Define the set of characters to be used for
6 splitting the list. (default: `,;`)
10 from nominatim.errors import UsageError
13 """ Create a name processing function that splits name values with
14 multiple values into their components.
16 delimiter_set = set(func.get('delimiters', ',;'))
18 raise UsageError("Set of delimiters in split-name-list sanitizer is empty.")
20 regexp = re.compile('\\s*[{}]\\s*'.format(''.join('\\' + d for d in delimiter_set)))
27 for name in obj.names:
28 split_names = regexp.split(name.name)
29 if len(split_names) == 1:
30 new_names.append(name)
32 new_names.extend(name.clone(name=n) for n in split_names if n)