mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
use generator instead of iterable in function return annotation
This commit is contained in:
@ -101,10 +101,12 @@ Examples:
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
@add_jc_meta
|
@add_jc_meta
|
||||||
def parse(data: Iterable[str],
|
def parse(
|
||||||
|
data: Iterable[str],
|
||||||
raw: bool = False,
|
raw: bool = False,
|
||||||
quiet: bool = False,
|
quiet: bool = False,
|
||||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
ignore_exceptions: bool = False
|
||||||
|
) -> Union[Generator[Dict, None, None], tuple]
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
@ -83,10 +83,12 @@ Examples:
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
@add_jc_meta
|
@add_jc_meta
|
||||||
def parse(data: Iterable[str],
|
def parse(
|
||||||
|
data: Iterable[str],
|
||||||
raw: bool = False,
|
raw: bool = False,
|
||||||
quiet: bool = False,
|
quiet: bool = False,
|
||||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
ignore_exceptions: bool = False
|
||||||
|
) -> Union[Generator[Dict, None, None], tuple]
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
@ -90,10 +90,12 @@ Examples:
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
@add_jc_meta
|
@add_jc_meta
|
||||||
def parse(data: Iterable[str],
|
def parse(
|
||||||
|
data: Iterable[str],
|
||||||
raw: bool = False,
|
raw: bool = False,
|
||||||
quiet: bool = False,
|
quiet: bool = False,
|
||||||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple]
|
ignore_exceptions: bool = False
|
||||||
|
) -> Union[Generator[Dict, None, None], tuple]
|
||||||
```
|
```
|
||||||
|
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
@ -54,7 +54,8 @@ Returns:
|
|||||||
### sparse\_table\_parse
|
### sparse\_table\_parse
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def sparse_table_parse(data: List[str], delim: str = '\u2063') -> List[Dict]
|
def sparse_table_parse(data: Iterable[str],
|
||||||
|
delim: str = '\u2063') -> List[Dict]
|
||||||
```
|
```
|
||||||
|
|
||||||
Parse tables with missing column data or with spaces in column data.
|
Parse tables with missing column data or with spaces in column data.
|
||||||
@ -77,16 +78,14 @@ Example Table:
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
data: (list) Text data to parse that has been split into lines
|
data: (iter) An iterable of string lines (e.g. str.splitlines())
|
||||||
via .splitlines(). Item 0 must be the header row.
|
Item 0 must be the header row. Any spaces in header
|
||||||
Any spaces in header names should be changed to
|
names should be changed to underscore '_'. You
|
||||||
underscore '_'. You should also ensure headers are
|
should also ensure headers are lowercase by using
|
||||||
lowercase by using .lower(). Do not change the
|
.lower(). Do not change the position of header
|
||||||
position of header names as the positions are used
|
names as the positions are used to find the data.
|
||||||
to find the data.
|
|
||||||
|
|
||||||
Also, ensure there are no blank lines (list items)
|
Also, ensure there are no blank line items.
|
||||||
in the data.
|
|
||||||
|
|
||||||
delim: (string) Delimiter to use. By default `u\\2063`
|
delim: (string) Delimiter to use. By default `u\\2063`
|
||||||
(invisible separator) is used since it is unlikely
|
(invisible separator) is used since it is unlikely
|
||||||
|
@ -40,7 +40,7 @@ Examples:
|
|||||||
{example output}
|
{example output}
|
||||||
...
|
...
|
||||||
"""
|
"""
|
||||||
from typing import Dict, Iterable, Union
|
from typing import Dict, Iterable, Generator, Union
|
||||||
import jc.utils
|
import jc.utils
|
||||||
from jc.streaming import (
|
from jc.streaming import (
|
||||||
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
||||||
@ -90,7 +90,7 @@ def parse(
|
|||||||
raw: bool = False,
|
raw: bool = False,
|
||||||
quiet: bool = False,
|
quiet: bool = False,
|
||||||
ignore_exceptions: bool = False
|
ignore_exceptions: bool = False
|
||||||
) -> Union[Iterable[Dict], tuple]:
|
) -> Union[Generator[Dict, None, None], tuple]:
|
||||||
"""
|
"""
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ Examples:
|
|||||||
{"cpu":"all","intr_s":"37.61","type":"interrupts","time":"03:15:06 PM"}
|
{"cpu":"all","intr_s":"37.61","type":"interrupts","time":"03:15:06 PM"}
|
||||||
...
|
...
|
||||||
"""
|
"""
|
||||||
from typing import Dict, Iterable, Union
|
from typing import Dict, Iterable, Generator, Union
|
||||||
import jc.utils
|
import jc.utils
|
||||||
from jc.parsers.universal import simple_table_parse
|
from jc.parsers.universal import simple_table_parse
|
||||||
from jc.streaming import (
|
from jc.streaming import (
|
||||||
@ -145,7 +145,7 @@ def parse(
|
|||||||
raw: bool = False,
|
raw: bool = False,
|
||||||
quiet: bool = False,
|
quiet: bool = False,
|
||||||
ignore_exceptions: bool = False
|
ignore_exceptions: bool = False
|
||||||
) -> Union[Iterable[Dict], tuple]:
|
) -> Union[Generator[Dict, None, None], tuple]:
|
||||||
"""
|
"""
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ Examples:
|
|||||||
{"time":"1646859134","uid":"0","pid":"9","percent_usr":"0.00","perc...}
|
{"time":"1646859134","uid":"0","pid":"9","percent_usr":"0.00","perc...}
|
||||||
...
|
...
|
||||||
"""
|
"""
|
||||||
from typing import Dict, Iterable, Union
|
from typing import Dict, Iterable, Generator, Union
|
||||||
import jc.utils
|
import jc.utils
|
||||||
from jc.streaming import (
|
from jc.streaming import (
|
||||||
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
||||||
@ -126,7 +126,7 @@ def parse(
|
|||||||
raw: bool = False,
|
raw: bool = False,
|
||||||
quiet: bool = False,
|
quiet: bool = False,
|
||||||
ignore_exceptions: bool = False
|
ignore_exceptions: bool = False
|
||||||
) -> Union[Iterable[Dict], tuple]:
|
) -> Union[Generator[Dict, None, None], tuple]:
|
||||||
"""
|
"""
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ Examples:
|
|||||||
...
|
...
|
||||||
"""
|
"""
|
||||||
import re
|
import re
|
||||||
from typing import Dict, Iterable, Union
|
from typing import Dict, Iterable, Generator, Union
|
||||||
import jc.utils
|
import jc.utils
|
||||||
from jc.streaming import (
|
from jc.streaming import (
|
||||||
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
add_jc_meta, streaming_input_type_check, streaming_line_input_type_check, raise_or_yield
|
||||||
@ -139,7 +139,7 @@ def parse(
|
|||||||
raw: bool = False,
|
raw: bool = False,
|
||||||
quiet: bool = False,
|
quiet: bool = False,
|
||||||
ignore_exceptions: bool = False
|
ignore_exceptions: bool = False
|
||||||
) -> Union[Iterable[Dict], tuple]:
|
) -> Union[Generator[Dict, None, None], tuple]:
|
||||||
"""
|
"""
|
||||||
Main text parsing generator function. Returns an iterator object.
|
Main text parsing generator function. Returns an iterator object.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user