diff --git a/CHANGELOG b/CHANGELOG index 242eac66..247a7c6d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,17 +1,14 @@ jc changelog -20220510 v1.19.0 (in progress) +20220510 v1.19.0 - Add chage --list command parser tested on linux - 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 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 - Fix asciitable-m parser to skip some rows that contain column separator characters in cell data. A warning message will be printed to STDOUT unless `-q` or `quiet=True` is used. -- Add YAML output option 20220427 v1.18.8 - Fix update-alternatives --query parser for cases where `slaves` are not present diff --git a/README.md b/README.md index 6cae1790..3fa2fe29 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,6 @@ option. | `--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) | | `--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) | | `--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) | diff --git a/docs/parsers/git_log.md b/docs/parsers/git_log.md index b495ea49..292a9e6f 100644 --- a/docs/parsers/git_log.md +++ b/docs/parsers/git_log.md @@ -172,4 +172,4 @@ Returns: ### Parser Information 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) diff --git a/docs/parsers/git_log_s.md b/docs/parsers/git_log_s.md index 1ee737cb..11c2f6a2 100644 --- a/docs/parsers/git_log_s.md +++ b/docs/parsers/git_log_s.md @@ -108,4 +108,4 @@ Returns: ### Parser Information 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) diff --git a/docs/parsers/top.md b/docs/parsers/top.md deleted file mode 100644 index 1d36751f..00000000 --- a/docs/parsers/top.md +++ /dev/null @@ -1,64 +0,0 @@ -[Home](https://kellyjonbrazil.github.io/jc/) - - -# jc.parsers.top - -jc - JSON Convert `top -b` command output parser - -<> - -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 - [] - - - -### 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) diff --git a/jc/lib.py b/jc/lib.py index fcab3b60..ac9411f8 100644 --- a/jc/lib.py +++ b/jc/lib.py @@ -91,7 +91,6 @@ parsers = [ 'systeminfo', 'time', 'timedatectl', - 'top', 'tracepath', 'traceroute', 'ufw', diff --git a/jc/parsers/top.py b/jc/parsers/top.py deleted file mode 100644 index 536b2659..00000000 --- a/jc/parsers/top.py +++ /dev/null @@ -1,107 +0,0 @@ -"""jc - JSON Convert `top -b` command output parser - -<> - -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) diff --git a/man/jc.1 b/man/jc.1 index 9def3b33..53649fb0 100644 --- a/man/jc.1 +++ b/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 \fBjc\fP \- JSON Convert JSONifies the output of many CLI tools and file-types .SH SYNOPSIS @@ -427,11 +427,6 @@ Key/Value file parser \fB--timedatectl\fP `timedatectl status` command parser -.TP -.B -\fB--top\fP -`top -b` command parser - .TP .B \fB--tracepath\fP