diff --git a/jc/lib.py b/jc/lib.py index 0b554691..49a343b7 100644 --- a/jc/lib.py +++ b/jc/lib.py @@ -85,6 +85,8 @@ parsers = [ 'plist', 'postconf', 'proc', + 'proc-meminfo', + 'proc-modules', 'ps', 'route', 'rpm-qi', @@ -340,7 +342,9 @@ def parser_info(parser_mod_name: str, documentation: bool = False) -> Dict: return info_dict -def all_parser_info(documentation: bool = False) -> List[Dict]: +def all_parser_info(documentation: bool = False, + show_hidden: bool = False +) -> List[Dict]: """ Returns a list of dictionaries that includes metadata for all parser modules. @@ -348,8 +352,22 @@ def all_parser_info(documentation: bool = False) -> List[Dict]: Parameters: documentation: (boolean) include parser docstrings if True + show_hidden: (boolean) also show parsers marked as hidden + in their info metadata. """ - return [parser_info(p, documentation=documentation) for p in parsers] + temp_list = [parser_info(p, documentation=documentation) for p in parsers] + + p_list = [] + if show_hidden: + p_list = temp_list + + else: + for item in temp_list: + if not item.get('hidden', None): + p_list.append(item) + + return p_list + def get_help(parser_mod_name: str) -> None: """ diff --git a/jc/parsers/proc_meminfo.py b/jc/parsers/proc_meminfo.py index 4f1a12ba..e9030084 100644 --- a/jc/parsers/proc_meminfo.py +++ b/jc/parsers/proc_meminfo.py @@ -38,6 +38,7 @@ class info(): author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' compatible = ['linux'] + hidden = True __version__ = info.version diff --git a/jc/parsers/proc_modules.py b/jc/parsers/proc_modules.py index 366d8250..4cc8593e 100644 --- a/jc/parsers/proc_modules.py +++ b/jc/parsers/proc_modules.py @@ -101,6 +101,7 @@ class info(): author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' compatible = ['linux'] + hidden = True __version__ = info.version diff --git a/tests/test_jc_lib.py b/tests/test_jc_lib.py index a33a5ae9..609f1c3c 100644 --- a/tests/test_jc_lib.py +++ b/tests/test_jc_lib.py @@ -53,6 +53,11 @@ class MyTests(unittest.TestCase): def test_lib_all_parser_info_length(self): self.assertGreaterEqual(len(jc.lib.all_parser_info()), 80) + def test_lib_all_parser_hidden_length(self): + reg_length = len(jc.lib.all_parser_info()) + hidden_length = len(jc.lib.all_parser_info(show_hidden=True)) + self.assertGreater(hidden_length, reg_length) + def test_lib_plugin_parser_mod_list_is_list(self): self.assertIsInstance(jc.lib.plugin_parser_mod_list(), list)