mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 22:45:39 +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):
|
def split_csv(argument, required):
|
||||||
argument = argument or ""
|
argument = argument or ""
|
||||||
values = list(filter(len, (s.strip() for s in argument.split(","))))
|
outlist = list(filter(len, (s.strip() for s in argument.split(","))))
|
||||||
if required and not values:
|
if required and not outlist:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"a non-empty list required; provide at least one value or remove"
|
"a non-empty list required; provide at least one value or remove"
|
||||||
" this option"
|
" this option"
|
||||||
)
|
)
|
||||||
# Order-preserving de-duplication
|
if not len(outlist) == len(set(outlist)):
|
||||||
outlist, seen = list(), set() # pylint: disable=use-list-literal
|
raise ValueError("duplicate value detected")
|
||||||
for value in values:
|
|
||||||
if value not in seen:
|
|
||||||
seen.add(value)
|
|
||||||
outlist.append(value)
|
|
||||||
return outlist
|
return outlist
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user