diff options
Diffstat (limited to 'classes/help.py')
-rw-r--r-- | classes/help.py | 29 |
1 files changed, 29 insertions, 0 deletions
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 |