X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/4b007ae74039d26cd0b5cfd755beac9081b3528a..3741afa6dc5eced78483b2c2793a8eead0a2396e:/nominatim/tokenizer/sanitizers/split_name_list.py?ds=inline diff --git a/nominatim/tokenizer/sanitizers/split_name_list.py b/nominatim/tokenizer/sanitizers/split_name_list.py index 86385985..b2a2045f 100644 --- a/nominatim/tokenizer/sanitizers/split_name_list.py +++ b/nominatim/tokenizer/sanitizers/split_name_list.py @@ -1,23 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# This file is part of Nominatim. (https://nominatim.org) +# +# Copyright (C) 2022 by the Nominatim developer community. +# For a full list of authors see the git log. """ 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 nominatim.errors import UsageError +from nominatim.tokenizer.sanitizers.helpers import create_split_regex def create(func): """ 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 = re.compile('\\s*[{}]\\s*'.format(''.join('\\' + d for d in delimiter_set))) + regexp = create_split_regex(func) def _process(obj): if not obj.names: