2023-11-28 11:23:47 -08:00
|
|
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
|
|
|
<a id="jc.parsers.swapon"></a>
|
|
|
|
|
|
|
|
# jc.parsers.swapon
|
|
|
|
|
|
|
|
jc - JSON Convert `swapon` command output parser
|
|
|
|
|
|
|
|
Usage (cli):
|
|
|
|
|
|
|
|
$ swapon | jc --swapon
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
$ jc swapon
|
|
|
|
|
|
|
|
Usage (module):
|
|
|
|
|
|
|
|
import jc
|
2023-12-17 09:44:18 -08:00
|
|
|
result = jc.parse('swapon', swapon_command_output)
|
2023-11-28 11:23:47 -08:00
|
|
|
|
|
|
|
Schema:
|
|
|
|
|
|
|
|
[
|
|
|
|
{
|
2023-12-17 09:44:18 -08:00
|
|
|
"name": string,
|
|
|
|
"type": string,
|
|
|
|
"size": integer,
|
|
|
|
"used": integer,
|
|
|
|
"priority": integer
|
2023-11-28 11:23:47 -08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
$ swapon | jc --swapon
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"name": "/swapfile",
|
|
|
|
"type": "file",
|
|
|
|
"size": 1073741824,
|
|
|
|
"used": 0,
|
|
|
|
"priority": -2
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
<a id="jc.parsers.swapon.parse"></a>
|
|
|
|
|
|
|
|
### parse
|
|
|
|
|
|
|
|
```python
|
2024-03-14 22:46:52 -07:00
|
|
|
def parse(data: str,
|
|
|
|
raw: bool = False,
|
|
|
|
quiet: bool = False) -> List[Dict[str, Union[str, int]]]
|
2023-11-28 11:23:47 -08:00
|
|
|
```
|
|
|
|
|
|
|
|
Main text parsing function
|
|
|
|
|
|
|
|
Parameters:
|
|
|
|
|
|
|
|
data: (string) text data to parse
|
|
|
|
raw: (boolean) unprocessed output if True
|
|
|
|
quiet: (boolean) suppress warning messages if True
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
Dictionary. Raw or processed structured data.
|
|
|
|
|
|
|
|
### Parser Information
|
|
|
|
Compatibility: linux, freebsd
|
|
|
|
|
2023-12-21 14:55:21 -08:00
|
|
|
Source: [`jc/parsers/swapon.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/swapon.py)
|
|
|
|
|
2023-11-28 11:23:47 -08:00
|
|
|
Version 1.0 by Roey Darwish Dror (roey.ghost@gmail.com)
|