From a5a46832322b38fda69ef3eb9acd4cf999d07ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Tue, 9 Jun 2015 19:36:59 +0200 Subject: [PATCH] avocado.core.plugins.multiplexer: Add option to show system-wide tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "--system-wide|-s" option can be used to display the result of only the files user asked for or the whole package including nodes/values defined by plugins and other branches. Signed-off-by: Lukáš Doktor --- avocado/core/plugins/multiplexer.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/avocado/core/plugins/multiplexer.py b/avocado/core/plugins/multiplexer.py index 2cfa7e61..8e58df77 100644 --- a/avocado/core/plugins/multiplexer.py +++ b/avocado/core/plugins/multiplexer.py @@ -30,6 +30,10 @@ class Multiplexer(plugin.Plugin): name = 'multiplexer' enabled = True + def __init__(self, *args, **kwargs): + super(Multiplexer, self).__init__(*args, **kwargs) + self._from_args_tree = tree.TreeNode() + def configure(self, parser): if multiplexer.MULTIPLEX_CAPABLE is False: self.enabled = False @@ -45,6 +49,9 @@ class Multiplexer(plugin.Plugin): self.parser.add_argument('--filter-out', nargs='*', default=[], help='Filter out path(s) from multiplexing') + self.parser.add_argument('-s', '--system-wide', action='store_true', + help="Combine the files with the default " + "tree.") self.parser.add_argument('-t', '--tree', action='store_true', default=False, help='Shows the multiplex tree structure') @@ -60,6 +67,7 @@ class Multiplexer(plugin.Plugin): help="Inject [path:]key:node values into " "the final multiplex tree.") super(Multiplexer, self).configure(self.parser) + self._from_args_tree = tree.TreeNode() def activate(self, args): # Extend default multiplex tree of --env values @@ -69,9 +77,9 @@ class Multiplexer(plugin.Plugin): raise ValueError("key:value pairs required, found only %s" % (value)) elif len(value) == 2: - args.default_multiplex_tree.value[value[0]] = value[1] + self._from_args_tree.value[value[0]] = value[1] else: - node = args.default_multiplex_tree.get_node(value[0], True) + node = self._from_args_tree.get_node(value[0], True) node.value[value[1]] = value[2] def run(self, args): @@ -84,7 +92,9 @@ class Multiplexer(plugin.Plugin): view.notify(event='error', msg=details.strerror) sys.exit(exit_codes.AVOCADO_JOB_FAIL) - mux_tree.merge(args.default_multiplex_tree) + if args.system_wide: + mux_tree.merge(args.default_multiplex_tree) + mux_tree.merge(self._from_args_tree) if args.tree: view.notify(event='message', msg='Config file tree structure:') view.notify(event='minor', -- GitLab