diff --git a/CHANGELOG b/CHANGELOG index 55227a3a..32520170 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,12 @@ jc changelog +20220127 v1.18.2 +- Fix for plugin parsers with underscores in the name +- Add type hints to public API functions +- Add plugin attribute to plugin parser metadata +- Add C locale hint to parsing error messages +- Refactor more cli code into lib + 20220121 v1.18.1 - Minor fix for MacOS binary diff --git a/MANIFEST.in b/MANIFEST.in index cbed6f59..1db4a364 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,2 @@ -include jc/man/jc.1.gz include man/jc.1 include CHANGELOG diff --git a/README.md b/README.md index 38576fb7..7f48230d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg?branch=master) ![Pypi](https://img.shields.io/pypi/v/jc.svg) -> `jc` was just featured in the [Console Open Source Newsletter](https://console.substack.com/p/console-89) +> `jc` was recently featured in the [Console Open Source Newsletter](https://console.substack.com/p/console-89) > Check out the `jc` Python [package documentation](https://github.com/kellyjonbrazil/jc/tree/master/docs) for developers diff --git a/docgen.sh b/docgen.sh index 994891b8..13cd6fec 100755 --- a/docgen.sh +++ b/docgen.sh @@ -1,31 +1,104 @@ #!/bin/bash # Generate docs.md -# requires pydoc-markdown 2.1.0.post1 +# requires pydoc-markdown 4.5.0 +readme_config=$(cat <<'EOF' +{ + "processors": [ + { + "type": "filter" + }, + { + "type": "pydocmd" + } + ], + "renderer": { + "type": "markdown", + "header_level_by_type": { + "Module": 1, + "Class": 3, + "Method": 3, + "Function": 3, + "Data": 3 + } + } +} +EOF +) + +toc_config=$(cat <<'EOF' +{ + "processors": [ + { + "type": "filter" + }, + { + "type": "pydocmd" + } + ], + "renderer": { + "type": "markdown", + "render_toc": true, + "header_level_by_type": { + "Module": 1, + "Class": 3, + "Method": 3, + "Function": 3, + "Data": 3 + } + } +} +EOF +) + +parser_config=$(cat <<'EOF' +{ + "processors": [ + { + "type": "filter", + "expression": "not name == \"info\" and not name.startswith(\"_\") and default()" + }, + { + "type": "pydocmd" + } + ], + "renderer": { + "type": "markdown", + "header_level_by_type": { + "Module": 1, + "Class": 3, + "Method": 3, + "Function": 3, + "Data": 3 + } + } +} +EOF +) cd jc echo Building docs for: package -pydocmd simple jc+ > ../docs/readme.md +pydoc-markdown -m jc "${readme_config}" > ../docs/readme.md echo Building docs for: lib -pydocmd simple lib+ > ../docs/lib.md +pydoc-markdown -m jc.lib "${toc_config}" > ../docs/lib.md echo Building docs for: utils -pydocmd simple utils+ > ../docs/utils.md +pydoc-markdown -m jc.utils "${toc_config}" > ../docs/utils.md echo Building docs for: universal parser -pydocmd simple jc.parsers.universal+ > ../docs/parsers/universal.md +pydoc-markdown -m jc.parsers.universal "${toc_config}" > ../docs/parsers/universal.md # a bit of inception here... jc is being used to help # automate the generation of its own documentation. :) # pull jc parser objects into a bash array from jq +# filter out any plugin parsers parsers=() while read -r value do parsers+=("$value") -done < <(jc -a | jq -c '.parsers[]') +done < <(jc -a | jq -c '.parsers[] | select(.plugin != true)') -# iterate over the bash array for parser in "${parsers[@]}" do parser_name=$(jq -r '.name' <<< "$parser") @@ -36,8 +109,8 @@ do echo "Building docs for: ${parser_name}" echo "[Home](https://kellyjonbrazil.github.io/jc/)" > ../docs/parsers/"${parser_name}".md - pydocmd simple jc.parsers."${parser_name}"+ >> ../docs/parsers/"${parser_name}".md - echo "## Parser Information" >> ../docs/parsers/"${parser_name}".md + pydoc-markdown -m jc.parsers."${parser_name}" "${parser_config}" >> ../docs/parsers/"${parser_name}".md + echo "### Parser Information" >> ../docs/parsers/"${parser_name}".md echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md echo >> ../docs/parsers/"${parser_name}".md echo "Version ${version} by ${author} (${author_email})" >> ../docs/parsers/"${parser_name}".md diff --git a/docs/lib.md b/docs/lib.md index 4601a0bb..8d2b7c2b 100644 --- a/docs/lib.md +++ b/docs/lib.md @@ -1,17 +1,26 @@ +# Table of Contents + +* [jc.lib](#jc.lib) + * [parse](#jc.lib.parse) + * [parser\_mod\_list](#jc.lib.parser_mod_list) + * [plugin\_parser\_mod\_list](#jc.lib.plugin_parser_mod_list) + * [parser\_info](#jc.lib.parser_info) + * [all\_parser\_info](#jc.lib.all_parser_info) + * [get\_help](#jc.lib.get_help) + + + +# jc.lib -# lib jc - JSON CLI output utility JC lib module + + +### parse -## parse ```python -parse(parser_mod_name, - data, - quiet=False, - raw=False, - ignore_exceptions=None, - **kwargs) +def parse(parser_mod_name: str, data: Union[str, Iterable[str]], quiet: bool = False, raw: bool = False, ignore_exceptions: bool = None, **kwargs) -> Union[Dict, List[Dict], Iterator[Dict]] ``` Parse the string data using the supplied parser module. @@ -49,7 +58,10 @@ parsers without this API: Parameters: - parser_mod_name: (string) name of the parser module + parser_mod_name: (string) name of the parser module. This + function will accept module_name, + cli-name, and --argument-name + variants of the module name. data: (string or data to parse (string for normal iterator) parsers, iterator of strings for @@ -67,24 +79,60 @@ Returns: Standard Parsers: Dictionary or List of Dictionaries Streaming Parsers: Generator Object containing Dictionaries + + +### parser\_mod\_list -## parser_mod_list ```python -parser_mod_list() +def parser_mod_list() -> List[str] ``` + Returns a list of all available parser module names. -## plugin_parser_mod_list + + +### plugin\_parser\_mod\_list + ```python -plugin_parser_mod_list() +def plugin_parser_mod_list() -> List[str] ``` Returns a list of plugin parser module names. This function is a subset of `parser_mod_list()`. + + +### parser\_info -## get_help ```python -get_help(parser_mod_name) +def parser_info(parser_mod_name: str) -> Union[Dict, None] ``` + +Returns a dictionary that includes the module metadata. + +This function will accept **module_name**, **cli-name**, and +**--argument-name** variants of the module name string. + + + +### all\_parser\_info + +```python +def all_parser_info() -> List[Optional[Dict]] +``` + +Returns a list of dictionaris that includes metadata for all modules. + + + +### get\_help + +```python +def get_help(parser_mod_name: str) -> None +``` + Show help screen for the selected parser. + +This function will accept **module_name**, **cli-name**, and +**--argument-name** variants of the module name string. + diff --git a/docs/parsers/acpi.md b/docs/parsers/acpi.md index 50e5f378..d6adf5a8 100644 --- a/docs/parsers/acpi.md +++ b/docs/parsers/acpi.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.acpi + jc - JSON CLI output utility `acpi` command output parser Usage (cli): @@ -230,16 +232,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -254,7 +252,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/airport.md b/docs/parsers/airport.md index dc178d52..24abb893 100644 --- a/docs/parsers/airport.md +++ b/docs/parsers/airport.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.airport + jc - JSON CLI output utility `airport -I` command output parser The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`. @@ -83,16 +85,12 @@ Examples: "channel": "48,80" } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -107,7 +105,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: darwin Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/airport_s.md b/docs/parsers/airport_s.md index 035a5d7a..ae9afae4 100644 --- a/docs/parsers/airport_s.md +++ b/docs/parsers/airport_s.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.airport\_s -# jc.parsers.airport_s jc - JSON CLI output utility `airport -s` command output parser The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport`. @@ -111,16 +113,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -135,7 +133,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: darwin Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/arp.md b/docs/parsers/arp.md index 70f5757b..09ca6d08 100644 --- a/docs/parsers/arp.md +++ b/docs/parsers/arp.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.arp + jc - JSON CLI output utility `arp` command output parser Supports `arp` and `arp -a` output. @@ -120,16 +122,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -144,7 +142,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, aix, freebsd, darwin Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/blkid.md b/docs/parsers/blkid.md index c982ba9e..b94411f2 100644 --- a/docs/parsers/blkid.md +++ b/docs/parsers/blkid.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.blkid + jc - JSON CLI output utility `blkid` command output parser Usage (cli): @@ -88,7 +90,7 @@ Examples: { "id_fs_uuid": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM", "id_fs_uuid_enc": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM", - "id_fs_version": "LVM2\x20001", + "id_fs_version": "LVM2\\x20001", "id_fs_type": "LVM2_member", "id_fs_usage": "raid", "id_iolimit_minimum_io_size": 512, @@ -123,16 +125,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -147,7 +145,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/cksum.md b/docs/parsers/cksum.md index afcb754a..0ba7468e 100644 --- a/docs/parsers/cksum.md +++ b/docs/parsers/cksum.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.cksum + jc - JSON CLI output utility `cksum` command output parser This parser works with the following checksum calculation utilities: @@ -57,16 +59,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -81,7 +79,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/crontab.md b/docs/parsers/crontab.md index 1efd7d31..d4f518b6 100644 --- a/docs/parsers/crontab.md +++ b/docs/parsers/crontab.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.crontab + jc - JSON CLI output utility `crontab -l` command output and crontab file parser @@ -176,16 +178,12 @@ Examples: ] } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -200,7 +198,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, aix, freebsd Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/crontab_u.md b/docs/parsers/crontab_u.md index dc66508b..718cb49a 100644 --- a/docs/parsers/crontab_u.md +++ b/docs/parsers/crontab_u.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.crontab\_u -# jc.parsers.crontab_u jc - JSON CLI output utility `crontab -l` command output and crontab file parser @@ -173,16 +175,12 @@ Examples: ] } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -197,7 +195,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, aix, freebsd Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/csv.md b/docs/parsers/csv.md index adc29ded..95656d8e 100644 --- a/docs/parsers/csv.md +++ b/docs/parsers/csv.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.csv + jc - JSON CLI output utility `csv` file parser The `csv` parser will attempt to automatically detect the delimiter @@ -80,16 +82,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -104,7 +102,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/csv_s.md b/docs/parsers/csv_s.md index 6392d6aa..eee33fae 100644 --- a/docs/parsers/csv_s.md +++ b/docs/parsers/csv_s.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.csv\_s -# jc.parsers.csv_s jc - JSON CLI output utility `csv` file streaming parser > This streaming parser outputs JSON Lines @@ -66,16 +68,12 @@ Examples: {"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3"...} ... + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False, ignore_exceptions=False) +def parse(data, raw=False, quiet=False, ignore_exceptions=False) ``` Main text parsing generator function. Returns an iterator object. @@ -97,7 +95,7 @@ Returns: Iterator object -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/date.md b/docs/parsers/date.md index 7132ed80..5e2f4d42 100644 --- a/docs/parsers/date.md +++ b/docs/parsers/date.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.date + jc - JSON CLI output utility `date` command output parser The `epoch` calculated timestamp field is naive. (i.e. based on the local @@ -80,16 +82,12 @@ Examples: "timezone_aware": true } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -104,7 +102,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/df.md b/docs/parsers/df.md index 6087b001..4e787857 100644 --- a/docs/parsers/df.md +++ b/docs/parsers/df.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.df + jc - JSON CLI output utility `df` command output parser Usage (cli): @@ -100,16 +102,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -124,7 +122,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/dig.md b/docs/parsers/dig.md index c727c763..fa3d492d 100644 --- a/docs/parsers/dig.md +++ b/docs/parsers/dig.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.dig + jc - JSON CLI output utility `dig` command output parser Options supported: @@ -325,16 +327,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -349,7 +347,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, aix, freebsd, darwin, win32, cygwin Version 2.2 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/dir.md b/docs/parsers/dir.md index 9d59d602..db4651c9 100644 --- a/docs/parsers/dir.md +++ b/docs/parsers/dir.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.dir + jc - JSON CLI output utility `dir` command output parser Options supported: @@ -53,7 +55,7 @@ Examples: "dir": true, "size": null, "filename": ".", - "parent": "C:\Program Files\Internet Explorer", + "parent": "C:\\Program Files\\Internet Explorer", "epoch": 1616624100 }, { @@ -62,7 +64,7 @@ Examples: "dir": true, "size": null, "filename": "..", - "parent": "C:\Program Files\Internet Explorer", + "parent": "C:\\Program Files\\Internet Explorer", "epoch": 1616624100 }, { @@ -71,7 +73,7 @@ Examples: "dir": true, "size": null, "filename": "en-US", - "parent": "C:\Program Files\Internet Explorer", + "parent": "C:\\Program Files\\Internet Explorer", "epoch": 1575715740 }, { @@ -80,7 +82,7 @@ Examples: "dir": false, "size": 54784, "filename": "ExtExport.exe", - "parent": "C:\Program Files\Internet Explorer", + "parent": "C:\\Program Files\\Internet Explorer", "epoch": 1575713340 }, ... @@ -94,7 +96,7 @@ Examples: "dir": true, "size": null, "filename": ".", - "parent": "C:\Program Files\Internet Explorer" + "parent": "C:\\Program Files\\Internet Explorer" }, { "date": "03/24/2021", @@ -102,7 +104,7 @@ Examples: "dir": true, "size": null, "filename": "..", - "parent": "C:\Program Files\Internet Explorer" + "parent": "C:\\Program Files\\Internet Explorer" }, { "date": "12/07/2019", @@ -110,7 +112,7 @@ Examples: "dir": true, "size": null, "filename": "en-US", - "parent": "C:\Program Files\Internet Explorer" + "parent": "C:\\Program Files\\Internet Explorer" }, { "date": "12/07/2019", @@ -118,21 +120,17 @@ Examples: "dir": false, "size": "54,784", "filename": "ExtExport.exe", - "parent": "C:\Program Files\Internet Explorer" + "parent": "C:\\Program Files\\Internet Explorer" }, ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -147,7 +145,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: win32 Version 1.4 by Rasheed Elsaleh (rasheed@rebelliondefense.com) diff --git a/docs/parsers/dmidecode.md b/docs/parsers/dmidecode.md index 6a548ffe..8591a534 100644 --- a/docs/parsers/dmidecode.md +++ b/docs/parsers/dmidecode.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.dmidecode + jc - JSON CLI output utility `dmidecode` command output parser Usage (cli): @@ -128,16 +130,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -152,7 +150,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/dpkg_l.md b/docs/parsers/dpkg_l.md index 9080b111..0daa5f96 100644 --- a/docs/parsers/dpkg_l.md +++ b/docs/parsers/dpkg_l.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.dpkg\_l -# jc.parsers.dpkg_l jc - JSON CLI output utility `dpkg -l` command output parser Set the `COLUMNS` environment variable to a large value to avoid field @@ -134,16 +136,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -158,7 +156,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/du.md b/docs/parsers/du.md index c17c26b2..6168bfda 100644 --- a/docs/parsers/du.md +++ b/docs/parsers/du.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.du + jc - JSON CLI output utility `du` command output parser Usage (cli): @@ -90,16 +92,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -114,7 +112,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, aix, freebsd Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/env.md b/docs/parsers/env.md index e2b8525a..428f02d1 100644 --- a/docs/parsers/env.md +++ b/docs/parsers/env.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.env + jc - JSON CLI output utility `env` and `printenv` command output parser This parser will output a list of dictionaries each containing `name` and @@ -75,16 +77,12 @@ Examples: "_": "/usr/bin/env" } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -100,7 +98,7 @@ Returns: Dictionary of raw structured data or List of Dictionaries of processed structured data -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/file.md b/docs/parsers/file.md index bb8a211e..aefb2165 100644 --- a/docs/parsers/file.md +++ b/docs/parsers/file.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.file + jc - JSON CLI output utility `file` command output parser Usage (cli): @@ -65,16 +67,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -89,7 +87,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, aix, freebsd, darwin Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/finger.md b/docs/parsers/finger.md index 09e59400..a48edaa9 100644 --- a/docs/parsers/finger.md +++ b/docs/parsers/finger.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.finger + jc - JSON CLI output utility `finger` command output parser Supports `-s` output option. Does not support the `-l` detail option. @@ -93,16 +95,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -117,7 +115,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, freebsd Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/free.md b/docs/parsers/free.md index 25e7b826..4e3fa757 100644 --- a/docs/parsers/free.md +++ b/docs/parsers/free.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.free + jc - JSON CLI output utility `free` command output parser Usage (cli): @@ -75,16 +77,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -99,7 +97,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/fstab.md b/docs/parsers/fstab.md index ede53d87..4d4707ec 100644 --- a/docs/parsers/fstab.md +++ b/docs/parsers/fstab.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.fstab + jc - JSON CLI output utility `fstab` file parser Usage (cli): @@ -88,16 +90,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -112,7 +110,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, freebsd Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/group.md b/docs/parsers/group.md index 04d2be6d..14037ccc 100644 --- a/docs/parsers/group.md +++ b/docs/parsers/group.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.group + jc - JSON CLI output utility `/etc/group` file parser Usage (cli): @@ -112,16 +114,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -136,7 +134,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, aix, freebsd Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/gshadow.md b/docs/parsers/gshadow.md index 8fb1c089..d70b01ca 100644 --- a/docs/parsers/gshadow.md +++ b/docs/parsers/gshadow.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.gshadow + jc - JSON CLI output utility `/etc/gshadow` file parser Usage (cli): @@ -80,16 +82,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -104,7 +102,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, aix, freebsd Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/hash.md b/docs/parsers/hash.md index c2874b41..319591d2 100644 --- a/docs/parsers/hash.md +++ b/docs/parsers/hash.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.hash + jc - JSON CLI output utility `hash` command output parser Usage (cli): @@ -40,16 +42,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -64,7 +62,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/hashsum.md b/docs/parsers/hashsum.md index d4894dc5..a2ca926c 100644 --- a/docs/parsers/hashsum.md +++ b/docs/parsers/hashsum.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.hashsum + jc - JSON CLI output utility `hash sum` command output parser This parser works with the following hash calculation utilities: @@ -71,16 +73,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -95,7 +93,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/hciconfig.md b/docs/parsers/hciconfig.md index 191f941d..7a486eb6 100644 --- a/docs/parsers/hciconfig.md +++ b/docs/parsers/hciconfig.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.hciconfig + jc - JSON CLI output utility `hciconfig` command output parser Usage (cli): @@ -320,16 +322,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -344,7 +342,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/history.md b/docs/parsers/history.md index 6b082014..54ce0dea 100644 --- a/docs/parsers/history.md +++ b/docs/parsers/history.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.history + jc - JSON CLI output utility `history` command output parser This parser will output a list of dictionaries each containing `line` and @@ -48,7 +50,7 @@ Examples: }, { "line": 120, - "command": "echo "hello"" + "command": "echo \"hello\"" }, { "line": 121, @@ -61,21 +63,17 @@ Examples: { "118": "sleep 100", "119": "ls /bin", - "120": "echo "hello"", + "120": "echo \"hello\"", "121": "docker images", ... } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -91,7 +89,7 @@ Returns: Dictionary of raw structured data or List of Dictionaries of processed structured data -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/hosts.md b/docs/parsers/hosts.md index 0ba8e85f..9b9d165b 100644 --- a/docs/parsers/hosts.md +++ b/docs/parsers/hosts.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.hosts + jc - JSON CLI output utility `/etc/hosts` file parser Usage (cli): @@ -77,16 +79,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -101,7 +99,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/id.md b/docs/parsers/id.md index 427f93d4..f231d485 100644 --- a/docs/parsers/id.md +++ b/docs/parsers/id.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.id + jc - JSON CLI output utility `id` command output parser Usage (cli): @@ -108,16 +110,12 @@ Examples: } } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -132,7 +130,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, aix, freebsd Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ifconfig.md b/docs/parsers/ifconfig.md index 67b2ddf5..b742d594 100644 --- a/docs/parsers/ifconfig.md +++ b/docs/parsers/ifconfig.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.ifconfig + jc - JSON CLI output utility `ifconfig` command output parser Note: No `ifconfig` options are supported. @@ -189,16 +191,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -213,7 +211,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, aix, freebsd, darwin Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ini.md b/docs/parsers/ini.md index 810f5073..f5d7892d 100644 --- a/docs/parsers/ini.md +++ b/docs/parsers/ini.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.ini + jc - JSON CLI output utility `INI` file parser Parses standard `INI` files and files containing simple key/value pairs. @@ -69,16 +71,12 @@ Examples: } } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -93,7 +91,7 @@ Returns: Dictionary representing the ini file -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/iostat.md b/docs/parsers/iostat.md index e2482252..e0843778 100644 --- a/docs/parsers/iostat.md +++ b/docs/parsers/iostat.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.iostat + jc - JSON CLI output utility `iostat` command output parser Note: `iostat` version 11 and higher include a JSON output option @@ -162,16 +164,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -186,7 +184,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/iostat_s.md b/docs/parsers/iostat_s.md index 3696ff4b..fd116a85 100644 --- a/docs/parsers/iostat_s.md +++ b/docs/parsers/iostat_s.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.iostat\_s -# jc.parsers.iostat_s jc - JSON CLI output utility `iostat` command output streaming parser > This streaming parser outputs JSON Lines @@ -103,16 +105,12 @@ Examples: {"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10"...} ... + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False, ignore_exceptions=False) +def parse(data, raw=False, quiet=False, ignore_exceptions=False) ``` Main text parsing generator function. Returns an iterator object. @@ -134,7 +132,7 @@ Returns: Iterator object -## Parser Information +### Parser Information Compatibility: linux Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/iptables.md b/docs/parsers/iptables.md index 3f3c41fa..3066c881 100644 --- a/docs/parsers/iptables.md +++ b/docs/parsers/iptables.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.iptables + jc - JSON CLI output utility `iptables` command output parser Supports `-vLn` and `--line-numbers` for all tables. @@ -166,16 +168,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -190,7 +188,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/iw_scan.md b/docs/parsers/iw_scan.md index b9932f17..df0ed6df 100644 --- a/docs/parsers/iw_scan.md +++ b/docs/parsers/iw_scan.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.iw\_scan -# jc.parsers.iw_scan jc - JSON CLI output utility `iw dev scan` command output parser This parser is considered beta quality. Not all fields are parsed and there @@ -124,16 +126,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -148,7 +146,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 0.7 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/jar_manifest.md b/docs/parsers/jar_manifest.md index b3014594..7e2b44d2 100644 --- a/docs/parsers/jar_manifest.md +++ b/docs/parsers/jar_manifest.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.jar\_manifest -# jc.parsers.jar_manifest jc - JSON CLI output utility `MANIFEST.MF` file parser Usage (cli): @@ -29,16 +31,16 @@ Schema: Examples: $ cat MANIFEST.MF | jc --jar-manifest -p - $ unzip -c log4j-core-2.16.0.jar META-INF/MANIFEST.MF | \ + $ unzip -c log4j-core-2.16.0.jar META-INF/MANIFEST.MF | \\ jc --jar-manifest -p - $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \ + $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \\ jc --jar-manifest -p $ cat MANIFEST.MF | jc --jar-manifest -p [ { "Import_Package": "com.conversantmedia.util.concurrent;resoluti...", - "Export_Package": "org.apache.logging.log4j.core;uses:="org.ap...", + "Export_Package": "org.apache.logging.log4j.core;uses:=\"org.ap...", "Manifest_Version": "1.0", "Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt", "Bundle_SymbolicName": "org.apache.logging.log4j.core", @@ -51,7 +53,7 @@ Examples: } ] - $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \ + $ unzip -c 'apache-log4j-2.16.0-bin/*.jar' META-INF/MANIFEST.MF | \\ jc --jar-manifest -p [ ... @@ -80,16 +82,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -104,7 +102,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 0.01 by Matt J (https://github.com/listuser) diff --git a/docs/parsers/jobs.md b/docs/parsers/jobs.md index 2810277c..d24d7e2b 100644 --- a/docs/parsers/jobs.md +++ b/docs/parsers/jobs.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.jobs + jc - JSON CLI output utility `jobs` command output parser Also supports the `-l` option. @@ -96,16 +98,12 @@ Example: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -120,7 +118,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/kv.md b/docs/parsers/kv.md index 391a82a4..024e1a88 100644 --- a/docs/parsers/kv.md +++ b/docs/parsers/kv.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.kv + jc - JSON CLI output utility `Key/Value` file parser Supports files containing simple key/value pairs. Delimiter can be `=` or @@ -56,16 +58,12 @@ Examples: "occupation": "Engineer" } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -82,7 +80,7 @@ Returns: Dictionary representing the key/value file -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/last.md b/docs/parsers/last.md index 75ac2eea..aa9de406 100644 --- a/docs/parsers/last.md +++ b/docs/parsers/last.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.last + jc - JSON CLI output utility `last` and `lastb` command output parser Supports `-w` and `-F` options. @@ -107,17 +109,12 @@ Examples: ... ] + +### parse -## info ```python -info() -``` -Provides parser metadata (version, author, etc.) - -## parse -```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -132,7 +129,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, aix, freebsd Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ls.md b/docs/parsers/ls.md index 67bc7199..f9acc3df 100644 --- a/docs/parsers/ls.md +++ b/docs/parsers/ls.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.ls + jc - JSON CLI output utility `ls` and `vdir` command output parser Options supported: @@ -119,16 +121,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -143,7 +141,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ls_s.md b/docs/parsers/ls_s.md index 6a4374cf..1016aafa 100644 --- a/docs/parsers/ls_s.md +++ b/docs/parsers/ls_s.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.ls\_s -# jc.parsers.ls_s jc - JSON CLI output utility `ls` and `vdir` command output streaming parser @@ -80,16 +82,12 @@ Examples: {"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1...} ... + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False, ignore_exceptions=False) +def parse(data, raw=False, quiet=False, ignore_exceptions=False) ``` Main text parsing generator function. Returns an iterator object. @@ -111,7 +109,7 @@ Returns: Iterator object -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/lsblk.md b/docs/parsers/lsblk.md index 265593ab..137bb66b 100644 --- a/docs/parsers/lsblk.md +++ b/docs/parsers/lsblk.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.lsblk + jc - JSON CLI output utility `lsblk` command output parser Usage (cli): @@ -93,9 +95,9 @@ Examples: ... ] - $ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\ - STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\ - SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\ + $ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\\ + STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\\ + SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\\ PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p [ { @@ -185,9 +187,9 @@ Examples: ... ] - $ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\ - STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\ - SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\ + $ lsblk -o +KNAME,FSTYPE,LABEL,UUID,PARTLABEL,PARTUUID,RA,MODEL,SERIAL,\\ + STATE,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,\\ + SCHED,RQ-SIZE,DISC-ALN,DISC-GRAN,DISC-MAX,DISC-ZERO,WSAME,WWN,RAND,\\ PKNAME,HCTL,TRAN,REV,VENDOR | jc --lsblk -p -r [ { @@ -277,16 +279,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -301,7 +299,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/lsmod.md b/docs/parsers/lsmod.md index 2cb65ce4..918196c2 100644 --- a/docs/parsers/lsmod.md +++ b/docs/parsers/lsmod.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.lsmod + jc - JSON CLI output utility `lsmod` command output parser Usage (cli): @@ -128,16 +130,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -152,7 +150,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/lsof.md b/docs/parsers/lsof.md index 6003595f..91d8b439 100644 --- a/docs/parsers/lsof.md +++ b/docs/parsers/lsof.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.lsof + jc - JSON CLI output utility `lsof` command output parser Usage (cli): @@ -122,16 +124,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -146,7 +144,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/lsusb.md b/docs/parsers/lsusb.md index 73198739..4243593c 100644 --- a/docs/parsers/lsusb.md +++ b/docs/parsers/lsusb.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.lsusb + jc - JSON CLI output utility `lsusb` command output parser Supports the `-v` option or no options. @@ -264,16 +266,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -288,7 +286,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/mount.md b/docs/parsers/mount.md index cf85d0f7..4eb3ba20 100644 --- a/docs/parsers/mount.md +++ b/docs/parsers/mount.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.mount + jc - JSON CLI output utility `mount` command output parser Usage (cli): @@ -78,16 +80,12 @@ Example: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -102,7 +100,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/netstat.md b/docs/parsers/netstat.md index fcd0173a..c48fbcfc 100644 --- a/docs/parsers/netstat.md +++ b/docs/parsers/netstat.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.netstat + jc - JSON CLI output utility `netstat` command output parser Caveats: @@ -358,16 +360,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -382,7 +380,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ntpq.md b/docs/parsers/ntpq.md index 71293dc4..15ca65db 100644 --- a/docs/parsers/ntpq.md +++ b/docs/parsers/ntpq.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.ntpq + jc - JSON CLI output utility `ntpq -p` command output parser Usage (cli): @@ -209,16 +211,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -233,7 +231,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, freebsd Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/passwd.md b/docs/parsers/passwd.md index 6253da68..e0682d55 100644 --- a/docs/parsers/passwd.md +++ b/docs/parsers/passwd.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.passwd + jc - JSON CLI output utility `/etc/passwd` file Parser Usage (cli): @@ -97,16 +99,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -121,7 +119,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, aix, freebsd Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ping.md b/docs/parsers/ping.md index e20ca0c4..3ffce210 100644 --- a/docs/parsers/ping.md +++ b/docs/parsers/ping.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.ping + jc - JSON CLI output utility `ping` command output parser Supports `ping` and `ping6` output. @@ -165,16 +167,12 @@ Examples: ] } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -189,7 +187,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ping_s.md b/docs/parsers/ping_s.md index 6d8913af..f31a2c68 100644 --- a/docs/parsers/ping_s.md +++ b/docs/parsers/ping_s.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.ping\_s -# jc.parsers.ping_s jc - JSON CLI output utility `ping` command output streaming parser > This streaming parser outputs JSON Lines @@ -86,16 +88,12 @@ Examples: {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...} ... + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False, ignore_exceptions=False) +def parse(data, raw=False, quiet=False, ignore_exceptions=False) ``` Main text parsing generator function. Returns an iterator object. @@ -117,7 +115,7 @@ Returns: Iterator object -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/pip_list.md b/docs/parsers/pip_list.md index d63c4afb..de814615 100644 --- a/docs/parsers/pip_list.md +++ b/docs/parsers/pip_list.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.pip\_list -# jc.parsers.pip_list jc - JSON CLI output utility `pip-list` command output parser Usage (cli): @@ -50,16 +52,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -74,7 +72,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/pip_show.md b/docs/parsers/pip_show.md index cc6c43c7..9de9de46 100644 --- a/docs/parsers/pip_show.md +++ b/docs/parsers/pip_show.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.pip\_show -# jc.parsers.pip_show jc - JSON CLI output utility `pip-show` command output parser Usage (cli): @@ -68,16 +70,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -92,7 +90,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ps.md b/docs/parsers/ps.md index 85f1cc8a..b2e21c5c 100644 --- a/docs/parsers/ps.md +++ b/docs/parsers/ps.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.ps + jc - JSON CLI output utility `ps` command output parser `ps` options supported: @@ -209,16 +211,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -233,7 +231,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/route.md b/docs/parsers/route.md index 0615d264..c44d9a2a 100644 --- a/docs/parsers/route.md +++ b/docs/parsers/route.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.route + jc - JSON CLI output utility `route` command output parser Usage (cli): @@ -111,16 +113,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -135,7 +133,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/rpm_qi.md b/docs/parsers/rpm_qi.md index 5125ac7a..d3c4f71e 100644 --- a/docs/parsers/rpm_qi.md +++ b/docs/parsers/rpm_qi.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.rpm\_qi -# jc.parsers.rpm_qi jc - JSON CLI output utility `rpm -qi` command output parser Works with `rpm -qi [package]` or `rpm -qia`. @@ -164,16 +166,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -188,7 +186,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/sfdisk.md b/docs/parsers/sfdisk.md index 70464fc1..eb0d8cde 100644 --- a/docs/parsers/sfdisk.md +++ b/docs/parsers/sfdisk.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.sfdisk + jc - JSON CLI output utility `sfdisk` command output parser Supports the following `sfdisk` options: @@ -205,16 +207,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -229,7 +227,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/shadow.md b/docs/parsers/shadow.md index d3323439..b184b650 100644 --- a/docs/parsers/shadow.md +++ b/docs/parsers/shadow.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.shadow + jc - JSON CLI output utility `/etc/shadow` file parser Usage (cli): @@ -104,16 +106,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -128,7 +126,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, aix, freebsd Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ss.md b/docs/parsers/ss.md index a41d9a9f..17031b5e 100644 --- a/docs/parsers/ss.md +++ b/docs/parsers/ss.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.ss + jc - JSON CLI output utility `ss` command output parser Extended information options like -e and -p are not supported and may cause @@ -283,16 +285,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -307,7 +305,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/stat.md b/docs/parsers/stat.md index 1a1726c4..72566c41 100644 --- a/docs/parsers/stat.md +++ b/docs/parsers/stat.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.stat + jc - JSON CLI output utility `stat` command output parser The `xxx_epoch` calculated timestamp fields are naive. (i.e. based on the @@ -173,16 +175,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -197,7 +195,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/stat_s.md b/docs/parsers/stat_s.md index 9a442c21..4f560f7c 100644 --- a/docs/parsers/stat_s.md +++ b/docs/parsers/stat_s.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.stat\_s -# jc.parsers.stat_s jc - JSON CLI output utility `stat` command output streaming parser > This streaming parser outputs JSON Lines @@ -84,16 +86,12 @@ Examples: $ stat | jc --stat-s -r {"file":"(stdin)","unix_device":"1027739696","inode":"1155","flag...} + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False, ignore_exceptions=False) +def parse(data, raw=False, quiet=False, ignore_exceptions=False) ``` Main text parsing generator function. Returns an iterator object. @@ -115,7 +113,7 @@ Returns: Iterator object -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 0.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/sysctl.md b/docs/parsers/sysctl.md index f324bd35..1b77027a 100644 --- a/docs/parsers/sysctl.md +++ b/docs/parsers/sysctl.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.sysctl + jc - JSON CLI output utility `sysctl -a` command output parser Note: Since `sysctl` output is not easily parsable only a very simple @@ -60,16 +62,12 @@ Examples: ... } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -84,7 +82,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/systemctl.md b/docs/parsers/systemctl.md index cb953574..2359a0f4 100644 --- a/docs/parsers/systemctl.md +++ b/docs/parsers/systemctl.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.systemctl + jc - JSON CLI output utility `systemctl` command output parser Usage (cli): @@ -61,16 +63,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -85,7 +83,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/systemctl_lj.md b/docs/parsers/systemctl_lj.md index f6fd1f7a..324375d0 100644 --- a/docs/parsers/systemctl_lj.md +++ b/docs/parsers/systemctl_lj.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.systemctl\_lj -# jc.parsers.systemctl_lj jc - JSON CLI output utility `systemctl list-jobs` command output parser Usage (cli): @@ -78,16 +80,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -102,7 +100,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/systemctl_ls.md b/docs/parsers/systemctl_ls.md index ce0bbd1c..caca4b71 100644 --- a/docs/parsers/systemctl_ls.md +++ b/docs/parsers/systemctl_ls.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.systemctl\_ls -# jc.parsers.systemctl_ls jc - JSON CLI output utility `systemctl list-sockets` command output parser @@ -54,16 +56,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -78,7 +76,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/systemctl_luf.md b/docs/parsers/systemctl_luf.md index c13e2480..9624439e 100644 --- a/docs/parsers/systemctl_luf.md +++ b/docs/parsers/systemctl_luf.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.systemctl\_luf -# jc.parsers.systemctl_luf jc - JSON CLI output utility `systemctl list-unit-files` command output parser @@ -50,16 +52,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -74,7 +72,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/systeminfo.md b/docs/parsers/systeminfo.md index d6af59be..fa77289c 100644 --- a/docs/parsers/systeminfo.md +++ b/docs/parsers/systeminfo.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.systeminfo + jc - JSON CLI output utility `systeminfo` command output parser Blank or missing elements are set to `null`. @@ -114,9 +116,9 @@ Examples: "Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz" ], "bios_version": "Dell Inc. 1.16.2, 4/21/2020", - "windows_directory": "C:\WINDOWS", - "system_directory": "C:\WINDOWS\system32", - "boot_device": "\Device\HarddiskVolume2", + "windows_directory": "C:\\WINDOWS", + "system_directory": "C:\\WINDOWS\\system32", + "boot_device": "\\Device\\HarddiskVolume2", "system_locale": "en-us;English (United States)", "input_locale": "en-us;English (United States)", "time_zone": "(UTC+00:00) UTC", @@ -125,9 +127,9 @@ Examples: "virtual_memory_max_size_mb": 37367, "virtual_memory_available_mb": 22266, "virtual_memory_in_use_mb": 15101, - "page_file_locations": "C:\pagefile.sys", + "page_file_locations": "C:\\pagefile.sys", "domain": "test.com", - "logon_server": "\\TESTDC01", + "logon_server": "\\\\TESTDC01", "hotfixs": [ "KB2693643", "KB4601054" @@ -176,9 +178,9 @@ Examples: "Intel64 Family 6 Model 158 Stepping 10 GenuineIntel ~2592 Mhz" ], "bios_version": "Dell Inc. 1.16.2, 4/21/2020", - "windows_directory": "C:\WINDOWS", - "system_directory": "C:\WINDOWS\system32", - "boot_device": "\Device\HarddiskVolume2", + "windows_directory": "C:\\WINDOWS", + "system_directory": "C:\\WINDOWS\\system32", + "boot_device": "\\Device\\HarddiskVolume2", "system_locale": "en-us;English (United States)", "input_locale": "en-us;English (United States)", "time_zone": "(UTC+00:00) UTC", @@ -187,9 +189,9 @@ Examples: "virtual_memory_max_size_mb": "37,367 MB", "virtual_memory_available_mb": "22,266 MB", "virtual_memory_in_use_mb": "15,101 MB", - "page_file_locations": "C:\pagefile.sys", + "page_file_locations": "C:\\pagefile.sys", "domain": "test.com", - "logon_server": "\\TESTDC01", + "logon_server": "\\\\TESTDC01", "hotfixs": [ "KB2693643", "KB4601054" @@ -214,16 +216,12 @@ Examples: } } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -238,7 +236,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: win32 Version 1.1 by Jon Smith (jon@rebelliondefense.com) diff --git a/docs/parsers/time.md b/docs/parsers/time.md index 3a4c6bfa..6ade177f 100644 --- a/docs/parsers/time.md +++ b/docs/parsers/time.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.time + jc - JSON CLI output utility `/usr/bin/time` command output parser Output from `/usr/bin/time` is sent to `STDERR`, so the `-o` option can be @@ -14,7 +16,7 @@ Note: `/usr/bin/time` is similar but different from the Bash builtin Usage (cli): - $ /usr/bin/time -o timefile.out sleep 2; cat timefile.out | \ + $ /usr/bin/time -o timefile.out sleep 2; cat timefile.out | \\ jc --time -p Usage (module): @@ -74,7 +76,7 @@ Schema: Examples: - $ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \ + $ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \\ jc --time -p { "command_being_timed": "sleep 2", @@ -107,10 +109,10 @@ Examples: "elapsed_time_total_seconds": 2.5 } - $ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \ + $ /usr/bin/time --verbose -o timefile.out sleep 2; cat timefile.out | \\ jc --time -p -r { - "command_being_timed": ""sleep 2"", + "command_being_timed": "\"sleep 2\"", "user_time": "0.00", "system_time": "0.00", "cpu_percent": "0", @@ -135,16 +137,12 @@ Examples: "exit_status": "0" } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -159,7 +157,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/timedatectl.md b/docs/parsers/timedatectl.md index 2ee72708..8c4b1539 100644 --- a/docs/parsers/timedatectl.md +++ b/docs/parsers/timedatectl.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.timedatectl + jc - JSON CLI output utility `timedatectl` command output parser The `epoch_utc` calculated timestamp field is timezone-aware and is only @@ -67,16 +69,12 @@ Examples: "dst_active": "yes" } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -91,7 +89,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/tracepath.md b/docs/parsers/tracepath.md index 96297c54..19636189 100644 --- a/docs/parsers/tracepath.md +++ b/docs/parsers/tracepath.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.tracepath + jc - JSON CLI output utility `tracepath` command output parser Supports `tracepath` and `tracepath6` output. @@ -134,16 +136,12 @@ Examples: ] } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -158,7 +156,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/traceroute.md b/docs/parsers/traceroute.md index bf11c3c2..1ab094fb 100644 --- a/docs/parsers/traceroute.md +++ b/docs/parsers/traceroute.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.traceroute + jc - JSON CLI output utility `traceroute` command output parser Supports `traceroute` and `traceroute6` output. @@ -123,16 +125,12 @@ Examples: ] } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -147,7 +145,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ufw.md b/docs/parsers/ufw.md index 2651b6b4..ddc29105 100644 --- a/docs/parsers/ufw.md +++ b/docs/parsers/ufw.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.ufw + jc - JSON CLI output utility `ufw status` command output parser Usage (cli): @@ -203,16 +205,12 @@ Examples: ] } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -227,7 +225,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/ufw_appinfo.md b/docs/parsers/ufw_appinfo.md index 85f46de4..0ad1eecc 100644 --- a/docs/parsers/ufw_appinfo.md +++ b/docs/parsers/ufw_appinfo.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.ufw\_appinfo -# jc.parsers.ufw_appinfo jc - JSON CLI output utility `ufw app info [application]` command output parser @@ -141,16 +143,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -165,7 +163,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/uname.md b/docs/parsers/uname.md index f83c96ba..71e67ddc 100644 --- a/docs/parsers/uname.md +++ b/docs/parsers/uname.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.uname + jc - JSON CLI output utility `uname -a` command output parser Note: Must use `uname -a` @@ -50,16 +52,12 @@ Example: "kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019" } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -74,7 +72,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, freebsd Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/universal.md b/docs/parsers/universal.md index 1b25f899..f360f875 100644 --- a/docs/parsers/universal.md +++ b/docs/parsers/universal.md @@ -1,10 +1,21 @@ +# Table of Contents + +* [jc.parsers.universal](#jc.parsers.universal) + * [simple\_table\_parse](#jc.parsers.universal.simple_table_parse) + * [sparse\_table\_parse](#jc.parsers.universal.sparse_table_parse) + + # jc.parsers.universal + jc - JSON CLI output utility universal Parsers -## simple_table_parse + + +### simple\_table\_parse + ```python -simple_table_parse(data) +def simple_table_parse(data: List[str]) -> List[Dict] ``` Parse simple tables. The last column may contain data with spaces. @@ -24,10 +35,12 @@ Returns: List of Dictionaries + + +### sparse\_table\_parse -## sparse_table_parse ```python -sparse_table_parse(data, delim='\u2063') +def sparse_table_parse(data: List[str], delim: Optional[str] = '\u2063') -> List[Dict] ``` Parse tables with missing column data or with spaces in column data. @@ -45,7 +58,7 @@ Parameters: Also, ensure there are no blank lines (list 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 to ever be seen in terminal output. You can change this for troubleshooting purposes or if there is a diff --git a/docs/parsers/upower.md b/docs/parsers/upower.md index 5c1651f1..ffcbb334 100644 --- a/docs/parsers/upower.md +++ b/docs/parsers/upower.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.upower + jc - JSON CLI output utility `upower` command output parser The `updated_epoch` calculated timestamp field is naive. (i.e. based on the @@ -201,16 +203,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -225,7 +223,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/uptime.md b/docs/parsers/uptime.md index 78d5e3e5..9d5375bd 100644 --- a/docs/parsers/uptime.md +++ b/docs/parsers/uptime.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.uptime + jc - JSON CLI output utility `uptime` command output parser Usage (cli): @@ -68,16 +70,12 @@ Example: "load_15m": "1.94" } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -92,7 +90,7 @@ Returns: Dictionary. Raw or processed structured data -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/vmstat.md b/docs/parsers/vmstat.md index efa9a99c..2291fb79 100644 --- a/docs/parsers/vmstat.md +++ b/docs/parsers/vmstat.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.vmstat + jc - JSON CLI output utility `vmstat` command output parser Options supported: `-a`, `-w`, `-d`, `-t` @@ -129,16 +131,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -153,7 +151,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/vmstat_s.md b/docs/parsers/vmstat_s.md index 8c6532d7..6f85dce7 100644 --- a/docs/parsers/vmstat_s.md +++ b/docs/parsers/vmstat_s.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + + +# jc.parsers.vmstat\_s -# jc.parsers.vmstat_s jc - JSON CLI output utility `vmstat` command output streaming parser > This streaming parser outputs JSON Lines @@ -103,16 +105,12 @@ Examples: {"runnable_procs":"2","uninterruptible_sleeping_procs":"0","virtua...} ... + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False, ignore_exceptions=False) +def parse(data, raw=False, quiet=False, ignore_exceptions=False) ``` Main text parsing generator function. Returns an iterator object. @@ -134,7 +132,7 @@ Returns: Iterator object -## Parser Information +### Parser Information Compatibility: linux Version 0.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/w.md b/docs/parsers/w.md index 8f3a8b6b..378fa467 100644 --- a/docs/parsers/w.md +++ b/docs/parsers/w.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.w + jc - JSON CLI output utility `w` command output parser Usage (cli): @@ -106,16 +108,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -130,7 +128,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/wc.md b/docs/parsers/wc.md index b7251bb5..49f2f82b 100644 --- a/docs/parsers/wc.md +++ b/docs/parsers/wc.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.wc + jc - JSON CLI output utility `wc` command output parser Usage (cli): @@ -57,16 +59,12 @@ Examples: ... ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -81,7 +79,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/who.md b/docs/parsers/who.md index b8b6e211..b1d5996f 100644 --- a/docs/parsers/who.md +++ b/docs/parsers/who.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.who + jc - JSON CLI output utility `who` command output parser Accepts any of the following who options (or no options): `-aTH` @@ -138,16 +140,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -162,7 +160,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/xml.md b/docs/parsers/xml.md index 55f14bfa..1dab4203 100644 --- a/docs/parsers/xml.md +++ b/docs/parsers/xml.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.xml + jc - JSON CLI output utility `XML` file parser Usage (cli): @@ -73,16 +75,12 @@ Examples: ... } + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -97,7 +95,7 @@ Returns: Dictionary. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/yaml.md b/docs/parsers/yaml.md index 9bb5fb20..6e4d8cd2 100644 --- a/docs/parsers/yaml.md +++ b/docs/parsers/yaml.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.yaml + jc - JSON CLI output utility `YAML` file parser Usage (cli): @@ -87,16 +89,12 @@ Examples: } ] + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -111,7 +109,7 @@ Returns: List of Dictionaries representing the YAML documents. -## Parser Information +### Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com) diff --git a/docs/parsers/zipinfo.md b/docs/parsers/zipinfo.md index 1637a83b..49a4712a 100644 --- a/docs/parsers/zipinfo.md +++ b/docs/parsers/zipinfo.md @@ -1,6 +1,8 @@ [Home](https://kellyjonbrazil.github.io/jc/) + # jc.parsers.zipinfo + jc - JSON CLI output utility `zipinfo` command output parser Options supported: @@ -82,16 +84,12 @@ Examples: }, ... + -## info -```python -info() -``` -Provides parser metadata (version, author, etc.) +### parse -## parse ```python -parse(data, raw=False, quiet=False) +def parse(data, raw=False, quiet=False) ``` Main text parsing function @@ -106,7 +104,7 @@ Returns: List of Dictionaries. Raw or processed structured data. -## Parser Information +### Parser Information Compatibility: linux, darwin Version 0.01 by Matt J (https://github.com/listuser) diff --git a/docs/readme.md b/docs/readme.md index 2d2f1a79..073af8bc 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -1,5 +1,7 @@ + # jc + JC - JSON CLI output utility * kellyjonbrazil@gmail.com @@ -55,19 +57,27 @@ modules directly: Use `help(jc.lib)` for details: - parse(parser_module_name: str, data: str | iterable) + parse(parser_module_name: str, data: str | Iterable) + -> dict | list[dict] | Iterable[dict] High-level API to easily access the parser. This API will find both built-in parsers and local plugin parsers. - get_help(parser_module_name: str) + parser_info(parser_module_name: str) -> dict + Get the metadata for a particular parser. + + all_parser_info() -> list[dict] + Get the metadata for all parsers. + + get_help(parser_module_name: str) -> None Convenience function to display the help screen for a parser using its module name. - parser_mod_list() + parser_mod_list() -> list Get a list of all available parser module names to be used in - parse() and get_help(). + parse(), parser_info(), and get_help(). - plugin_parser_mod_list() - Get a list of plugin parser module names. This list is a subset of + plugin_parser_mod_list() -> list + Get a list of plugin parser module names to be used in + parse(), parser_info(), and get_help(). This list is a subset of parser_mod_list(). diff --git a/docs/utils.md b/docs/utils.md index f79b5af2..2b914cac 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -1,10 +1,33 @@ +# Table of Contents + +* [jc.utils](#jc.utils) + * [warning\_message](#jc.utils.warning_message) + * [error\_message](#jc.utils.error_message) + * [compatibility](#jc.utils.compatibility) + * [has\_data](#jc.utils.has_data) + * [convert\_to\_int](#jc.utils.convert_to_int) + * [convert\_to\_float](#jc.utils.convert_to_float) + * [convert\_to\_bool](#jc.utils.convert_to_bool) + * [stream\_success](#jc.utils.stream_success) + * [stream\_error](#jc.utils.stream_error) + * [input\_type\_check](#jc.utils.input_type_check) + * [streaming\_input\_type\_check](#jc.utils.streaming_input_type_check) + * [streaming\_line\_input\_type\_check](#jc.utils.streaming_line_input_type_check) + * [timestamp](#jc.utils.timestamp) + * [\_\_init\_\_](#jc.utils.timestamp.__init__) + + + +# jc.utils -# utils jc - JSON CLI output utility utils -## warning_message + + +### warning\_message + ```python -warning_message(message_lines) +def warning_message(message_lines: List[str]) -> None ``` Prints warning message for non-fatal issues. The first line is @@ -19,10 +42,12 @@ Returns: None - just prints output to STDERR + + +### error\_message -## error_message ```python -error_message(message_lines) +def error_message(message_lines: List[str]) -> None ``` Prints an error message for fatal issues. The first line is @@ -37,10 +62,12 @@ Returns: None - just prints output to STDERR + + +### compatibility -## compatibility ```python -compatibility(mod_name, compatible, quiet=False) +def compatibility(mod_name: str, compatible: List, quiet: Optional[bool] = False) -> None ``` Checks for the parser's compatibility with the running OS @@ -60,10 +87,12 @@ Returns: None - just prints output to STDERR + + +### has\_data -## has_data ```python -has_data(data) +def has_data(data: str) -> bool ``` Checks if the input contains data. If there are any non-whitespace @@ -78,10 +107,12 @@ Returns: Boolean True if input string (data) contains non-whitespace characters, otherwise False + + +### convert\_to\_int -## convert_to_int ```python -convert_to_int(value) +def convert_to_int(value: Union[str, float]) -> Union[int, None] ``` Converts string and float input to int. Strips all non-numeric @@ -89,16 +120,18 @@ characters from strings. Parameters: - value: (string/integer/float) Input value + value: (string/float) Input value Returns: integer/None Integer if successful conversion, otherwise None + + +### convert\_to\_float -## convert_to_float ```python -convert_to_float(value) +def convert_to_float(value: Union[str, int]) -> Union[float, None] ``` Converts string and int input to float. Strips all non-numeric @@ -106,16 +139,18 @@ characters from strings. Parameters: - value: (string) Input value + value: (string/integer) Input value Returns: float/None Float if successful conversion, otherwise None + + +### convert\_to\_bool -## convert_to_bool ```python -convert_to_bool(value) +def convert_to_bool(value: Union[str, int, float]) -> bool ``` Converts string, integer, or float input to boolean by checking @@ -130,43 +165,72 @@ Returns: True/False False unless a 'truthy' number or string is found ('y', 'yes', 'true', '1', 1, -1, etc.) + + +### stream\_success -## stream_success ```python -stream_success(output_line, ignore_exceptions) +def stream_success(output_line: Dict, ignore_exceptions: bool) -> Dict ``` + Add `_jc_meta` object to output line if `ignore_exceptions=True` -## stream_error + + +### stream\_error + ```python -stream_error(e, ignore_exceptions, line) +def stream_error(e: BaseException, ignore_exceptions: bool, line: str) -> Dict ``` Reraise the stream exception with annotation or print an error `_jc_meta` field if `ignore_exceptions=True`. + + +### input\_type\_check -## input_type_check ```python -input_type_check(data) +def input_type_check(data: str) -> None ``` -Ensure input data is a string -## streaming_input_type_check +Ensure input data is a string. Raises `TypeError` if not. + + + +### streaming\_input\_type\_check + ```python -streaming_input_type_check(data) +def streaming_input_type_check(data: Iterable) -> None ``` -Ensure input data is an iterable, but not a string or bytes -## streaming_line_input_type_check +Ensure input data is an iterable, but not a string or bytes. Raises +`TypeError` if not. + + + +### streaming\_line\_input\_type\_check + ```python -streaming_line_input_type_check(line) +def streaming_line_input_type_check(line: str) -> None ``` -Ensure each line is a string -## timestamp +Ensure each line is a string. Raises `TypeError` if not. + + + +### timestamp Objects + ```python -timestamp(datetime_string) +class timestamp() +``` + + + +### \_\_init\_\_ + +```python +def __init__(datetime_string: str) -> None ``` Input a date-time text string of several formats and convert to a @@ -179,16 +243,16 @@ Parameters: Attributes: - string (str) the input datetime string + string (str) the input datetime string - format (int) the format rule that was used to - decode the datetime string. None if - conversion fails + format (int) the format rule that was used to + decode the datetime string. None if + conversion fails - naive (int) timestamp based on locally configured - timezone. None if conversion fails + naive (int) timestamp based on locally configured + timezone. None if conversion fails - utc (int) aware timestamp only if UTC timezone - detected in datetime string. None if - conversion fails + utc (int) aware timestamp only if UTC timezone + detected in datetime string. None if + conversion fails diff --git a/jc/__init__.py b/jc/__init__.py index 0579852b..d5a02709 100644 --- a/jc/__init__.py +++ b/jc/__init__.py @@ -53,21 +53,29 @@ modules directly: Use `help(jc.lib)` for details: - parse(parser_module_name: str, data: str | iterable) + parse(parser_module_name: str, data: str | Iterable) + -> dict | list[dict] | Iterable[dict] High-level API to easily access the parser. This API will find both built-in parsers and local plugin parsers. - get_help(parser_module_name: str) + parser_info(parser_module_name: str) -> dict + Get the metadata for a particular parser. + + all_parser_info() -> list[dict] + Get the metadata for all parsers. + + get_help(parser_module_name: str) -> None Convenience function to display the help screen for a parser using its module name. - parser_mod_list() + parser_mod_list() -> list Get a list of all available parser module names to be used in - parse() and get_help(). + parse(), parser_info(), and get_help(). - plugin_parser_mod_list() - Get a list of plugin parser module names. This list is a subset of + plugin_parser_mod_list() -> list + Get a list of plugin parser module names to be used in + parse(), parser_info(), and get_help(). This list is a subset of parser_mod_list(). """ -from .lib import (__version__, parse, parser_mod_list, - plugin_parser_mod_list, get_help) +from .lib import (__version__, parse, parser_mod_list, plugin_parser_mod_list, + parser_info, all_parser_info, get_help) diff --git a/jc/cli.py b/jc/cli.py index 9798f7a8..20425df1 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -10,7 +10,8 @@ import signal import shlex import subprocess import json -from .lib import __version__, parsers, local_parsers +from .lib import (__version__, all_parser_info, parsers, + _parser_argument, _get_parser) from . import utils from . import tracebackplus from .exceptions import LibraryNotInstalled, ParseError @@ -147,29 +148,12 @@ def parser_shortname(parser_arg): return parser_arg[2:] -def parser_argument(parser): - """Return short name of the parser with dashes and with -- prefix""" - return f'--{parser}' - - -def parser_mod_shortname(parser): - """Return short name of the parser's module name (no -- prefix and dashes converted to underscores)""" - return parser.replace('--', '').replace('-', '_') - - -def parser_module(parser): - """Import the module just in time and return the module object""" - shortname = parser_mod_shortname(parser) - path = ('jcparsers.' if shortname in local_parsers else 'jc.parsers.') - return importlib.import_module(path + shortname) - - def parsers_text(indent=0, pad=0): """Return the argument and description information from each parser""" ptext = '' for parser in parsers: - parser_arg = parser_argument(parser) - parser_mod = parser_module(parser) + parser_arg = _parser_argument(parser) + parser_mod = _get_parser(parser) if hasattr(parser_mod, 'info'): parser_desc = parser_mod.info.description @@ -184,23 +168,6 @@ def parsers_text(indent=0, pad=0): def about_jc(): """Return jc info and the contents of each parser.info as a dictionary""" - parser_list = [] - - for parser in parsers: - parser_mod = parser_module(parser) - - if hasattr(parser_mod, 'info'): - info_dict = {} - info_dict['name'] = parser_mod.__name__.split('.')[-1] - info_dict['argument'] = parser_argument(parser) - parser_entry = vars(parser_mod.info) - - for k, v in parser_entry.items(): - if not k.startswith('__'): - info_dict[k] = v - - parser_list.append(info_dict) - return { 'name': 'jc', 'version': info.version, @@ -210,8 +177,8 @@ def about_jc(): 'website': info.website, 'copyright': info.copyright, 'license': info.license, - 'parser_count': len(parser_list), - 'parsers': parser_list + 'parser_count': len(all_parser_info()), + 'parsers': all_parser_info() } @@ -264,8 +231,7 @@ def help_doc(options): parser_name = parser_shortname(arg) if parser_name in parsers: - # load parser module just in time so we don't need to load all modules - parser = parser_module(arg) + parser = _get_parser(arg) compatible = ', '.join(parser.info.compatible) doc_text = \ f'{parser.__doc__}\n'\ @@ -491,7 +457,7 @@ def main(): # find the correct parser if magic_found_parser: - parser = parser_module(magic_found_parser) + parser = _get_parser(magic_found_parser) parser_name = parser_shortname(magic_found_parser) else: @@ -500,7 +466,7 @@ def main(): parser_name = parser_shortname(arg) if parser_name in parsers: - parser = parser_module(arg) + parser = _get_parser(arg) found = True break @@ -553,6 +519,7 @@ def main(): utils.error_message([f'Parser issue with {parser_name}:', f'{e.__class__.__name__}: {e}', + 'If this is the correct parser, try setting the locale to C (LANG=C).', 'For details use the -d or -dd option. Use "jc -h" for help.']) sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT)) @@ -573,8 +540,9 @@ def main(): streaming_msg = 'Use the -qq option to ignore streaming parser errors.' utils.error_message([ - f'{parser_name} parser could not parse the input data. Did you use the correct parser?', + f'{parser_name} parser could not parse the input data.', f'{streaming_msg}', + 'If this is the correct parser, try setting the locale to C (LANG=C).', 'For details use the -d or -dd option. Use "jc -h" for help.' ]) sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT)) diff --git a/jc/lib.py b/jc/lib.py index 917a80b2..ab6b6b38 100644 --- a/jc/lib.py +++ b/jc/lib.py @@ -6,9 +6,10 @@ import sys import os import re import importlib +from typing import Dict, List, Iterable, Union, Iterator, Optional from jc import appdirs -__version__ = '1.18.1' +__version__ = '1.18.2' parsers = [ 'acpi', @@ -98,6 +99,14 @@ parsers = [ 'zipinfo' ] +def _cliname_to_modname(parser_cli_name): + """Return real module name (dashes converted to underscores)""" + return parser_cli_name.replace('--', '').replace('-', '_') + +def _modname_to_cliname(parser_mod_name): + """Return module's cli name (underscores converted to dashes)""" + return parser_mod_name.replace('_', '-') + # Create the local_parsers list. This is a list of custom or # override parsers from /jc/jcparsers/*.py. # Once this list is created, extend the parsers list with it. @@ -109,31 +118,36 @@ if os.path.isdir(local_parsers_dir): for name in os.listdir(local_parsers_dir): if re.match(r'\w+\.py$', name) and os.path.isfile(os.path.join(local_parsers_dir, name)): plugin_name = name[0:-3] - local_parsers.append(plugin_name) + local_parsers.append(_modname_to_cliname(plugin_name)) if plugin_name not in parsers: - parsers.append(plugin_name) + parsers.append(_modname_to_cliname(plugin_name)) try: del name except Exception: pass - -def _cliname_to_modname(parser_cli_name): - """Return real module name (dashes converted to underscores)""" - return parser_cli_name.replace('-', '_') - -def _modname_to_cliname(parser_mod_name): - """Return module's cli name (underscores converted to dashes)""" - return parser_mod_name.replace('_', '-') +def _parser_argument(parser_mod_name): + """Return short name of the parser with dashes and with -- prefix""" + parser = _modname_to_cliname(parser_mod_name) + return f'--{parser}' def _get_parser(parser_mod_name): """Return the parser module object""" + # ensure parser_mod_name is a true module name and not a cli name + parser_mod_name = _cliname_to_modname(parser_mod_name) + parser_cli_name = _modname_to_cliname(parser_mod_name) modpath = 'jcparsers.' if parser_cli_name in local_parsers else 'jc.parsers.' return importlib.import_module(f'{modpath}{parser_mod_name}') -def parse(parser_mod_name, data, - quiet=False, raw=False, ignore_exceptions=None, **kwargs): +def parse( + parser_mod_name: str, + data: Union[str, Iterable[str]], + quiet: bool = False, + raw: bool = False, + ignore_exceptions: bool = None, + **kwargs +) -> Union[Dict, List[Dict], Iterator[Dict]]: """ Parse the string data using the supplied parser module. @@ -170,7 +184,10 @@ def parse(parser_mod_name, data, Parameters: - parser_mod_name: (string) name of the parser module + parser_mod_name: (string) name of the parser module. This + function will accept module_name, + cli-name, and --argument-name + variants of the module name. data: (string or data to parse (string for normal iterator) parsers, iterator of strings for @@ -196,17 +213,57 @@ def parse(parser_mod_name, data, return jc_parser.parse(data, quiet=quiet, raw=raw, **kwargs) -def parser_mod_list(): +def parser_mod_list() -> List[str]: """Returns a list of all available parser module names.""" return [_cliname_to_modname(p) for p in parsers] -def plugin_parser_mod_list(): +def plugin_parser_mod_list() -> List[str]: """ Returns a list of plugin parser module names. This function is a subset of `parser_mod_list()`. """ return [_cliname_to_modname(p) for p in local_parsers] -def get_help(parser_mod_name): - """Show help screen for the selected parser.""" +def parser_info(parser_mod_name: str) -> Union[Dict, None]: + """ + Returns a dictionary that includes the module metadata. + + This function will accept **module_name**, **cli-name**, and + **--argument-name** variants of the module name string. + """ + # ensure parser_mod_name is a true module name and not a cli name + parser_mod_name = _cliname_to_modname(parser_mod_name) + + parser_mod = _get_parser(parser_mod_name) + + if hasattr(parser_mod, 'info'): + info_dict: Dict = {} + info_dict['name'] = parser_mod_name + info_dict['argument'] = _parser_argument(parser_mod_name) + parser_entry = vars(parser_mod.info) + + for k, v in parser_entry.items(): + if not k.startswith('__'): + info_dict[k] = v + + if _modname_to_cliname(parser_mod_name) in local_parsers: + info_dict['plugin'] = True + + return info_dict + + return None + +def all_parser_info() -> List[Optional[Dict]]: + """ + Returns a list of dictionaris that includes metadata for all modules. + """ + return [parser_info(_cliname_to_modname(p)) for p in parsers] + +def get_help(parser_mod_name: str) -> None: + """ + Show help screen for the selected parser. + + This function will accept **module_name**, **cli-name**, and + **--argument-name** variants of the module name string. + """ help(_get_parser(parser_mod_name)) diff --git a/jc/parsers/foo.py b/jc/parsers/foo.py index 2743c05f..bd077f3f 100644 --- a/jc/parsers/foo.py +++ b/jc/parsers/foo.py @@ -39,6 +39,7 @@ Examples: [] """ import jc.utils +from typing import List, Dict class info(): @@ -57,7 +58,7 @@ class info(): __version__ = info.version -def _process(proc_data): +def _process(proc_data: List[Dict]) -> List[Dict]: """ Final processing to conform to the schema. @@ -78,7 +79,11 @@ def _process(proc_data): return proc_data -def parse(data, raw=False, quiet=False): +def parse( + data: str, + raw: bool = False, + quiet: bool = False +) -> List[Dict]: """ Main text parsing function @@ -95,7 +100,7 @@ def parse(data, raw=False, quiet=False): jc.utils.compatibility(__name__, info.compatible, quiet) jc.utils.input_type_check(data) - raw_output = [] + raw_output: List = [] if jc.utils.has_data(data): diff --git a/jc/parsers/foo_s.py b/jc/parsers/foo_s.py index 9b29e337..44e0ee31 100644 --- a/jc/parsers/foo_s.py +++ b/jc/parsers/foo_s.py @@ -49,6 +49,7 @@ Examples: {example output} ... """ +from typing import Dict, Iterable import jc.utils from jc.utils import stream_success, stream_error from jc.exceptions import ParseError @@ -69,7 +70,7 @@ class info(): __version__ = info.version -def _process(proc_data): +def _process(proc_data: Dict) -> Dict: """ Final processing to conform to the schema. @@ -90,7 +91,12 @@ def _process(proc_data): return proc_data -def parse(data, raw=False, quiet=False, ignore_exceptions=False): +def parse( + data: Iterable[str], + raw: bool = False, + quiet: bool = False, + ignore_exceptions: bool = False +) -> Iterable[Dict]: """ Main text parsing generator function. Returns an iterator object. @@ -115,7 +121,7 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False): jc.utils.streaming_input_type_check(data) for line in data: - output_line = {} + output_line: Dict = {} try: jc.utils.streaming_line_input_type_check(line) diff --git a/jc/parsers/universal.py b/jc/parsers/universal.py index 9d1bfa64..22bf2705 100644 --- a/jc/parsers/universal.py +++ b/jc/parsers/universal.py @@ -2,9 +2,10 @@ import string +from typing import List, Dict, Optional -def simple_table_parse(data): +def simple_table_parse(data: List[str]) -> List[Dict]: """ Parse simple tables. The last column may contain data with spaces. @@ -32,7 +33,7 @@ def simple_table_parse(data): return raw_output -def sparse_table_parse(data, delim='\u2063'): +def sparse_table_parse(data: List[str], delim: Optional[str] ='\u2063') -> List[Dict]: """ Parse tables with missing column data or with spaces in column data. diff --git a/jc/utils.py b/jc/utils.py index b0a467ae..75b1bdf9 100644 --- a/jc/utils.py +++ b/jc/utils.py @@ -5,9 +5,10 @@ import locale import shutil from datetime import datetime, timezone from textwrap import TextWrapper +from typing import Dict, Iterable, List, Union, Optional -def warning_message(message_lines): +def warning_message(message_lines: List[str]) -> None: """ Prints warning message for non-fatal issues. The first line is prepended with 'jc: Warning - ' and subsequent lines are indented. @@ -43,7 +44,7 @@ def warning_message(message_lines): print(message, file=sys.stderr) -def error_message(message_lines): +def error_message(message_lines: List[str]) -> None: """ Prints an error message for fatal issues. The first line is prepended with 'jc: Error - ' and subsequent lines are indented. @@ -75,7 +76,7 @@ def error_message(message_lines): print(message, file=sys.stderr) -def compatibility(mod_name, compatible, quiet=False): +def compatibility(mod_name: str, compatible: List, quiet: Optional[bool] = False) -> None: """ Checks for the parser's compatibility with the running OS platform. @@ -109,7 +110,7 @@ def compatibility(mod_name, compatible, quiet=False): f'Compatible platforms: {compat_list}']) -def has_data(data): +def has_data(data: str) -> bool: """ Checks if the input contains data. If there are any non-whitespace characters then return True, else return False. @@ -126,14 +127,14 @@ def has_data(data): return bool(data and not data.isspace()) -def convert_to_int(value): +def convert_to_int(value: Union[str, float]) -> Union[int, None]: """ Converts string and float input to int. Strips all non-numeric characters from strings. Parameters: - value: (string/integer/float) Input value + value: (string/float) Input value Returns: @@ -156,14 +157,14 @@ def convert_to_int(value): return None -def convert_to_float(value): +def convert_to_float(value: Union[str, int]) -> Union[float, None]: """ Converts string and int input to float. Strips all non-numeric characters from strings. Parameters: - value: (string) Input value + value: (string/integer) Input value Returns: @@ -182,7 +183,7 @@ def convert_to_float(value): return None -def convert_to_bool(value): +def convert_to_bool(value: Union[str, int, float]) -> bool: """ Converts string, integer, or float input to boolean by checking for 'truthy' values. @@ -220,7 +221,7 @@ def convert_to_bool(value): return False -def stream_success(output_line, ignore_exceptions): +def stream_success(output_line: Dict, ignore_exceptions: bool) -> Dict: """Add `_jc_meta` object to output line if `ignore_exceptions=True`""" if ignore_exceptions: output_line.update({'_jc_meta': {'success': True}}) @@ -228,7 +229,7 @@ def stream_success(output_line, ignore_exceptions): return output_line -def stream_error(e, ignore_exceptions, line): +def stream_error(e: BaseException, ignore_exceptions: bool, line: str) -> Dict: """ Reraise the stream exception with annotation or print an error `_jc_meta` field if `ignore_exceptions=True`. @@ -247,51 +248,53 @@ def stream_error(e, ignore_exceptions, line): } -def input_type_check(data): - """Ensure input data is a string""" +def input_type_check(data: str) -> None: + """Ensure input data is a string. Raises `TypeError` if not.""" if not isinstance(data, str): raise TypeError("Input data must be a 'str' object.") -def streaming_input_type_check(data): - """Ensure input data is an iterable, but not a string or bytes""" +def streaming_input_type_check(data: Iterable) -> None: + """ + Ensure input data is an iterable, but not a string or bytes. Raises + `TypeError` if not. + """ if not hasattr(data, '__iter__') or isinstance(data, (str, bytes)): raise TypeError("Input data must be a non-string iterable object.") -def streaming_line_input_type_check(line): - """Ensure each line is a string""" +def streaming_line_input_type_check(line: str) -> None: + """Ensure each line is a string. Raises `TypeError` if not.""" if not isinstance(line, str): raise TypeError("Input line must be a 'str' object.") class timestamp: - """ - Input a date-time text string of several formats and convert to a - naive or timezone-aware epoch timestamp in UTC. + def __init__(self, datetime_string: str) -> None: + """ + Input a date-time text string of several formats and convert to a + naive or timezone-aware epoch timestamp in UTC. - Parameters: + Parameters: - datetime_string: (str) a string representation of a - date-time in several supported formats + datetime_string: (str) a string representation of a + date-time in several supported formats - Attributes: + Attributes: - string (str) the input datetime string + string (str) the input datetime string - format (int) the format rule that was used to - decode the datetime string. None if - conversion fails + format (int) the format rule that was used to + decode the datetime string. None if + conversion fails - naive (int) timestamp based on locally configured - timezone. None if conversion fails + naive (int) timestamp based on locally configured + timezone. None if conversion fails - utc (int) aware timestamp only if UTC timezone - detected in datetime string. None if - conversion fails - """ - - def __init__(self, datetime_string): + utc (int) aware timestamp only if UTC timezone + detected in datetime string. None if + conversion fails + """ self.string = datetime_string dt = self._parse() self.format = dt['format'] @@ -395,28 +398,33 @@ class timestamp: # from https://www.timeanddate.com/time/zones/ # only removed UTC timezone and added known non-UTC offsets - tz_abbr = ['A', 'ACDT', 'ACST', 'ACT', 'ACWST', 'ADT', 'AEDT', 'AEST', 'AET', 'AFT', 'AKDT', 'AKST', 'ALMT', - 'AMST', 'AMT', 'ANAST', 'ANAT', 'AQTT', 'ART', 'AST', 'AT', 'AWDT', 'AWST', 'AZOST', 'AZOT', - 'AZST', 'AZT', 'AoE', 'B', 'BNT', 'BOT', 'BRST', 'BRT', 'BST', 'BTT', 'C', 'CAST', 'CAT', 'CCT', - 'CDT', 'CEST', 'CET', 'CHADT', 'CHAST', 'CHOST', 'CHOT', 'CHUT', 'CIDST', 'CIST', 'CKT', 'CLST', - 'CLT', 'COT', 'CST', 'CT', 'CVT', 'CXT', 'ChST', 'D', 'DAVT', 'DDUT', 'E', 'EASST', 'EAST', - 'EAT', 'ECT', 'EDT', 'EEST', 'EET', 'EGST', 'EGT', 'EST', 'ET', 'F', 'FET', 'FJST', 'FJT', 'FKST', - 'FKT', 'FNT', 'G', 'GALT', 'GAMT', 'GET', 'GFT', 'GILT', 'GMT', 'GST', 'GYT', 'H', 'HDT', 'HKT', - 'HOVST', 'HOVT', 'HST', 'I', 'ICT', 'IDT', 'IOT', 'IRDT', 'IRKST', 'IRKT', 'IRST', 'IST', 'JST', - 'K', 'KGT', 'KOST', 'KRAST', 'KRAT', 'KST', 'KUYT', 'L', 'LHDT', 'LHST', 'LINT', 'M', 'MAGST', - 'MAGT', 'MART', 'MAWT', 'MDT', 'MHT', 'MMT', 'MSD', 'MSK', 'MST', 'MT', 'MUT', 'MVT', 'MYT', 'N', - 'NCT', 'NDT', 'NFDT', 'NFT', 'NOVST', 'NOVT', 'NPT', 'NRT', 'NST', 'NUT', 'NZDT', 'NZST', 'O', - 'OMSST', 'OMST', 'ORAT', 'P', 'PDT', 'PET', 'PETST', 'PETT', 'PGT', 'PHOT', 'PHT', 'PKT', 'PMDT', - 'PMST', 'PONT', 'PST', 'PT', 'PWT', 'PYST', 'PYT', 'Q', 'QYZT', 'R', 'RET', 'ROTT', 'S', 'SAKT', - 'SAMT', 'SAST', 'SBT', 'SCT', 'SGT', 'SRET', 'SRT', 'SST', 'SYOT', 'T', 'TAHT', 'TFT', 'TJT', 'TKT', - 'TLT', 'TMT', 'TOST', 'TOT', 'TRT', 'TVT', 'U', 'ULAST', 'ULAT', 'UYST', 'UYT', 'UZT', 'V', 'VET', - 'VLAST', 'VLAT', 'VOST', 'VUT', 'W', 'WAKT', 'WARST', 'WAST', 'WAT', 'WEST', 'WET', 'WFT', 'WGST', - 'WGT', 'WIB', 'WIT', 'WITA', 'WST', 'WT', 'X', 'Y', 'YAKST', 'YAKT', 'YAPT', 'YEKST', 'YEKT', 'Z', - 'UTC-1200', 'UTC-1100', 'UTC-1000', 'UTC-0930', 'UTC-0900', 'UTC-0800', 'UTC-0700', 'UTC-0600', - 'UTC-0500', 'UTC-0400', 'UTC-0300', 'UTC-0230', 'UTC-0200', 'UTC-0100', 'UTC+0100', 'UTC+0200', - 'UTC+0300', 'UTC+0400', 'UTC+0430', 'UTC+0500', 'UTC+0530', 'UTC+0545', 'UTC+0600', 'UTC+0630', - 'UTC+0700', 'UTC+0800', 'UTC+0845', 'UTC+0900', 'UTC+1000', 'UTC+1030', 'UTC+1100', 'UTC+1200', - 'UTC+1300', 'UTC+1345', 'UTC+1400'] + tz_abbr = [ + 'A', 'ACDT', 'ACST', 'ACT', 'ACWST', 'ADT', 'AEDT', 'AEST', 'AET', 'AFT', 'AKDT', + 'AKST', 'ALMT', 'AMST', 'AMT', 'ANAST', 'ANAT', 'AQTT', 'ART', 'AST', 'AT', 'AWDT', + 'AWST', 'AZOST', 'AZOT', 'AZST', 'AZT', 'AoE', 'B', 'BNT', 'BOT', 'BRST', 'BRT', 'BST', + 'BTT', 'C', 'CAST', 'CAT', 'CCT', 'CDT', 'CEST', 'CET', 'CHADT', 'CHAST', 'CHOST', + 'CHOT', 'CHUT', 'CIDST', 'CIST', 'CKT', 'CLST', 'CLT', 'COT', 'CST', 'CT', 'CVT', 'CXT', + 'ChST', 'D', 'DAVT', 'DDUT', 'E', 'EASST', 'EAST', 'EAT', 'ECT', 'EDT', 'EEST', 'EET', + 'EGST', 'EGT', 'EST', 'ET', 'F', 'FET', 'FJST', 'FJT', 'FKST', 'FKT', 'FNT', 'G', + 'GALT', 'GAMT', 'GET', 'GFT', 'GILT', 'GMT', 'GST', 'GYT', 'H', 'HDT', 'HKT', 'HOVST', + 'HOVT', 'HST', 'I', 'ICT', 'IDT', 'IOT', 'IRDT', 'IRKST', 'IRKT', 'IRST', 'IST', 'JST', + 'K', 'KGT', 'KOST', 'KRAST', 'KRAT', 'KST', 'KUYT', 'L', 'LHDT', 'LHST', 'LINT', 'M', + 'MAGST', 'MAGT', 'MART', 'MAWT', 'MDT', 'MHT', 'MMT', 'MSD', 'MSK', 'MST', 'MT', 'MUT', + 'MVT', 'MYT', 'N', 'NCT', 'NDT', 'NFDT', 'NFT', 'NOVST', 'NOVT', 'NPT', 'NRT', 'NST', + 'NUT', 'NZDT', 'NZST', 'O', 'OMSST', 'OMST', 'ORAT', 'P', 'PDT', 'PET', 'PETST', 'PETT', + 'PGT', 'PHOT', 'PHT', 'PKT', 'PMDT', 'PMST', 'PONT', 'PST', 'PT', 'PWT', 'PYST', 'PYT', + 'Q', 'QYZT', 'R', 'RET', 'ROTT', 'S', 'SAKT', 'SAMT', 'SAST', 'SBT', 'SCT', 'SGT', + 'SRET', 'SRT', 'SST', 'SYOT', 'T', 'TAHT', 'TFT', 'TJT', 'TKT', 'TLT', 'TMT', 'TOST', + 'TOT', 'TRT', 'TVT', 'U', 'ULAST', 'ULAT', 'UYST', 'UYT', 'UZT', 'V', 'VET', 'VLAST', + 'VLAT', 'VOST', 'VUT', 'W', 'WAKT', 'WARST', 'WAST', 'WAT', 'WEST', 'WET', 'WFT', + 'WGST', 'WGT', 'WIB', 'WIT', 'WITA', 'WST', 'WT', 'X', 'Y', 'YAKST', 'YAKT', 'YAPT', + 'YEKST', 'YEKT', 'Z', 'UTC-1200', 'UTC-1100', 'UTC-1000', 'UTC-0930', 'UTC-0900', + 'UTC-0800', 'UTC-0700', 'UTC-0600', 'UTC-0500', 'UTC-0400', 'UTC-0300', 'UTC-0230', + 'UTC-0200', 'UTC-0100', 'UTC+0100', 'UTC+0200', 'UTC+0300', 'UTC+0400', 'UTC+0430', + 'UTC+0500', 'UTC+0530', 'UTC+0545', 'UTC+0600', 'UTC+0630', 'UTC+0700', 'UTC+0800', + 'UTC+0845', 'UTC+0900', 'UTC+1000', 'UTC+1030', 'UTC+1100', 'UTC+1200', 'UTC+1300', + 'UTC+1345', 'UTC+1400' + ] # normalize the timezone by taking out any timezone reference, except UTC cleandata = data.replace('(', '').replace(')', '') diff --git a/man/jc.1 b/man/jc.1 index c2b3b944..f7bf3bf4 100644 --- a/man/jc.1 +++ b/man/jc.1 @@ -1,4 +1,4 @@ -.TH jc 1 2022-01-23 1.18.1 "JSON CLI output utility" +.TH jc 1 2022-01-27 1.18.2 "JSON CLI output utility" .SH NAME jc \- JSONifies the output of many CLI tools and file-types .SH SYNOPSIS diff --git a/mangen.py b/mangen.py index ed2629ab..adda2da5 100755 --- a/mangen.py +++ b/mangen.py @@ -1,9 +1,6 @@ #!/usr/bin/env python3 # Genereate man page from jc metadata using jinja2 templates from datetime import date -import os -import gzip -import shutil import jc.cli from jinja2 import Environment, FileSystemLoader diff --git a/runtests.sh b/runtests.sh index d0a7ab96..b6f62a72 100755 --- a/runtests.sh +++ b/runtests.sh @@ -1,4 +1,5 @@ #!/bin/bash # system should be in "America/Los_Angeles" timezone for all tests to pass +# ensure no local plugin parsers are installed for all tests to pass python3 -m unittest -v diff --git a/setup.py b/setup.py index 7c443230..73eb28e5 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open('README.md', 'r') as f: setuptools.setup( name='jc', - version='1.18.1', + version='1.18.2', author='Kelly Brazil', author_email='kellyjonbrazil@gmail.com', description='Converts the output of popular command-line tools and file-types to JSON.', diff --git a/templates/readme_template b/templates/readme_template index 86e6e009..cb71e2c8 100644 --- a/templates/readme_template +++ b/templates/readme_template @@ -1,7 +1,7 @@ ![Tests](https://github.com/kellyjonbrazil/jc/workflows/Tests/badge.svg?branch=master) ![Pypi](https://img.shields.io/pypi/v/jc.svg) -> `jc` was just featured in the [Console Open Source Newsletter](https://console.substack.com/p/console-89) +> `jc` was recently featured in the [Console Open Source Newsletter](https://console.substack.com/p/console-89) > Check out the `jc` Python [package documentation](https://github.com/kellyjonbrazil/jc/tree/master/docs) for developers diff --git a/tests/test_lib.py b/tests/test_lib.py index 2714b811..a33a5ae9 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -34,6 +34,25 @@ class MyTests(unittest.TestCase): def test_lib_parser_mod_list_length(self): self.assertGreaterEqual(len(jc.lib.parser_mod_list()), 80) + def test_lib_parser_info_is_dict(self): + self.assertIsInstance(jc.lib.parser_info('csv'), dict) + + def test_lib_parser_info_csv(self): + self.assertTrue(jc.lib.parser_info('csv')['name'] == 'csv') + + def test_lib_all_parser_info_is_list_of_dicts(self): + self.assertIsInstance(jc.lib.all_parser_info(), list) + self.assertIsInstance(jc.lib.all_parser_info()[0], dict) + + def test_lib_all_parser_info_contains_csv(self): + p_list = [] + for p in jc.lib.all_parser_info(): + p_list.append(p['name']) + self.assertTrue('csv' in p_list) + + def test_lib_all_parser_info_length(self): + self.assertGreaterEqual(len(jc.lib.all_parser_info()), 80) + def test_lib_plugin_parser_mod_list_is_list(self): self.assertIsInstance(jc.lib.plugin_parser_mod_list(), list) @@ -44,6 +63,9 @@ class MyTests(unittest.TestCase): def test_lib_cliname_to_modname(self): self.assertEqual(jc.lib._cliname_to_modname('module-name'), 'module_name') + def test_lib_argumentname_to_modname(self): + self.assertEqual(jc.lib._cliname_to_modname('--module-name'), 'module_name') + def test_lib_modname_to_cliname(self): self.assertEqual(jc.lib._modname_to_cliname('module_name'), 'module-name') diff --git a/updatedocs.sh b/updatedocs.sh index 6294c837..a3e4e564 100755 --- a/updatedocs.sh +++ b/updatedocs.sh @@ -3,7 +3,9 @@ echo === Building README.md ./readmegen.py && echo "+++ README.md build successful" || echo "--- README.md build failed" + echo === Building man page ./mangen.py && echo "+++ man page build successful" || echo "--- man page build failed" + echo === Building documentation ./docgen.sh && echo "+++ documentation build successful" || echo "--- documentation build failed"