mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
Disallow duplicate statement tags in docs
I can't think of a use-case for them, so let's simplify code and treat
them as an invalid input.
(cherry picked from commit 5b832126b3
)
This commit is contained in:
@@ -41,18 +41,14 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
def split_csv(argument, required):
|
||||
argument = argument or ""
|
||||
values = list(filter(len, (s.strip() for s in argument.split(","))))
|
||||
if required and not values:
|
||||
outlist = list(filter(len, (s.strip() for s in argument.split(","))))
|
||||
if required and not outlist:
|
||||
raise ValueError(
|
||||
"a non-empty list required; provide at least one value or remove"
|
||||
" this option"
|
||||
)
|
||||
# Order-preserving de-duplication
|
||||
outlist, seen = list(), set() # pylint: disable=use-list-literal
|
||||
for value in values:
|
||||
if value not in seen:
|
||||
seen.add(value)
|
||||
outlist.append(value)
|
||||
if not len(outlist) == len(set(outlist)):
|
||||
raise ValueError("duplicate value detected")
|
||||
return outlist
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user