mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
doc update
This commit is contained in:
15
docs/lib.md
15
docs/lib.md
@ -31,13 +31,24 @@ parser module.
|
||||
|
||||
Parameters:
|
||||
|
||||
parser_mod_name: (string or name of the parser module. This
|
||||
parser_mod_name: (string or Name of the parser module. This
|
||||
Module) function will accept module_name,
|
||||
cli-name, and --argument-name
|
||||
variants of the module name.
|
||||
|
||||
If a Module is given and the Module
|
||||
is a valid parser Module, then the
|
||||
same Module is returned.
|
||||
|
||||
Returns:
|
||||
|
||||
Parser: the parser module object
|
||||
Module: the parser Module object
|
||||
|
||||
Raises:
|
||||
|
||||
ModuleNotFoundError: If the Module is not found or is not a valid
|
||||
parser Module, then a ModuleNotFoundError
|
||||
exception is raised.
|
||||
|
||||
<a id="jc.lib.parse"></a>
|
||||
|
||||
|
@ -52,6 +52,18 @@ menu.
|
||||
Alternatively, you can bypass the high-level API and call the parser
|
||||
modules directly:
|
||||
|
||||
>>> import subprocess
|
||||
>>> import jc
|
||||
>>>
|
||||
>>> jc_dig = jc.get_parser('dig')
|
||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
|
||||
text=True)
|
||||
>>> data = jc_dig.parse(cmd_output)
|
||||
>>> data
|
||||
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]
|
||||
|
||||
or
|
||||
|
||||
>>> import subprocess
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
@ -75,6 +87,14 @@ Use `help(jc.lib)` for details.
|
||||
High-level API to easily access the parser. This API will find both
|
||||
built-in parsers and local plugin parsers.
|
||||
|
||||
### get_parser
|
||||
|
||||
get_parser(
|
||||
parser_module_name: str
|
||||
) -> ModuleType
|
||||
|
||||
Get a parser Module object so you can use it directly.
|
||||
|
||||
### parser_info
|
||||
|
||||
parser_info(
|
||||
|
@ -48,6 +48,18 @@ menu.
|
||||
Alternatively, you can bypass the high-level API and call the parser
|
||||
modules directly:
|
||||
|
||||
>>> import subprocess
|
||||
>>> import jc
|
||||
>>>
|
||||
>>> jc_dig = jc.get_parser('dig')
|
||||
>>> cmd_output = subprocess.check_output(['dig', 'example.com'],
|
||||
text=True)
|
||||
>>> data = jc_dig.parse(cmd_output)
|
||||
>>> data
|
||||
[{'id': 64612, 'opcode': 'QUERY', 'status': 'NOERROR', ...}]
|
||||
|
||||
or
|
||||
|
||||
>>> import subprocess
|
||||
>>> import jc.parsers.dig
|
||||
>>>
|
||||
@ -71,6 +83,14 @@ Use `help(jc.lib)` for details.
|
||||
High-level API to easily access the parser. This API will find both
|
||||
built-in parsers and local plugin parsers.
|
||||
|
||||
### get_parser
|
||||
|
||||
get_parser(
|
||||
parser_module_name: str
|
||||
) -> ModuleType
|
||||
|
||||
Get a parser Module object so you can use it directly.
|
||||
|
||||
### parser_info
|
||||
|
||||
parser_info(
|
||||
|
15
jc/lib.py
15
jc/lib.py
@ -281,13 +281,24 @@ def get_parser(parser_mod_name: Union[str, ModuleType]) -> ModuleType:
|
||||
|
||||
Parameters:
|
||||
|
||||
parser_mod_name: (string or name of the parser module. This
|
||||
parser_mod_name: (string or Name of the parser module. This
|
||||
Module) function will accept module_name,
|
||||
cli-name, and --argument-name
|
||||
variants of the module name.
|
||||
|
||||
If a Module is given and the Module
|
||||
is a valid parser Module, then the
|
||||
same Module is returned.
|
||||
|
||||
Returns:
|
||||
|
||||
Parser: the parser module object
|
||||
Module: the parser Module object
|
||||
|
||||
Raises:
|
||||
|
||||
ModuleNotFoundError: If the Module is not found or is not a valid
|
||||
parser Module, then a ModuleNotFoundError
|
||||
exception is raised.
|
||||
"""
|
||||
if isinstance(parser_mod_name, ModuleType):
|
||||
jc_parser = parser_mod_name
|
||||
|
Reference in New Issue
Block a user