From e27b1eb99f4d6585552eaf71243fd2247dd8cbf5 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 22 Aug 2017 14:16:46 +0200 Subject: [PATCH] tools: ratbagctl: remove useless try/catch ns is never reset, so once it has a subparser, it'll keep it, so the try catch is just too much Signed-off-by: Benjamin Tissoires --- tools/ratbagctl.in | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/ratbagctl.in b/tools/ratbagctl.in index a3dbe0da..1b83baff 100755 --- a/tools/ratbagctl.in +++ b/tools/ratbagctl.in @@ -1299,18 +1299,16 @@ class RatbagParserRoot(object): child.add_to_subparsers(subs) pr_debug(ns, "<<< {}: {} | {}".format(child.type, child.name, rest)) + ns.subparse = None + while subparser: old_rest = rest ns, rest = subparser.parse_known_args(rest, namespace=ns) if not rest or old_rest == rest: break pr_debug(ns, ns, rest) - try: - subparse_call = ns.subparse - except AttributeError: - break - else: - subparser = subparse_call(rest, ns) + if ns.subparse: + subparser = ns.subparse(rest, ns) if rest: self.parser.error("extra arguments: '{}'".format(" ".join(rest)))