blob: 27d5cc83b230541855fdeca0773948071a3a7d07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# coding: utf-8
from __future__ import print_function
import argparse
class CheckSingleStoreAction(argparse.Action):
"""issue a warning when the store action is called multiple times"""
def __call__(self, parser, namespace, values, option_string=None):
if getattr(namespace, self.dest, None) is not None:
print(
'WARNING: previous optional argument "' + option_string + " " +
getattr(namespace, self.dest) + '" overwritten by "' +
option_string + " " + values + '"')
setattr(namespace, self.dest, values)
|