From 134a674228b3d2b42cb7fe2a12f215a225e7544b Mon Sep 17 00:00:00 2001 From: nico Date: Wed, 9 Jan 2019 19:38:04 +0100 Subject: initial rework of the implemented functions + added __init__ import file for all functions + added new helper function + added strings.json file * some logic fixups * validator fixup * arg abbreviation moved to misc --- classes/help.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 classes/help.py (limited to 'classes/help.py') diff --git a/classes/help.py b/classes/help.py new file mode 100644 index 0000000..c268520 --- /dev/null +++ b/classes/help.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from common.misc import arg_abbr +from common.strings import StaticAnswers +import json + + +class Helper: + def __init__(self): + self.possible_vars = StaticAnswers().helpfile["help_advanced"].keys() + + def receive(self, target): + # optional argument abbreviation + target = arg_abbr(target, self.possible_vars) + + if target in self.possible_vars: + return StaticAnswers().help_doc(target) + else: + return StaticAnswers().help_doc() + + def format(self, query, target, opt_arg): + doc = self.receive(target) + + if target in self.possible_vars: + answer = json.dumps(StaticAnswers().help_doc(target), indent=4) + + else: + answer = "\n".join(['%s' % value for (_, value) in doc.items()]) + + return answer -- cgit v1.2.3-54-g00ecf