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

doc update

This commit is contained in:
Kelly Brazil
2022-08-21 16:20:13 -07:00
parent 37835c1972
commit abf6ea1fec
2 changed files with 28 additions and 6 deletions

View File

@ -34,11 +34,22 @@ Parse the string data using the supplied parser module.
This function provides a high-level API to simplify parser use. This This function provides a high-level API to simplify parser use. This
function will call built-in parsers and custom plugin parsers. function will call built-in parsers and custom plugin parsers.
Example: Example (standard parsers):
>>> import jc >>> import jc
>>> jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022') >>> date_obj = jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022')
{'year': 2022, 'month': 'Jan', 'month_num': 1, 'day'...} >>> print(f'The year is: {date_obj["year"]}')
The year is: 2022
Example (streaming parsers):
>>> import jc
>>> ping_gen = jc.parse('ping_s', ping_output.splitlines())
>>> for item in ping_gen:
>>> print(f'Response time: {item["time_ms"]} ms')
Response time: 102 ms
Response time: 109 ms
...
To get a list of available parser module names, use `parser_mod_list()`. To get a list of available parser module names, use `parser_mod_list()`.

View File

@ -197,11 +197,22 @@ def parse(
This function provides a high-level API to simplify parser use. This This function provides a high-level API to simplify parser use. This
function will call built-in parsers and custom plugin parsers. function will call built-in parsers and custom plugin parsers.
Example: Example (standard parsers):
>>> import jc >>> import jc
>>> jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022') >>> date_obj = jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022')
{'year': 2022, 'month': 'Jan', 'month_num': 1, 'day'...} >>> print(f'The year is: {date_obj["year"]}')
The year is: 2022
Example (streaming parsers):
>>> import jc
>>> ping_gen = jc.parse('ping_s', ping_output.splitlines())
>>> for item in ping_gen:
>>> print(f'Response time: {item["time_ms"]} ms')
Response time: 102 ms
Response time: 109 ms
...
To get a list of available parser module names, use `parser_mod_list()`. To get a list of available parser module names, use `parser_mod_list()`.