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:
22
jc/lib.py
22
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:
|
||||
"""
|
||||
|
@ -38,6 +38,7 @@ class info():
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
compatible = ['linux']
|
||||
hidden = True
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
@ -101,6 +101,7 @@ class info():
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
compatible = ['linux']
|
||||
hidden = True
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user