aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/git/args.py
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-08-08 09:44:20 +0300
committerGuido Günther <agx@sigxcpu.org>2013-03-22 21:06:07 +0100
commit57bbd0abde12e1dafd2ca31a4bcf63c639b5ae6c (patch)
treefe326dcb319b293e905b54d27abae231a6f1121d /gbp/git/args.py
parent3d80b2f671db3e4420bf308b290eddd634d1d437 (diff)
GitArgs: utilize the add() method in other add_X methods
Only use the add() method for updating the argument list. This makes the code more robust and makes all add method variant types support the same argument types. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp/git/args.py')
-rw-r--r--gbp/git/args.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/gbp/git/args.py b/gbp/git/args.py
index f894085d..8f0ffba6 100644
--- a/gbp/git/args.py
+++ b/gbp/git/args.py
@@ -23,6 +23,8 @@ class GitArgs(object):
>>> GitArgs('-h', '--no-foo').args
['-h', '--no-foo']
+ >>> GitArgs('-n', 123).args
+ ['-n', '123']
>>> GitArgs().add('--more-foo', '--less-bar').args
['--more-foo', '--less-bar']
>>> GitArgs().add(['--foo', '--bar']).args
@@ -38,7 +40,8 @@ class GitArgs(object):
"""
def __init__(self, *args):
- self._args = list(args)
+ self._args = []
+ self.add(args)
@property
def args(self):
@@ -68,7 +71,7 @@ class GitArgs(object):
@param args: arguments to add
"""
if condition:
- self._args += list(args)
+ self.add(*args)
return self
def add_false(self, condition, *args):
@@ -94,10 +97,9 @@ class GitArgs(object):
@param noopt: option to add if I{condition} is C{False}
@type noopt: C{str} or C{list}
"""
- if isinstance(opt, basestring):
- opt = [ opt ]
- if isinstance(noopt, basestring):
- noopt = [ noopt ]
- self._args += opt if condition else noopt
+ if condition:
+ self.add(opt)
+ else:
+ self.add(noopt)
return self