1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-23 00:29:59 +02:00

add standard and streaming list functions

This commit is contained in:
Kelly Brazil
2022-03-03 17:36:40 -08:00
parent 4758e28a36
commit 7ede7be7bf
2 changed files with 42 additions and 0 deletions

View File

@ -98,6 +98,23 @@ Get a list of all available parser module names to be used in
Get a list of plugin parser module names to be used in Get a list of plugin parser module names to be used in
`parse()`, `parser_info()`, and `get_help()`. This list is a subset of `parse()`, `parser_info()`, and `get_help()`. This list is a subset of
`parser_mod_list()`. `parser_mod_list()`.
### standard_parser_mod_list
standard_parser_mod_list() -> list
Get a list of standard parser module names to be used in
`parse()`, `parser_info()`, and `get_help()`. This list is a subset of
`parser_mod_list()` and does not contain any streaming parsers.
### streaming_parser_mod_list
streaming_parser_mod_list() -> list
Get a list of streaming parser module names to be used in
`parse()`, `parser_info()`, and `get_help()`. This list is a subset of
`parser_mod_list()`.
""" """
from .lib import (__version__, parse, parser_mod_list, plugin_parser_mod_list, from .lib import (__version__, parse, parser_mod_list, plugin_parser_mod_list,
standard_parser_mod_list, streaming_parser_mod_list,
parser_info, all_parser_info, get_help) parser_info, all_parser_info, get_help)

View File

@ -228,6 +228,31 @@ def plugin_parser_mod_list() -> List[str]:
""" """
return [_cliname_to_modname(p) for p in local_parsers] return [_cliname_to_modname(p) for p in local_parsers]
def standard_parser_mod_list() -> List[str]:
"""
Returns a list of standard parser module names. This function is a
subset of `parser_mod_list()` and does not contain any streaming
parsers.
"""
plist = []
for p in parsers:
parser = _get_parser(p)
if not getattr(parser.info, 'streaming', None):
plist.append(p)
return plist
def streaming_parser_mod_list() -> List[str]:
"""
Returns a list of streaming parser module names. This function is a
subset of `parser_mod_list()`.
"""
plist = []
for p in parsers:
parser = _get_parser(p)
if getattr(parser.info, 'streaming', None):
plist.append(p)
return plist
def parser_info(parser_mod_name: str) -> Dict: def parser_info(parser_mod_name: str) -> Dict:
""" """
Returns a dictionary that includes the module metadata. Returns a dictionary that includes the module metadata.