From 6c14dc98dafd3b45628ca78f1fd6c654b5efb138 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 29 May 2020 12:39:16 -0400 Subject: [PATCH] Integrated chmod.sh --- lib/adapter/cmd.py | 25 +++++++++++++++++++++++++ lib/config.py | 2 ++ 2 files changed, 27 insertions(+) diff --git a/lib/adapter/cmd.py b/lib/adapter/cmd.py index 66699ea..db365e2 100644 --- a/lib/adapter/cmd.py +++ b/lib/adapter/cmd.py @@ -140,3 +140,28 @@ class AdapterOeis(CommandAdapter): def is_found(self, topic): return True + +class AdapterChmod(CommandAdapter): + """ + Show chmod numeric values and strings + Exported as: "/chmod/NUMBER" + """ + + _adapter_name = "chmod" + _output_format = "text" + _cache_needed = True + _command = ["share/adapters/chmod.sh"] + + def _get_command(self, topic, request_options=None): + cmd = self._command[:] + if not cmd[0].startswith("/"): + cmd[0] = _get_abspath(cmd[0]) + + # cut chmod/ off + if topic.startswith("chmod/"): + topic = topic[4:] + + return cmd + [topic] + + def is_found(self, topic): + return True diff --git a/lib/config.py b/lib/config.py index 4b51460..25c9785 100644 --- a/lib/config.py +++ b/lib/config.py @@ -86,6 +86,7 @@ _CONFIG = { "learnxiny", "rfc", "oeis", + "chmod", ], "adapters.mandatory": [ "search", @@ -116,6 +117,7 @@ _CONFIG = { ("^[^/]*/rosetta(/|$)", "rosetta"), ("^rfc/", "rfc"), ("^oeis/", "oeis"), + ("^chmod/", "chmod"), ("^:", "internal"), ("/:list$", "internal"), ("/$", "cheat.sheets dir"),