blob: 3a37792542019cb31c1fbf2d8d0a7f6e2ca49e96 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# coding: utf-8
# Copyright Ruamel bvba 2007-2014
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 + " " +
str(getattr(namespace, self.dest)) + '" overwritten by "' +
str(option_string) +
" " + str(values) +
'"')
setattr(namespace, self.dest, values)
|