forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_args.py
More file actions
20 lines (17 loc) 路 723 Bytes
/
Copy pathjson_args.py
File metadata and controls
20 lines (17 loc) 路 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
import argparse
from typing import Any, Sequence, Union
class JsonArgs(argparse.Action):
def __call__(self, parser: Any, namespace: argparse.Namespace, values: Union[str, Sequence[Any], None], option_string: str = None) -> None:
setattr(namespace, self.dest, dict())
for value in values:
key, value = value.split(':')
getattr(namespace, self.dest)[key] = value