From 08bdaffd89bdb3f0745c242ba8451572ab750437 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Mon, 29 Jan 2018 10:03:28 +0100 Subject: [PATCH] kete: remove custom namespace class Args We are using argparse in the various prompt function that already provide a NameSpace class. We can just reuse it instead of rebuilding everything. Given that we enforce/parse the type of the arguments, there is no need to do more processing. --- tools/tuhi-kete.py | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/tools/tuhi-kete.py b/tools/tuhi-kete.py index a35e86b..58b4744 100755 --- a/tools/tuhi-kete.py +++ b/tools/tuhi-kete.py @@ -312,10 +312,6 @@ class TuhiKeteManager(_DBusObject): pass -class Args(object): - pass - - class Worker(GObject.Object): """Implements a command to be executed. Subclasses need to overwrite run() that will be executed @@ -674,9 +670,7 @@ class TuhiKeteShell(cmd.Cmd): break return - wargs = Args() - wargs.address = address - self.start_worker(Listener, wargs) + self.start_worker(Listener, parsed_args) def help_fetch(self): self.do_fetch('-h') @@ -715,20 +709,7 @@ class TuhiKeteShell(cmd.Cmd): except SystemExit: return - address = parsed_args.address - index = parsed_args.index - - if index != 'all': - try: - int(index) - except ValueError: - print(self._fetch_usage) - return - - wargs = Args() - wargs.address = address - wargs.index = index - self.start_worker(Fetcher, wargs) + self.start_worker(Fetcher, parsed_args) def help_search(self): self.do_search('-h') @@ -755,9 +736,8 @@ class TuhiKeteShell(cmd.Cmd): return Searcher.interactive = False - wargs = Args() - wargs.address = None - self.start_worker(Searcher, wargs) + parsed_args.address = None + self.start_worker(Searcher, parsed_args) def help_pair(self): self.do_pair('-h')