mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-11 23:10:10 +01:00
21 lines
723 B
Python
21 lines
723 B
Python
from argparse import _AppendAction
|
|
|
|
|
|
class CommaSeparatedArgs(_AppendAction): # pylint: disable=protected-access
|
|
def __call__(self, parser, namespace, values, option_string=None):
|
|
from funcy import ldistinct
|
|
|
|
items = getattr(namespace, self.dest) or []
|
|
items.extend(map(str.strip, values.split(",")))
|
|
setattr(namespace, self.dest, ldistinct(items))
|
|
|
|
|
|
class KeyValueArgs(_AppendAction):
|
|
def __call__(self, parser, namespace, values, option_string=None):
|
|
items = getattr(namespace, self.dest) or {}
|
|
for value in filter(bool, values):
|
|
key, _, value = value.partition("=")
|
|
items[key.strip()] = value
|
|
|
|
setattr(namespace, self.dest, items)
|