2 Name processor that splits name values with multiple values into their components.
6 from nominatim.errors import UsageError
9 """ Create a name processing function that splits name values with
10 multiple values into their components. The optional parameter
11 'delimiters' can be used to define the characters that should be used
12 for splitting. The default is ',;'.
14 delimiter_set = set(func.get('delimiters', ',;'))
16 raise UsageError("Set of delimiters in split-name-list sanitizer is empty.")
18 regexp = re.compile('\\s*[{}]\\s*'.format(''.join('\\' + d for d in delimiter_set)))
25 for name in obj.names:
26 split_names = regexp.split(name.name)
28 if len(split_names) == 1:
29 new_names.append(name)
31 new_names.extend(name.clone(name=n) for n in split_names if n)