mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
remove top parsers
This commit is contained in:
@ -1,17 +1,14 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
20220510 v1.19.0 (in progress)
|
20220510 v1.19.0
|
||||||
- Add chage --list command parser tested on linux
|
- Add chage --list command parser tested on linux
|
||||||
- Add git log command streaming parser
|
- Add git log command streaming parser
|
||||||
- Add top -b command parser tested on linux
|
|
||||||
- Add top -b command streaming parser tested on linux
|
|
||||||
- Fix git log standard parser for coner-cases where hash values are in messages
|
- Fix git log standard parser for coner-cases where hash values are in messages
|
||||||
- Fix df command parser for rare instances when a newline is found at the end
|
- Fix df command parser for rare instances when a newline is found at the end
|
||||||
- Allow jc to pip install on unsupported python version 3.6
|
- Allow jc to pip install on unsupported python version 3.6
|
||||||
- Fix asciitable-m parser to skip some rows that contain column separator
|
- Fix asciitable-m parser to skip some rows that contain column separator
|
||||||
characters in cell data. A warning message will be printed to STDOUT
|
characters in cell data. A warning message will be printed to STDOUT
|
||||||
unless `-q` or `quiet=True` is used.
|
unless `-q` or `quiet=True` is used.
|
||||||
- Add YAML output option
|
|
||||||
|
|
||||||
20220427 v1.18.8
|
20220427 v1.18.8
|
||||||
- Fix update-alternatives --query parser for cases where `slaves` are not present
|
- Fix update-alternatives --query parser for cases where `slaves` are not present
|
||||||
|
@ -228,7 +228,6 @@ option.
|
|||||||
| `--systeminfo` | `systeminfo` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/systeminfo) |
|
| `--systeminfo` | `systeminfo` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/systeminfo) |
|
||||||
| `--time` | `/usr/bin/time` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/time) |
|
| `--time` | `/usr/bin/time` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/time) |
|
||||||
| `--timedatectl` | `timedatectl status` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl) |
|
| `--timedatectl` | `timedatectl status` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl) |
|
||||||
| `--top` | `top -b` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/top) |
|
|
||||||
| `--tracepath` | `tracepath` and `tracepath6` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath) |
|
| `--tracepath` | `tracepath` and `tracepath6` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath) |
|
||||||
| `--traceroute` | `traceroute` and `traceroute6` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute) |
|
| `--traceroute` | `traceroute` and `traceroute6` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/traceroute) |
|
||||||
| `--ufw` | `ufw status` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw) |
|
| `--ufw` | `ufw status` command parser | [📃](https://kellyjonbrazil.github.io/jc/docs/parsers/ufw) |
|
||||||
|
@ -172,4 +172,4 @@ Returns:
|
|||||||
### Parser Information
|
### Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
@ -108,4 +108,4 @@ Returns:
|
|||||||
### Parser Information
|
### Parser Information
|
||||||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||||
|
|
||||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
[Home](https://kellyjonbrazil.github.io/jc/)
|
|
||||||
<a id="jc.parsers.top"></a>
|
|
||||||
|
|
||||||
# jc.parsers.top
|
|
||||||
|
|
||||||
jc - JSON Convert `top -b` command output parser
|
|
||||||
|
|
||||||
<<Short top description and caveats>>
|
|
||||||
|
|
||||||
Usage (cli):
|
|
||||||
|
|
||||||
$ top -b -n 3 | jc --top
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
$ jc top -b -n 3
|
|
||||||
|
|
||||||
Usage (module):
|
|
||||||
|
|
||||||
import jc
|
|
||||||
result = jc.parse('top', top_command_output)
|
|
||||||
|
|
||||||
Schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"top": string,
|
|
||||||
"bar": boolean,
|
|
||||||
"baz": integer
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ top | jc --top -p
|
|
||||||
[]
|
|
||||||
|
|
||||||
$ top | jc --top -p -r
|
|
||||||
[]
|
|
||||||
|
|
||||||
<a id="jc.parsers.top.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
|
|
||||||
|
|
||||||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
|
@ -91,7 +91,6 @@ parsers = [
|
|||||||
'systeminfo',
|
'systeminfo',
|
||||||
'time',
|
'time',
|
||||||
'timedatectl',
|
'timedatectl',
|
||||||
'top',
|
|
||||||
'tracepath',
|
'tracepath',
|
||||||
'traceroute',
|
'traceroute',
|
||||||
'ufw',
|
'ufw',
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
"""jc - JSON Convert `top -b` command output parser
|
|
||||||
|
|
||||||
<<Short top description and caveats>>
|
|
||||||
|
|
||||||
Usage (cli):
|
|
||||||
|
|
||||||
$ top -b -n 3 | jc --top
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
$ jc top -b -n 3
|
|
||||||
|
|
||||||
Usage (module):
|
|
||||||
|
|
||||||
import jc
|
|
||||||
result = jc.parse('top', top_command_output)
|
|
||||||
|
|
||||||
Schema:
|
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"top": string,
|
|
||||||
"bar": boolean,
|
|
||||||
"baz": integer
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
$ top | jc --top -p
|
|
||||||
[]
|
|
||||||
|
|
||||||
$ top | jc --top -p -r
|
|
||||||
[]
|
|
||||||
"""
|
|
||||||
from typing import List, Dict
|
|
||||||
import jc.utils
|
|
||||||
|
|
||||||
|
|
||||||
class info():
|
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
|
||||||
version = '1.0'
|
|
||||||
description = '`top -b` command parser'
|
|
||||||
author = 'Kelly Brazil'
|
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
|
||||||
compatible = ['linux']
|
|
||||||
magic_commands = ['top -b']
|
|
||||||
|
|
||||||
|
|
||||||
__version__ = info.version
|
|
||||||
|
|
||||||
|
|
||||||
def _process(proc_data: List[Dict]) -> List[Dict]:
|
|
||||||
"""
|
|
||||||
Final processing to conform to the schema.
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
|
|
||||||
proc_data: (List of Dictionaries) raw structured data to process
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
List of Dictionaries. Structured to conform to the schema.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# process the data here
|
|
||||||
# rebuild output for added semantic information
|
|
||||||
# use helper functions in jc.utils for int, float, bool
|
|
||||||
# conversions and timestamps
|
|
||||||
|
|
||||||
return proc_data
|
|
||||||
|
|
||||||
|
|
||||||
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.
|
|
||||||
"""
|
|
||||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
|
||||||
jc.utils.input_type_check(data)
|
|
||||||
|
|
||||||
raw_output: List = []
|
|
||||||
|
|
||||||
if jc.utils.has_data(data):
|
|
||||||
|
|
||||||
for line in filter(None, data.splitlines()):
|
|
||||||
|
|
||||||
# parse the content here
|
|
||||||
# check out helper functions in jc.utils
|
|
||||||
# and jc.parsers.universal
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
return raw_output if raw else _process(raw_output)
|
|
7
man/jc.1
7
man/jc.1
@ -1,4 +1,4 @@
|
|||||||
.TH jc 1 2022-05-12 1.19.0 "JSON Convert"
|
.TH jc 1 2022-05-13 1.19.0 "JSON Convert"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools and file-types
|
\fBjc\fP \- JSON Convert JSONifies the output of many CLI tools and file-types
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -427,11 +427,6 @@ Key/Value file parser
|
|||||||
\fB--timedatectl\fP
|
\fB--timedatectl\fP
|
||||||
`timedatectl status` command parser
|
`timedatectl status` command parser
|
||||||
|
|
||||||
.TP
|
|
||||||
.B
|
|
||||||
\fB--top\fP
|
|
||||||
`top -b` command parser
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--tracepath\fP
|
\fB--tracepath\fP
|
||||||
|
Reference in New Issue
Block a user