gn2bp: rename _is_append_arg for clarity
I think _is_list_arg is a slightly better name, so it isn't going to be confused with _append_arg (which will be introduced shortly). Thought about naming some more, and in general we have 3 types of args: - flags (arg without value) - value arg (arg with value) - list arg (multiple args with multiple values) Will work on cleaning up the grammar. Test: none Change-Id: I40491b33780c7ab38e926efea2b28f1135c40e0c
This commit is contained in:
@@ -638,14 +638,14 @@ class BaseActionSanitizer():
|
|||||||
def _has_arg(self, arg):
|
def _has_arg(self, arg):
|
||||||
return arg in self.target.args
|
return arg in self.target.args
|
||||||
|
|
||||||
# Whether an arg has multiple occurences (see argparse action='append')
|
# Whether an arg has multiple occurences (e.g. see argparse action='append')
|
||||||
def _is_append_arg(self, arg):
|
def _is_list_arg(self, arg):
|
||||||
return operator.countOf(arg, self.target.args) > 1
|
return operator.countOf(arg, self.target.args) > 1
|
||||||
|
|
||||||
def _has_arg_value(self, arg):
|
def _has_arg_value(self, arg):
|
||||||
# TODO: we'll probably need a set of helper functions to deal with append
|
# TODO: we'll probably need a set of helper functions to deal with append
|
||||||
# args as well.
|
# args as well.
|
||||||
assert(not self._is_append_arg(arg))
|
assert(not self._is_list_arg(arg))
|
||||||
i = self.target.args.index(arg)
|
i = self.target.args.index(arg)
|
||||||
return not self.target.args[i + 1].startswith('--')
|
return not self.target.args[i + 1].startswith('--')
|
||||||
|
|
||||||
@@ -663,7 +663,7 @@ class BaseActionSanitizer():
|
|||||||
self.target.args[position] = value
|
self.target.args[position] = value
|
||||||
|
|
||||||
def _delete_arg(self, arg):
|
def _delete_arg(self, arg):
|
||||||
assert(not self._is_append_arg(arg))
|
assert(not self._is_list_arg(arg))
|
||||||
hasValue = self._has_arg_value(arg)
|
hasValue = self._has_arg_value(arg)
|
||||||
i = self.target.index(arg)
|
i = self.target.index(arg)
|
||||||
self.target.args.pop(i)
|
self.target.args.pop(i)
|
||||||
|
|||||||
Reference in New Issue
Block a user