Browse Source

tools: fix default for SinglePropertyAction

For positional arguments default is sent to __call__ even when not
provided on command line. Exclude it in SinglePropertyAction, since
"default" value is really meant for 'properties' attribute, not
individual property.
Marek Marczykowski-Górecki 7 years ago
parent
commit
4113651f01
1 changed files with 3 additions and 0 deletions
  1. 3 0
      qubesmgmt/tools/__init__.py

+ 3 - 0
qubesmgmt/tools/__init__.py

@@ -107,6 +107,9 @@ class SinglePropertyAction(argparse.Action):
 
 
     def __call__(self, parser, namespace, values, option_string=None):
+        if values is self.default and self.default == {}:
+            return
+
         properties = getattr(namespace, self.dest)
         # copy it, to not modify _mutable_ self.default
         if not properties: