mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04: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:
parent
3ecef74b9a
commit
a5d06fceb7
1 changed files with 4 additions and 8 deletions
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue