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

94 lines
1.7 KiB
Markdown
Raw Normal View History

2022-09-16 16:04:25 -07:00
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.proc_swaps"></a>
2024-03-14 22:46:52 -07:00
# jc.parsers.proc_swaps
2022-09-16 16:04:25 -07:00
jc - JSON Convert `/proc/swaps` file parser
Usage (cli):
$ cat /proc/swaps | jc --proc
or
$ jc /proc/swaps
or
$ cat /proc/swaps | jc --proc-swaps
Usage (module):
import jc
result = jc.parse('proc', proc_swaps_file)
or
import jc
result = jc.parse('proc_swaps', proc_swaps_file)
Schema:
[
{
"filename": string,
"type": string,
"size": integer,
"used": integer,
"priority": integer
}
]
Examples:
$ cat /proc/swaps | jc --proc -p
[
{
"filename": "/swap.img",
"type": "file",
"size": 3996668,
"used": 0,
"priority": -2
},
...
]
2022-09-26 19:41:35 -07:00
$ cat /proc/swaps | jc --proc-swaps -p -r
2022-09-16 16:04:25 -07:00
[
{
"filename": "/swap.img",
"type": "file",
"size": "3996668",
"used": "0",
"priority": "-2"
},
...
]
<a id="jc.parsers.proc_swaps.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]
```
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:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux
2023-12-21 14:55:21 -08:00
Source: [`jc/parsers/proc_swaps.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/proc_swaps.py)
2022-09-16 16:04:25 -07:00
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)