1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

add 'hidden' attribute to parsers and wire up to jc.lib.all_parser_info()

This commit is contained in:
Kelly Brazil
2022-09-06 09:21:40 -07:00
parent 79ade2c182
commit a9b0fe6728
4 changed files with 27 additions and 2 deletions

View File

@ -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:
"""

View File

@ -38,6 +38,7 @@ class info():
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
compatible = ['linux']
hidden = True
__version__ = info.version

View File

@ -101,6 +101,7 @@ class info():
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
compatible = ['linux']
hidden = True
__version__ = info.version

View File

@ -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)