1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-21 00:19:42 +02:00

try new markdown conversion

This commit is contained in:
Kelly Brazil
2022-01-25 17:07:47 -08:00
parent 6fad44e35d
commit 75cd84ce8a
94 changed files with 11007 additions and 9665 deletions

View File

@ -236,6 +236,8 @@ option.
- `--xml` enables the XML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/xml))
- `--yaml` enables the YAML file parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/yaml))
- `--zipinfo` enables the `zipinfo` command parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/zipinfo))
- `--testing-two` enables the test parser 2 ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/testing_two))
- `--testing` enables the test parser ([documentation](https://kellyjonbrazil.github.io/jc/docs/parsers/testing))
### Options
- `-a` about `jc`. Prints information about `jc` and the parsers (in JSON, of

View File

@ -4,16 +4,16 @@
cd jc
echo Building docs for: package
pydocmd simple jc+ > ../docs/readme.md
pydoc-markdown -m jc > ../docs/readme.md
echo Building docs for: lib
pydocmd simple lib+ > ../docs/lib.md
pydoc-markdown -m jc.lib > ../docs/lib.md
echo Building docs for: utils
pydocmd simple utils+ > ../docs/utils.md
pydoc-markdown -m jc.utils > ../docs/utils.md
echo Building docs for: universal parser
pydocmd simple jc.parsers.universal+ > ../docs/parsers/universal.md
pydoc-markdown -m jc.parsers.universal > ../docs/parsers/universal.md
# a bit of inception here... jc is being used to help
# automate the generation of its own documentation. :)
@ -23,7 +23,7 @@ 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[@]}"
@ -36,7 +36,7 @@ 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
pydoc-markdown -m jc.parsers."${parser_name}" >> ../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

44
docgen.sh.old Executable file
View File

@ -0,0 +1,44 @@
#!/bin/bash
# Generate docs.md
# requires pydoc-markdown 2.1.0.post1
cd jc
echo Building docs for: package
pydocmd simple jc+ > ../docs/readme.md
echo Building docs for: lib
pydocmd simple lib+ > ../docs/lib.md
echo Building docs for: utils
pydocmd simple utils+ > ../docs/utils.md
echo Building docs for: universal parser
pydocmd simple jc.parsers.universal+ > ../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
parsers=()
while read -r value
do
parsers+=("$value")
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")
compatible=$(jq -r '.compatible | join(", ")' <<< "$parser")
version=$(jq -r '.version' <<< "$parser")
author=$(jq -r '.author' <<< "$parser")
author_email=$(jq -r '.author_email' <<< "$parser")
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
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
done

View File

@ -1,17 +1,18 @@
<a id="jc.lib"></a>
# jc.lib
# lib
jc - JSON CLI output utility
JC lib module
<a id="jc.lib.parse"></a>
#### 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: Optional[bool] = False, raw: Optional[bool] = False, ignore_exceptions: Optional[Union[None, bool]] = None, **kwargs: Any, ,) -> Union[Dict[str, Any],
List[Dict[str, Any]],
Iterator[Dict[str, Any]]]
```
Parse the string data using the supplied parser module.
@ -19,11 +20,12 @@ Parse the string data using the supplied parser module.
This function provides a high-level API to simplify parser use. This
function will call built-in parsers and custom plugin parsers.
Example:
**Example**:
>>> import jc
>>> jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022')
{'year': 2022, 'month': 'Jan', 'month_num': 1, 'day'...}
- `{'year'` - 2022, 'month': 'Jan', 'month_num': 1, 'day'...}
To get a list of available parser module names, use `parser_mod_list()`
or `plugin_parser_mod_list()`. `plugin_parser_mod_list()` is a subset
@ -47,44 +49,77 @@ parsers without this API:
>>> import my_custom_parser
>>> my_custom_parser.parse('command_data')
Parameters:
parser_mod_name: (string) name of the parser module
**Arguments**:
data: (string or data to parse (string for normal
- `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
streaming parsers)
raw: (boolean) output preprocessed JSON if True
- `raw` - (boolean) output preprocessed JSON if True
quiet: (boolean) suppress warning messages if True
- `quiet` - (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
(streaming parsers only)
Returns:
**Returns**:
Standard Parsers: Dictionary or List of Dictionaries
Streaming Parsers: Generator Object containing Dictionaries
<a id="jc.lib.parser_mod_list"></a>
#### 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
<a id="jc.lib.plugin_parser_mod_list"></a>
#### 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()`.
<a id="jc.lib.parser_info"></a>
#### parser\_info
## get_help
```python
get_help(parser_mod_name)
def parser_info(parser_mod_name: str) -> Dict[str, Any]
```
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.
<a id="jc.lib.get_help"></a>
#### 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.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.acpi"></a>
# jc.parsers.acpi
jc - JSON CLI output utility `acpi` command output parser
Usage (cli):
@ -60,89 +62,90 @@ Schema:
}
]
Examples:
**Examples**:
$ acpi -V | jc --acpi -p
[
{
"type": "Battery",
"id": 0,
"state": "Charging",
"charge_percent": 71,
"until_charged": "00:29:20",
"design_capacity_mah": 2110,
"last_full_capacity": 2271,
"last_full_capacity_percent": 100,
"until_charged_hours": 0,
"until_charged_minutes": 29,
"until_charged_seconds": 20,
"until_charged_total_seconds": 1760
- `"type"` - "Battery",
- `"id"` - 0,
- `"state"` - "Charging",
- `"charge_percent"` - 71,
- `"until_charged"` - "00:29:20",
- `"design_capacity_mah"` - 2110,
- `"last_full_capacity"` - 2271,
- `"last_full_capacity_percent"` - 100,
- `"until_charged_hours"` - 0,
- `"until_charged_minutes"` - 29,
- `"until_charged_seconds"` - 20,
- `"until_charged_total_seconds"` - 1760
},
{
"type": "Adapter",
"id": 0,
"on-line": true
- `"type"` - "Adapter",
- `"id"` - 0,
- `"on-line"` - true
},
{
"type": "Thermal",
"id": 0,
"mode": "ok",
"temperature": 46.0,
"temperature_unit": "C",
"trip_points": [
- `"type"` - "Thermal",
- `"id"` - 0,
- `"mode"` - "ok",
- `"temperature"` - 46.0,
- `"temperature_unit"` - "C",
- `"trip_points"` - [
{
"id": 0,
"switches_to_mode": "critical",
"temperature": 127.0,
"temperature_unit": "C"
- `"id"` - 0,
- `"switches_to_mode"` - "critical",
- `"temperature"` - 127.0,
- `"temperature_unit"` - "C"
},
{
"id": 1,
"switches_to_mode": "hot",
"temperature": 127.0,
"temperature_unit": "C"
- `"id"` - 1,
- `"switches_to_mode"` - "hot",
- `"temperature"` - 127.0,
- `"temperature_unit"` - "C"
}
]
},
{
"type": "Cooling",
"id": 0,
"messages": [
- `"type"` - "Cooling",
- `"id"` - 0,
- `"messages"` - [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 1,
"messages": [
- `"type"` - "Cooling",
- `"id"` - 1,
- `"messages"` - [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 2,
"messages": [
- `"type"` - "Cooling",
- `"id"` - 2,
- `"messages"` - [
"x86_pkg_temp no state information available"
]
},
{
"type": "Cooling",
"id": 3,
"messages": [
- `"type"` - "Cooling",
- `"id"` - 3,
- `"messages"` - [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": 4,
"messages": [
- `"type"` - "Cooling",
- `"id"` - 4,
- `"messages"` - [
"intel_powerclamp no state information available"
]
},
{
"type": "Cooling",
"id": 5,
"messages": [
- `"type"` - "Cooling",
- `"id"` - 5,
- `"messages"` - [
"Processor 0 of 10"
]
}
@ -151,106 +154,115 @@ Examples:
$ acpi -V | jc --acpi -p -r
[
{
"type": "Battery",
"id": "0",
"state": "Charging",
"charge_percent": "71",
"until_charged": "00:29:20",
"design_capacity_mah": "2110",
"last_full_capacity": "2271",
"last_full_capacity_percent": "100"
- `"type"` - "Battery",
- `"id"` - "0",
- `"state"` - "Charging",
- `"charge_percent"` - "71",
- `"until_charged"` - "00:29:20",
- `"design_capacity_mah"` - "2110",
- `"last_full_capacity"` - "2271",
- `"last_full_capacity_percent"` - "100"
},
{
"type": "Adapter",
"id": "0",
"on-line": true
- `"type"` - "Adapter",
- `"id"` - "0",
- `"on-line"` - true
},
{
"type": "Thermal",
"id": "0",
"mode": "ok",
"temperature": "46.0",
"temperature_unit": "C",
"trip_points": [
- `"type"` - "Thermal",
- `"id"` - "0",
- `"mode"` - "ok",
- `"temperature"` - "46.0",
- `"temperature_unit"` - "C",
- `"trip_points"` - [
{
"id": "0",
"switches_to_mode": "critical",
"temperature": "127.0",
"temperature_unit": "C"
- `"id"` - "0",
- `"switches_to_mode"` - "critical",
- `"temperature"` - "127.0",
- `"temperature_unit"` - "C"
},
{
"id": "1",
"switches_to_mode": "hot",
"temperature": "127.0",
"temperature_unit": "C"
- `"id"` - "1",
- `"switches_to_mode"` - "hot",
- `"temperature"` - "127.0",
- `"temperature_unit"` - "C"
}
]
},
{
"type": "Cooling",
"id": "0",
"messages": [
- `"type"` - "Cooling",
- `"id"` - "0",
- `"messages"` - [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "1",
"messages": [
- `"type"` - "Cooling",
- `"id"` - "1",
- `"messages"` - [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "2",
"messages": [
- `"type"` - "Cooling",
- `"id"` - "2",
- `"messages"` - [
"x86_pkg_temp no state information available"
]
},
{
"type": "Cooling",
"id": "3",
"messages": [
- `"type"` - "Cooling",
- `"id"` - "3",
- `"messages"` - [
"Processor 0 of 10"
]
},
{
"type": "Cooling",
"id": "4",
"messages": [
- `"type"` - "Cooling",
- `"id"` - "4",
- `"messages"` - [
"intel_powerclamp no state information available"
]
},
{
"type": "Cooling",
"id": "5",
"messages": [
- `"type"` - "Cooling",
- `"id"` - "5",
- `"messages"` - [
"Processor 0 of 10"
]
}
]
<a id="jc.parsers.acpi.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.acpi.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.airport"></a>
# 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`.
@ -43,67 +45,77 @@ Schema:
"channel": string
}
Examples:
**Examples**:
$ airport -I | jc --airport -p
{
"agrctlrssi": -66,
"agrextrssi": 0,
"agrctlnoise": -90,
"agrextnoise": 0,
"state": "running",
"op_mode": "station",
"lasttxrate": 195,
"maxrate": 867,
"lastassocstatus": 0,
"802_11_auth": "open",
"link_auth": "wpa2-psk",
"bssid": "3c:37:86:15:ad:f9",
"ssid": "SnazzleDazzle",
"mcs": 0,
"channel": "48,80"
- `"agrctlrssi"` - -66,
- `"agrextrssi"` - 0,
- `"agrctlnoise"` - -90,
- `"agrextnoise"` - 0,
- `"state"` - "running",
- `"op_mode"` - "station",
- `"lasttxrate"` - 195,
- `"maxrate"` - 867,
- `"lastassocstatus"` - 0,
- `"802_11_auth"` - "open",
- `"link_auth"` - "wpa2-psk",
- `"bssid"` - "3c:37:86:15:ad:f9",
- `"ssid"` - "SnazzleDazzle",
- `"mcs"` - 0,
- `"channel"` - "48,80"
}
$ airport -I | jc --airport -p -r
{
"agrctlrssi": "-66",
"agrextrssi": "0",
"agrctlnoise": "-90",
"agrextnoise": "0",
"state": "running",
"op_mode": "station",
"lasttxrate": "195",
"maxrate": "867",
"lastassocstatus": "0",
"802_11_auth": "open",
"link_auth": "wpa2-psk",
"bssid": "3c:37:86:15:ad:f9",
"ssid": "SnazzleDazzle",
"mcs": "0",
"channel": "48,80"
- `"agrctlrssi"` - "-66",
- `"agrextrssi"` - "0",
- `"agrctlnoise"` - "-90",
- `"agrextnoise"` - "0",
- `"state"` - "running",
- `"op_mode"` - "station",
- `"lasttxrate"` - "195",
- `"maxrate"` - "867",
- `"lastassocstatus"` - "0",
- `"802_11_auth"` - "open",
- `"link_auth"` - "wpa2-psk",
- `"bssid"` - "3c:37:86:15:ad:f9",
- `"ssid"` - "SnazzleDazzle",
- `"mcs"` - "0",
- `"channel"` - "48,80"
}
<a id="jc.parsers.airport.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.airport.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.airport_s"></a>
# 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`.
@ -39,40 +41,41 @@ Schema:
}
]
Examples:
**Examples**:
$ airport -s | jc --airport-s -p
[
{
"ssid": "DIRECT-4A-HP OfficeJet 3830",
"bssid": "00:67:eb:2a:a7:3b",
"rssi": -90,
"channel": "6",
"ht": true,
"cc": "--",
"security": [
- `"ssid"` - "DIRECT-4A-HP OfficeJet 3830",
- `"bssid"` - "00:67:eb:2a:a7:3b",
- `"rssi"` - -90,
- `"channel"` - "6",
- `"ht"` - true,
- `"cc"` - "--",
- `"security"` - [
"WPA2(PSK/AES/AES)"
]
},
{
"ssid": "Latitude38",
"bssid": "c0:ff:d5:d2:7a:f3",
"rssi": -85,
"channel": "11",
"ht": true,
"cc": "US",
"security": [
- `"ssid"` - "Latitude38",
- `"bssid"` - "c0:ff:d5:d2:7a:f3",
- `"rssi"` - -85,
- `"channel"` - "11",
- `"ht"` - true,
- `"cc"` - "US",
- `"security"` - [
"WPA2(PSK/AES/AES)"
]
},
{
"ssid": "xfinitywifi",
"bssid": "6e:e3:0e:b8:45:99",
"rssi": -83,
"channel": "11",
"ht": true,
"cc": "US",
"security": [
- `"ssid"` - "xfinitywifi",
- `"bssid"` - "6e:e3:0e:b8:45:99",
- `"rssi"` - -83,
- `"channel"` - "11",
- `"ht"` - true,
- `"cc"` - "US",
- `"security"` - [
"NONE"
]
},
@ -82,56 +85,65 @@ Examples:
$ airport -s | jc --airport -p -r
[
{
"ssid": "DIRECT-F3-HP ENVY 5660 series",
"bssid": "b0:5a:da:6f:0a:d4",
"rssi": "-93",
"channel": "1",
"ht": "Y",
"cc": "--",
"security": "WPA2(PSK/AES/AES)"
- `"ssid"` - "DIRECT-F3-HP ENVY 5660 series",
- `"bssid"` - "b0:5a:da:6f:0a:d4",
- `"rssi"` - "-93",
- `"channel"` - "1",
- `"ht"` - "Y",
- `"cc"` - "--",
- `"security"` - "WPA2(PSK/AES/AES)"
},
{
"ssid": "YouAreInfected-5",
"bssid": "5c:e3:0e:c2:85:da",
"rssi": "-85",
"channel": "36",
"ht": "Y",
"cc": "US",
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
- `"ssid"` - "YouAreInfected-5",
- `"bssid"` - "5c:e3:0e:c2:85:da",
- `"rssi"` - "-85",
- `"channel"` - "36",
- `"ht"` - "Y",
- `"cc"` - "US",
- `"security"` - "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
},
{
"ssid": "YuanFamily",
"bssid": "5c:e3:0e:b8:5f:9a",
"rssi": "-84",
"channel": "11",
"ht": "Y",
"cc": "US",
"security": "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
- `"ssid"` - "YuanFamily",
- `"bssid"` - "5c:e3:0e:b8:5f:9a",
- `"rssi"` - "-84",
- `"channel"` - "11",
- `"ht"` - "Y",
- `"cc"` - "US",
- `"security"` - "WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)"
},
...
]
<a id="jc.parsers.airport_s.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.airport_s.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.arp"></a>
# jc.parsers.arp
jc - JSON CLI output utility `arp` command output parser
Supports `arp` and `arp -a` output.
@ -38,109 +40,119 @@ Schema:
}
]
Examples:
**Examples**:
$ arp | jc --arp -p
[
{
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:f0:98:26",
"flags_mask": "C",
"iface": "ens33"
- `"address"` - "192.168.71.254",
- `"hwtype"` - "ether",
- `"hwaddress"` - "00:50:56:f0:98:26",
- `"flags_mask"` - "C",
- `"iface"` - "ens33"
},
{
"address": "gateway",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"flags_mask": "C",
"iface": "ens33"
- `"address"` - "gateway",
- `"hwtype"` - "ether",
- `"hwaddress"` - "00:50:56:f7:4a:fc",
- `"flags_mask"` - "C",
- `"iface"` - "ens33"
}
]
$ arp | jc --arp -p -r
[
{
"address": "gateway",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"flags_mask": "C",
"iface": "ens33"
- `"address"` - "gateway",
- `"hwtype"` - "ether",
- `"hwaddress"` - "00:50:56:f7:4a:fc",
- `"flags_mask"` - "C",
- `"iface"` - "ens33"
},
{
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:fe:7a:b4",
"flags_mask": "C",
"iface": "ens33"
- `"address"` - "192.168.71.254",
- `"hwtype"` - "ether",
- `"hwaddress"` - "00:50:56:fe:7a:b4",
- `"flags_mask"` - "C",
- `"iface"` - "ens33"
}
]
$ arp -a | jc --arp -p
[
{
"name": null,
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:f0:98:26",
"iface": "ens33"
"permanent": false,
"expires": 1182
- `"name"` - null,
- `"address"` - "192.168.71.254",
- `"hwtype"` - "ether",
- `"hwaddress"` - "00:50:56:f0:98:26",
- `"iface"` - "ens33"
- `"permanent"` - false,
- `"expires"` - 1182
},
{
"name": "gateway",
"address": "192.168.71.2",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"iface": "ens33"
"permanent": false,
"expires": 110
- `"name"` - "gateway",
- `"address"` - "192.168.71.2",
- `"hwtype"` - "ether",
- `"hwaddress"` - "00:50:56:f7:4a:fc",
- `"iface"` - "ens33"
- `"permanent"` - false,
- `"expires"` - 110
}
]
$ arp -a | jc --arp -p -r
[
{
"name": "?",
"address": "192.168.71.254",
"hwtype": "ether",
"hwaddress": "00:50:56:fe:7a:b4",
"iface": "ens33"
"permanent": false,
"expires": "1182"
- `"name"` - "?",
- `"address"` - "192.168.71.254",
- `"hwtype"` - "ether",
- `"hwaddress"` - "00:50:56:fe:7a:b4",
- `"iface"` - "ens33"
- `"permanent"` - false,
- `"expires"` - "1182"
},
{
"name": "_gateway",
"address": "192.168.71.2",
"hwtype": "ether",
"hwaddress": "00:50:56:f7:4a:fc",
"iface": "ens33"
"permanent": false,
"expires": "110"
- `"name"` - "_gateway",
- `"address"` - "192.168.71.2",
- `"hwtype"` - "ether",
- `"hwaddress"` - "00:50:56:f7:4a:fc",
- `"iface"` - "ens33"
- `"permanent"` - false,
- `"expires"` - "110"
}
]
<a id="jc.parsers.arp.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.arp.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.blkid"></a>
# jc.parsers.blkid
jc - JSON CLI output utility `blkid` command output parser
Usage (cli):
@ -57,93 +59,103 @@ Schema:
}
]
Examples:
**Examples**:
$ blkid | jc --blkid -p
[
{
"device": "/dev/sda1",
"uuid": "05d927ab-5875-49e4-ada1-7f46cb32c932",
"type": "xfs"
- `"device"` - "/dev/sda1",
- `"uuid"` - "05d927ab-5875-49e4-ada1-7f46cb32c932",
- `"type"` - "xfs"
},
{
"device": "/dev/sda2",
"uuid": "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
"type": "LVM2_member"
- `"device"` - "/dev/sda2",
- `"uuid"` - "3klkIj-w1kk-DkJi-0XBJ-y3i7-i2Ac-vHqWBM",
- `"type"` - "LVM2_member"
},
{
"device": "/dev/mapper/centos-root",
"uuid": "07d718ff-950c-4e5b-98f0-42a1147c77d9",
"type": "xfs"
- `"device"` - "/dev/mapper/centos-root",
- `"uuid"` - "07d718ff-950c-4e5b-98f0-42a1147c77d9",
- `"type"` - "xfs"
},
{
"device": "/dev/mapper/centos-swap",
"uuid": "615eb89a-bcbf-46fd-80e3-c483ff5c931f",
"type": "swap"
- `"device"` - "/dev/mapper/centos-swap",
- `"uuid"` - "615eb89a-bcbf-46fd-80e3-c483ff5c931f",
- `"type"` - "swap"
}
]
$ sudo blkid -o udev -ip /dev/sda2 | jc --blkid -p
[
{
"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_type": "LVM2_member",
"id_fs_usage": "raid",
"id_iolimit_minimum_io_size": 512,
"id_iolimit_physical_sector_size": 512,
"id_iolimit_logical_sector_size": 512,
"id_part_entry_scheme": "dos",
"id_part_entry_type": "0x8e",
"id_part_entry_number": 2,
"id_part_entry_offset": 2099200,
"id_part_entry_size": 39843840,
"id_part_entry_disk": "8:0"
- `"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_type"` - "LVM2_member",
- `"id_fs_usage"` - "raid",
- `"id_iolimit_minimum_io_size"` - 512,
- `"id_iolimit_physical_sector_size"` - 512,
- `"id_iolimit_logical_sector_size"` - 512,
- `"id_part_entry_scheme"` - "dos",
- `"id_part_entry_type"` - "0x8e",
- `"id_part_entry_number"` - 2,
- `"id_part_entry_offset"` - 2099200,
- `"id_part_entry_size"` - 39843840,
- `"id_part_entry_disk"` - "8:0"
}
]
$ sudo blkid -ip /dev/sda1 | jc --blkid -p -r
[
{
"devname": "/dev/sda1",
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
"type": "xfs",
"usage": "filesystem",
"minimum_io_size": "512",
"physical_sector_size": "512",
"logical_sector_size": "512",
"part_entry_scheme": "dos",
"part_entry_type": "0x83",
"part_entry_flags": "0x80",
"part_entry_number": "1",
"part_entry_offset": "2048",
"part_entry_size": "2097152",
"part_entry_disk": "8:0"
- `"devname"` - "/dev/sda1",
- `"uuid"` - "05d927bb-5875-49e3-ada1-7f46cb31c932",
- `"type"` - "xfs",
- `"usage"` - "filesystem",
- `"minimum_io_size"` - "512",
- `"physical_sector_size"` - "512",
- `"logical_sector_size"` - "512",
- `"part_entry_scheme"` - "dos",
- `"part_entry_type"` - "0x83",
- `"part_entry_flags"` - "0x80",
- `"part_entry_number"` - "1",
- `"part_entry_offset"` - "2048",
- `"part_entry_size"` - "2097152",
- `"part_entry_disk"` - "8:0"
}
]
<a id="jc.parsers.blkid.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.blkid.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.cksum"></a>
# jc.parsers.cksum
jc - JSON CLI output utility `cksum` command output parser
This parser works with the following checksum calculation utilities:
@ -35,49 +37,59 @@ Schema:
}
]
Examples:
**Examples**:
$ cksum * | jc --cksum -p
[
{
"filename": "__init__.py",
"checksum": 4294967295,
"blocks": 0
- `"filename"` - "__init__.py",
- `"checksum"` - 4294967295,
- `"blocks"` - 0
},
{
"filename": "airport.py",
"checksum": 2208551092,
"blocks": 3745
- `"filename"` - "airport.py",
- `"checksum"` - 2208551092,
- `"blocks"` - 3745
},
{
"filename": "airport_s.py",
"checksum": 1113817598,
"blocks": 4572
- `"filename"` - "airport_s.py",
- `"checksum"` - 1113817598,
- `"blocks"` - 4572
},
...
]
<a id="jc.parsers.cksum.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.cksum.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.crontab"></a>
# jc.parsers.crontab
jc - JSON CLI output utility `crontab -l` command output and crontab
file parser
@ -57,146 +59,156 @@ Schema:
]
}
Examples:
**Examples**:
$ crontab -l | jc --crontab -p
{
"variables": [
- `"variables"` - [
{
"name": "MAILTO",
"value": "root"
- `"name"` - "MAILTO",
- `"value"` - "root"
},
{
"name": "PATH",
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
- `"name"` - "PATH",
- `"value"` - "/sbin:/bin:/usr/sbin:/usr/bin"
},
{
"name": "SHELL",
"value": "/bin/bash"
- `"name"` - "SHELL",
- `"value"` - "/bin/bash"
}
],
"schedule": [
- `"schedule"` - [
{
"minute": [
- `"minute"` - [
"5"
],
"hour": [
- `"hour"` - [
"10-11",
"22"
],
"day_of_month": [
- `"day_of_month"` - [
"*"
],
"month": [
- `"month"` - [
"*"
],
"day_of_week": [
- `"day_of_week"` - [
"*"
],
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
- `"command"` - "/var/www/devdaily.com/bin/mk-new-links.php"
},
{
"minute": [
- `"minute"` - [
"30"
],
"hour": [
- `"hour"` - [
"4/2"
],
"day_of_month": [
- `"day_of_month"` - [
"*"
],
"month": [
- `"month"` - [
"*"
],
"day_of_week": [
- `"day_of_week"` - [
"*"
],
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
- `"command"` - "/var/www/devdaily.com/bin/create-all-backups.sh"
},
{
"occurrence": "yearly",
"command": "/home/maverick/bin/annual-maintenance"
- `"occurrence"` - "yearly",
- `"command"` - "/home/maverick/bin/annual-maintenance"
},
{
"occurrence": "reboot",
"command": "/home/cleanup"
- `"occurrence"` - "reboot",
- `"command"` - "/home/cleanup"
},
{
"occurrence": "monthly",
"command": "/home/maverick/bin/tape-backup"
- `"occurrence"` - "monthly",
- `"command"` - "/home/maverick/bin/tape-backup"
}
]
}
$ cat /etc/crontab | jc --crontab -p -r
{
"variables": [
- `"variables"` - [
{
"name": "MAILTO",
"value": "root"
- `"name"` - "MAILTO",
- `"value"` - "root"
},
{
"name": "PATH",
"value": "/sbin:/bin:/usr/sbin:/usr/bin"
- `"name"` - "PATH",
- `"value"` - "/sbin:/bin:/usr/sbin:/usr/bin"
},
{
"name": "SHELL",
"value": "/bin/bash"
- `"name"` - "SHELL",
- `"value"` - "/bin/bash"
}
],
"schedule": [
- `"schedule"` - [
{
"minute": "5",
"hour": "10-11,22",
"day_of_month": "*",
"month": "*",
"day_of_week": "*",
"command": "/var/www/devdaily.com/bin/mk-new-links.php"
- `"minute"` - "5",
- `"hour"` - "10-11,22",
- `"day_of_month"` - "*",
- `"month"` - "*",
- `"day_of_week"` - "*",
- `"command"` - "/var/www/devdaily.com/bin/mk-new-links.php"
},
{
"minute": "30",
"hour": "4/2",
"day_of_month": "*",
"month": "*",
"day_of_week": "*",
"command": "/var/www/devdaily.com/bin/create-all-backups.sh"
- `"minute"` - "30",
- `"hour"` - "4/2",
- `"day_of_month"` - "*",
- `"month"` - "*",
- `"day_of_week"` - "*",
- `"command"` - "/var/www/devdaily.com/bin/create-all-backups.sh"
},
{
"occurrence": "yearly",
"command": "/home/maverick/bin/annual-maintenance"
- `"occurrence"` - "yearly",
- `"command"` - "/home/maverick/bin/annual-maintenance"
},
{
"occurrence": "reboot",
"command": "/home/cleanup"
- `"occurrence"` - "reboot",
- `"command"` - "/home/cleanup"
},
{
"occurrence": "monthly",
"command": "/home/maverick/bin/tape-backup"
- `"occurrence"` - "monthly",
- `"command"` - "/home/maverick/bin/tape-backup"
}
]
}
<a id="jc.parsers.crontab.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.crontab.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.crontab_u"></a>
# jc.parsers.crontab\_u
# jc.parsers.crontab_u
jc - JSON CLI output utility `crontab -l` command output and crontab
file parser
@ -55,145 +57,155 @@ Schema:
]
}
Examples:
**Examples**:
$ cat /etc/crontab | jc --crontab-u -p
{
"variables": [
- `"variables"` - [
{
"name": "PATH",
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sb..."
- `"name"` - "PATH",
- `"value"` - "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sb..."
},
{
"name": "SHELL",
"value": "/bin/sh"
- `"name"` - "SHELL",
- `"value"` - "/bin/sh"
}
],
"schedule": [
- `"schedule"` - [
{
"minute": [
- `"minute"` - [
"25"
],
"hour": [
- `"hour"` - [
"6"
],
"day_of_month": [
- `"day_of_month"` - [
"*"
],
"month": [
- `"month"` - [
"*"
],
"day_of_week": [
- `"day_of_week"` - [
"*"
],
"user": "root",
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
- `"user"` - "root",
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
},
{
"minute": [
- `"minute"` - [
"47"
],
"hour": [
- `"hour"` - [
"6"
],
"day_of_month": [
- `"day_of_month"` - [
"*"
],
"month": [
- `"month"` - [
"*"
],
"day_of_week": [
- `"day_of_week"` - [
"7"
],
"user": "root",
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
- `"user"` - "root",
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
},
{
"minute": [
- `"minute"` - [
"52"
],
"hour": [
- `"hour"` - [
"6"
],
"day_of_month": [
- `"day_of_month"` - [
"1"
],
"month": [
- `"month"` - [
"*"
],
"day_of_week": [
- `"day_of_week"` - [
"*"
],
"user": "root",
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
- `"user"` - "root",
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
}
]
}
$ cat /etc/crontab | jc --crontab-u -p -r
{
"variables": [
- `"variables"` - [
{
"name": "PATH",
"value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/..."
- `"name"` - "PATH",
- `"value"` - "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/..."
},
{
"name": "SHELL",
"value": "/bin/sh"
- `"name"` - "SHELL",
- `"value"` - "/bin/sh"
}
],
"schedule": [
- `"schedule"` - [
{
"minute": "25",
"hour": "6",
"day_of_month": "*",
"month": "*",
"day_of_week": "*",
"user": "root",
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
- `"minute"` - "25",
- `"hour"` - "6",
- `"day_of_month"` - "*",
- `"month"` - "*",
- `"day_of_week"` - "*",
- `"user"` - "root",
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
},
{
"minute": "47",
"hour": "6",
"day_of_month": "*",
"month": "*",
"day_of_week": "7",
"user": "root",
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
- `"minute"` - "47",
- `"hour"` - "6",
- `"day_of_month"` - "*",
- `"month"` - "*",
- `"day_of_week"` - "7",
- `"user"` - "root",
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
},
{
"minute": "52",
"hour": "6",
"day_of_month": "1",
"month": "*",
"day_of_week": "*",
"user": "root",
"command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
- `"minute"` - "52",
- `"hour"` - "6",
- `"day_of_month"` - "1",
- `"month"` - "*",
- `"day_of_week"` - "*",
- `"user"` - "root",
- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..."
}
]
}
<a id="jc.parsers.crontab_u.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.crontab_u.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.csv"></a>
# jc.parsers.csv
jc - JSON CLI output utility `csv` file parser
The `csv` parser will attempt to automatically detect the delimiter
@ -33,7 +35,8 @@ Schema:
}
]
Examples:
**Examples**:
$ cat homes.csv
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
@ -45,62 +48,71 @@ Examples:
$ cat homes.csv | jc --csv -p
[
{
"Sell": "142",
"List": "160",
"Living": "28",
"Rooms": "10",
"Beds": "5",
"Baths": "3",
"Age": "60",
"Acres": "0.28",
"Taxes": "3167"
- `"Sell"` - "142",
- `"List"` - "160",
- `"Living"` - "28",
- `"Rooms"` - "10",
- `"Beds"` - "5",
- `"Baths"` - "3",
- `"Age"` - "60",
- `"Acres"` - "0.28",
- `"Taxes"` - "3167"
},
{
"Sell": "175",
"List": "180",
"Living": "18",
"Rooms": "8",
"Beds": "4",
"Baths": "1",
"Age": "12",
"Acres": "0.43",
"Taxes": "4033"
- `"Sell"` - "175",
- `"List"` - "180",
- `"Living"` - "18",
- `"Rooms"` - "8",
- `"Beds"` - "4",
- `"Baths"` - "1",
- `"Age"` - "12",
- `"Acres"` - "0.43",
- `"Taxes"` - "4033"
},
{
"Sell": "129",
"List": "132",
"Living": "13",
"Rooms": "6",
"Beds": "3",
"Baths": "1",
"Age": "41",
"Acres": "0.33",
"Taxes": "1471"
- `"Sell"` - "129",
- `"List"` - "132",
- `"Living"` - "13",
- `"Rooms"` - "6",
- `"Beds"` - "3",
- `"Baths"` - "1",
- `"Age"` - "41",
- `"Acres"` - "0.33",
- `"Taxes"` - "1471"
},
...
]
<a id="jc.parsers.csv.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.csv.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.csv_s"></a>
# jc.parsers.csv\_s
# jc.parsers.csv_s
jc - JSON CLI output utility `csv` file streaming parser
> This streaming parser outputs JSON Lines
@ -51,7 +53,8 @@ Schema:
}
}
Examples:
**Examples**:
$ cat homes.csv
"Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"...
@ -66,34 +69,45 @@ Examples:
{"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3"...}
...
<a id="jc.parsers.csv_s.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.csv_s.parse"></a>
#### 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.
Parameters:
**Arguments**:
data: (iterable) line-based text data to parse
- `data` - (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
**Yields**:
Yields:
Dictionary. Raw or processed structured data.
Returns:
**Returns**:
Iterator object

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.date"></a>
# 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
@ -55,52 +57,62 @@ Schema:
[1] timezone-aware timestamp. Only available if timezone field is UTC
[2] if true, all fields are correctly based on UTC
Examples:
**Examples**:
$ date | jc --date -p
{
"year": 2021,
"month": "Mar",
"month_num": 3,
"day": 25,
"weekday": "Thu",
"weekday_num": 4,
"hour": 2,
"hour_24": 2,
"minute": 2,
"second": 26,
"period": "AM",
"timezone": "UTC",
"utc_offset": "+0000",
"day_of_year": 84,
"week_of_year": 12,
"iso": "2021-03-25T02:02:26+00:00",
"epoch": 1616662946,
"epoch_utc": 1616637746,
"timezone_aware": true
- `"year"` - 2021,
- `"month"` - "Mar",
- `"month_num"` - 3,
- `"day"` - 25,
- `"weekday"` - "Thu",
- `"weekday_num"` - 4,
- `"hour"` - 2,
- `"hour_24"` - 2,
- `"minute"` - 2,
- `"second"` - 26,
- `"period"` - "AM",
- `"timezone"` - "UTC",
- `"utc_offset"` - "+0000",
- `"day_of_year"` - 84,
- `"week_of_year"` - 12,
- `"iso"` - "2021-03-25T02:02:26+00:00",
- `"epoch"` - 1616662946,
- `"epoch_utc"` - 1616637746,
- `"timezone_aware"` - true
}
<a id="jc.parsers.date.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.date.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.df"></a>
# jc.parsers.df
jc - JSON CLI output utility `df` command output parser
Usage (cli):
@ -40,33 +42,34 @@ Schema:
}
]
Examples:
**Examples**:
$ df | jc --df -p
[
{
"filesystem": "devtmpfs",
"1k_blocks": 1918820,
"used": 0,
"available": 1918820,
"use_percent": 0,
"mounted_on": "/dev"
- `"filesystem"` - "devtmpfs",
- `"1k_blocks"` - 1918820,
- `"used"` - 0,
- `"available"` - 1918820,
- `"use_percent"` - 0,
- `"mounted_on"` - "/dev"
},
{
"filesystem": "tmpfs",
"1k_blocks": 1930668,
"used": 0,
"available": 1930668,
"use_percent": 0,
"mounted_on": "/dev/shm"
- `"filesystem"` - "tmpfs",
- `"1k_blocks"` - 1930668,
- `"used"` - 0,
- `"available"` - 1930668,
- `"use_percent"` - 0,
- `"mounted_on"` - "/dev/shm"
},
{
"filesystem": "tmpfs",
"1k_blocks": 1930668,
"used": 11800,
"available": 1918868,
"use_percent": 1,
"mounted_on": "/run"
- `"filesystem"` - "tmpfs",
- `"1k_blocks"` - 1930668,
- `"used"` - 11800,
- `"available"` - 1918868,
- `"use_percent"` - 1,
- `"mounted_on"` - "/run"
},
...
]
@ -74,53 +77,62 @@ Examples:
$ df | jc --df -p -r
[
{
"filesystem": "devtmpfs",
"1k_blocks": "1918820",
"used": "0",
"available": "1918820",
"use_percent": "0%",
"mounted_on": "/dev"
- `"filesystem"` - "devtmpfs",
- `"1k_blocks"` - "1918820",
- `"used"` - "0",
- `"available"` - "1918820",
- `"use_percent"` - "0%",
- `"mounted_on"` - "/dev"
},
{
"filesystem": "tmpfs",
"1k_blocks": "1930668",
"used": "0",
"available": "1930668",
"use_percent": "0%",
"mounted_on": "/dev/shm"
- `"filesystem"` - "tmpfs",
- `"1k_blocks"` - "1930668",
- `"used"` - "0",
- `"available"` - "1930668",
- `"use_percent"` - "0%",
- `"mounted_on"` - "/dev/shm"
},
{
"filesystem": "tmpfs",
"1k_blocks": "1930668",
"used": "11800",
"available": "1918868",
"use_percent": "1%",
"mounted_on": "/run"
- `"filesystem"` - "tmpfs",
- `"1k_blocks"` - "1930668",
- `"used"` - "11800",
- `"available"` - "1918868",
- `"use_percent"` - "1%",
- `"mounted_on"` - "/run"
},
...
]
<a id="jc.parsers.df.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.df.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.dig"></a>
# jc.parsers.dig
jc - JSON CLI output utility `dig` command output parser
Options supported:
@ -111,241 +113,251 @@ Schema:
[0] naive timestamp if "when" field is parsable, else null
[1] timezone aware timestamp availabe for UTC, else null
Examples:
**Examples**:
$ dig example.com | jc --dig -p
[
{
"id": 2951,
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
- `"id"` - 2951,
- `"opcode"` - "QUERY",
- `"status"` - "NOERROR",
- `"flags"` - [
"qr",
"rd",
"ra"
],
"query_num": 1,
"answer_num": 1,
"authority_num": 0,
"additional_num": 1,
"opt_pseudosection": {
"edns": {
"version": 0,
"flags": [],
"udp": 4096
- `"query_num"` - 1,
- `"answer_num"` - 1,
- `"authority_num"` - 0,
- `"additional_num"` - 1,
- `"opt_pseudosection"` - {
- `"edns"` - {
- `"version"` - 0,
- `"flags"` - [],
- `"udp"` - 4096
}
},
"question": {
"name": "example.com.",
"class": "IN",
"type": "A"
- `"question"` - {
- `"name"` - "example.com.",
- `"class"` - "IN",
- `"type"` - "A"
},
"answer": [
- `"answer"` - [
{
"name": "example.com.",
"class": "IN",
"type": "A",
"ttl": 39302,
"data": "93.184.216.34"
- `"name"` - "example.com.",
- `"class"` - "IN",
- `"type"` - "A",
- `"ttl"` - 39302,
- `"data"` - "93.184.216.34"
}
],
"query_time": 49,
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Fri Apr 16 16:05:10 PDT 2021",
"rcvd": 56,
"when_epoch": 1618614310,
"when_epoch_utc": null
- `"query_time"` - 49,
- `"server"` - "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
- `"when"` - "Fri Apr 16 16:05:10 PDT 2021",
- `"rcvd"` - 56,
- `"when_epoch"` - 1618614310,
- `"when_epoch_utc"` - null
}
]
$ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p -r
[
{
"id": "46052",
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
- `"id"` - "46052",
- `"opcode"` - "QUERY",
- `"status"` - "NOERROR",
- `"flags"` - [
"qr",
"rd",
"ra"
],
"query_num": "1",
"answer_num": "1",
"authority_num": "0",
"additional_num": "1",
"opt_pseudosection": {
"edns": {
"version": "0",
"flags": [],
"udp": "4096"
- `"query_num"` - "1",
- `"answer_num"` - "1",
- `"authority_num"` - "0",
- `"additional_num"` - "1",
- `"opt_pseudosection"` - {
- `"edns"` - {
- `"version"` - "0",
- `"flags"` - [],
- `"udp"` - "4096"
}
},
"question": {
"name": "example.com.",
"class": "IN",
"type": "A"
- `"question"` - {
- `"name"` - "example.com.",
- `"class"` - "IN",
- `"type"` - "A"
},
"answer": [
- `"answer"` - [
{
"name": "example.com.",
"class": "IN",
"type": "A",
"ttl": "40426",
"data": "93.184.216.34"
- `"name"` - "example.com.",
- `"class"` - "IN",
- `"type"` - "A",
- `"ttl"` - "40426",
- `"data"` - "93.184.216.34"
}
],
"query_time": "48 msec",
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Fri Apr 16 16:06:12 PDT 2021",
"rcvd": "56"
- `"query_time"` - "48 msec",
- `"server"` - "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
- `"when"` - "Fri Apr 16 16:06:12 PDT 2021",
- `"rcvd"` - "56"
}
]
$ dig -x 1.1.1.1 | jc --dig -p
[
{
"id": 20785,
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
- `"id"` - 20785,
- `"opcode"` - "QUERY",
- `"status"` - "NOERROR",
- `"flags"` - [
"qr",
"rd",
"ra"
],
"query_num": 1,
"answer_num": 1,
"authority_num": 0,
"additional_num": 1,
"opt_pseudosection": {
"edns": {
"version": 0,
"flags": [],
"udp": 4096
- `"query_num"` - 1,
- `"answer_num"` - 1,
- `"authority_num"` - 0,
- `"additional_num"` - 1,
- `"opt_pseudosection"` - {
- `"edns"` - {
- `"version"` - 0,
- `"flags"` - [],
- `"udp"` - 4096
}
},
"question": {
"name": "1.1.1.1.in-addr.arpa.",
"class": "IN",
"type": "PTR"
- `"question"` - {
- `"name"` - "1.1.1.1.in-addr.arpa.",
- `"class"` - "IN",
- `"type"` - "PTR"
},
"answer": [
- `"answer"` - [
{
"name": "1.1.1.1.in-addr.arpa.",
"class": "IN",
"type": "PTR",
"ttl": 1800,
"data": "one.one.one.one."
- `"name"` - "1.1.1.1.in-addr.arpa.",
- `"class"` - "IN",
- `"type"` - "PTR",
- `"ttl"` - 1800,
- `"data"` - "one.one.one.one."
}
],
"query_time": 40,
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Sat Apr 17 14:50:50 PDT 2021",
"rcvd": 78,
"when_epoch": 1618696250,
"when_epoch_utc": null
- `"query_time"` - 40,
- `"server"` - "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
- `"when"` - "Sat Apr 17 14:50:50 PDT 2021",
- `"rcvd"` - 78,
- `"when_epoch"` - 1618696250,
- `"when_epoch_utc"` - null
}
]
$ dig -x 1.1.1.1 | jc --dig -p -r
[
{
"id": "32644",
"opcode": "QUERY",
"status": "NOERROR",
"flags": [
- `"id"` - "32644",
- `"opcode"` - "QUERY",
- `"status"` - "NOERROR",
- `"flags"` - [
"qr",
"rd",
"ra"
],
"query_num": "1",
"answer_num": "1",
"authority_num": "0",
"additional_num": "1",
"opt_pseudosection": {
"edns": {
"version": "0",
"flags": [],
"udp": "4096"
- `"query_num"` - "1",
- `"answer_num"` - "1",
- `"authority_num"` - "0",
- `"additional_num"` - "1",
- `"opt_pseudosection"` - {
- `"edns"` - {
- `"version"` - "0",
- `"flags"` - [],
- `"udp"` - "4096"
}
},
"question": {
"name": "1.1.1.1.in-addr.arpa.",
"class": "IN",
"type": "PTR"
- `"question"` - {
- `"name"` - "1.1.1.1.in-addr.arpa.",
- `"class"` - "IN",
- `"type"` - "PTR"
},
"answer": [
- `"answer"` - [
{
"name": "1.1.1.1.in-addr.arpa.",
"class": "IN",
"type": "PTR",
"ttl": "1800",
"data": "one.one.one.one."
- `"name"` - "1.1.1.1.in-addr.arpa.",
- `"class"` - "IN",
- `"type"` - "PTR",
- `"ttl"` - "1800",
- `"data"` - "one.one.one.one."
}
],
"query_time": "52 msec",
"server": "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
"when": "Sat Apr 17 14:51:46 PDT 2021",
"rcvd": "78"
- `"query_time"` - "52 msec",
- `"server"` - "2600:1700:bab0:d40::1#53(2600:1700:bab0:d40::1)",
- `"when"` - "Sat Apr 17 14:51:46 PDT 2021",
- `"rcvd"` - "78"
}
]
$ dig +noall +answer cnn.com | jc --dig -p
[
{
"answer": [
- `"answer"` - [
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": 60,
"data": "151.101.193.67"
- `"name"` - "cnn.com.",
- `"class"` - "IN",
- `"type"` - "A",
- `"ttl"` - 60,
- `"data"` - "151.101.193.67"
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": 60,
"data": "151.101.65.67"
- `"name"` - "cnn.com.",
- `"class"` - "IN",
- `"type"` - "A",
- `"ttl"` - 60,
- `"data"` - "151.101.65.67"
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": 60,
"data": "151.101.1.67"
- `"name"` - "cnn.com.",
- `"class"` - "IN",
- `"type"` - "A",
- `"ttl"` - 60,
- `"data"` - "151.101.1.67"
},
{
"name": "cnn.com.",
"class": "IN",
"type": "A",
"ttl": 60,
"data": "151.101.129.67"
- `"name"` - "cnn.com.",
- `"class"` - "IN",
- `"type"` - "A",
- `"ttl"` - 60,
- `"data"` - "151.101.129.67"
}
]
}
]
<a id="jc.parsers.dig.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.dig.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.dir"></a>
# jc.parsers.dir
jc - JSON CLI output utility `dir` command output parser
Options supported:
@ -43,45 +45,46 @@ Schema:
}
]
Examples:
**Examples**:
C:> dir | jc --dir -p
[
{
"date": "03/24/2021",
"time": "03:15 PM",
"dir": true,
"size": null,
"filename": ".",
"parent": "C:\Program Files\Internet Explorer",
"epoch": 1616624100
- `"date"` - "03/24/2021",
- `"time"` - "03:15 PM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - ".",
- `"parent"` - "C:\\Program Files\\Internet Explorer",
- `"epoch"` - 1616624100
},
{
"date": "03/24/2021",
"time": "03:15 PM",
"dir": true,
"size": null,
"filename": "..",
"parent": "C:\Program Files\Internet Explorer",
"epoch": 1616624100
- `"date"` - "03/24/2021",
- `"time"` - "03:15 PM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - "..",
- `"parent"` - "C:\\Program Files\\Internet Explorer",
- `"epoch"` - 1616624100
},
{
"date": "12/07/2019",
"time": "02:49 AM",
"dir": true,
"size": null,
"filename": "en-US",
"parent": "C:\Program Files\Internet Explorer",
"epoch": 1575715740
- `"date"` - "12/07/2019",
- `"time"` - "02:49 AM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - "en-US",
- `"parent"` - "C:\\Program Files\\Internet Explorer",
- `"epoch"` - 1575715740
},
{
"date": "12/07/2019",
"time": "02:09 AM",
"dir": false,
"size": 54784,
"filename": "ExtExport.exe",
"parent": "C:\Program Files\Internet Explorer",
"epoch": 1575713340
- `"date"` - "12/07/2019",
- `"time"` - "02:09 AM",
- `"dir"` - false,
- `"size"` - 54784,
- `"filename"` - "ExtExport.exe",
- `"parent"` - "C:\\Program Files\\Internet Explorer",
- `"epoch"` - 1575713340
},
...
]
@ -89,61 +92,70 @@ Examples:
C:> dir | jc --dir -p -r
[
{
"date": "03/24/2021",
"time": "03:15 PM",
"dir": true,
"size": null,
"filename": ".",
"parent": "C:\Program Files\Internet Explorer"
- `"date"` - "03/24/2021",
- `"time"` - "03:15 PM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - ".",
- `"parent"` - "C:\\Program Files\\Internet Explorer"
},
{
"date": "03/24/2021",
"time": "03:15 PM",
"dir": true,
"size": null,
"filename": "..",
"parent": "C:\Program Files\Internet Explorer"
- `"date"` - "03/24/2021",
- `"time"` - "03:15 PM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - "..",
- `"parent"` - "C:\\Program Files\\Internet Explorer"
},
{
"date": "12/07/2019",
"time": "02:49 AM",
"dir": true,
"size": null,
"filename": "en-US",
"parent": "C:\Program Files\Internet Explorer"
- `"date"` - "12/07/2019",
- `"time"` - "02:49 AM",
- `"dir"` - true,
- `"size"` - null,
- `"filename"` - "en-US",
- `"parent"` - "C:\\Program Files\\Internet Explorer"
},
{
"date": "12/07/2019",
"time": "02:09 AM",
"dir": false,
"size": "54,784",
"filename": "ExtExport.exe",
"parent": "C:\Program Files\Internet Explorer"
- `"date"` - "12/07/2019",
- `"time"` - "02:09 AM",
- `"dir"` - false,
- `"size"` - "54,784",
- `"filename"` - "ExtExport.exe",
- `"parent"` - "C:\\Program Files\\Internet Explorer"
},
...
]
<a id="jc.parsers.dir.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.dir.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.dmidecode"></a>
# jc.parsers.dmidecode
jc - JSON CLI output utility `dmidecode` command output parser
Usage (cli):
@ -38,23 +40,24 @@ Schema:
}
]
Examples:
**Examples**:
# dmidecode | jc --dmidecode -p
[
{
"handle": "0x0000",
"type": 0,
"bytes": 24,
"description": "BIOS Information",
"values": {
"vendor": "Phoenix Technologies LTD",
"version": "6.00",
"release_date": "04/13/2018",
"address": "0xEA490",
"runtime_size": "88944 bytes",
"rom_size": "64 kB",
"characteristics": [
- `"handle"` - "0x0000",
- `"type"` - 0,
- `"bytes"` - 24,
- `"description"` - "BIOS Information",
- `"values"` - {
- `"vendor"` - "Phoenix Technologies LTD",
- `"version"` - "6.00",
- `"release_date"` - "04/13/2018",
- `"address"` - "0xEA490",
- `"runtime_size"` - "88944 bytes",
- `"rom_size"` - "64 kB",
- `"characteristics"` - [
"ISA is supported",
"PCI is supported",
"PC Card (PCMCIA) is supported",
@ -77,8 +80,8 @@ Examples:
"Function key-initiated network boot is supported",
"Targeted content distribution is supported"
],
"bios_revision": "4.6",
"firmware_revision": "0.0"
- `"bios_revision"` - "4.6",
- `"firmware_revision"` - "0.0"
}
},
...
@ -87,18 +90,18 @@ Examples:
# dmidecode | jc --dmidecode -p -r
[
{
"handle": "0x0000",
"type": "0",
"bytes": "24",
"description": "BIOS Information",
"values": {
"vendor": "Phoenix Technologies LTD",
"version": "6.00",
"release_date": "04/13/2018",
"address": "0xEA490",
"runtime_size": "88944 bytes",
"rom_size": "64 kB",
"characteristics": [
- `"handle"` - "0x0000",
- `"type"` - "0",
- `"bytes"` - "24",
- `"description"` - "BIOS Information",
- `"values"` - {
- `"vendor"` - "Phoenix Technologies LTD",
- `"version"` - "6.00",
- `"release_date"` - "04/13/2018",
- `"address"` - "0xEA490",
- `"runtime_size"` - "88944 bytes",
- `"rom_size"` - "64 kB",
- `"characteristics"` - [
"ISA is supported",
"PCI is supported",
"PC Card (PCMCIA) is supported",
@ -121,34 +124,43 @@ Examples:
"Function key-initiated network boot is supported",
"Targeted content distribution is supported"
],
"bios_revision": "4.6",
"firmware_revision": "0.0"
- `"bios_revision"` - "4.6",
- `"firmware_revision"` - "0.0"
}
},
...
]
<a id="jc.parsers.dmidecode.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.dmidecode.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.dpkg_l"></a>
# 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
@ -41,55 +43,56 @@ Schema:
}
]
Examples:
**Examples**:
$ dpkg -l | jc --dpkg-l -p
[
{
"codes": "ii",
"name": "accountsservice",
"version": "0.6.45-1ubuntu1.3",
"architecture": "amd64",
"description": "query and manipulate user account information",
"desired": "install",
"status": "installed"
- `"codes"` - "ii",
- `"name"` - "accountsservice",
- `"version"` - "0.6.45-1ubuntu1.3",
- `"architecture"` - "amd64",
- `"description"` - "query and manipulate user account information",
- `"desired"` - "install",
- `"status"` - "installed"
},
{
"codes": "rc",
"name": "acl",
"version": "2.2.52-3build1",
"architecture": "amd64",
"description": "Access control list utilities",
"desired": "remove",
"status": "config-files"
- `"codes"` - "rc",
- `"name"` - "acl",
- `"version"` - "2.2.52-3build1",
- `"architecture"` - "amd64",
- `"description"` - "Access control list utilities",
- `"desired"` - "remove",
- `"status"` - "config-files"
},
{
"codes": "uWR",
"name": "acpi",
"version": "1.7-1.1",
"architecture": "amd64",
"description": "displays information on ACPI devices",
"desired": "unknown",
"status": "trigger await",
"error": "reinstall required"
- `"codes"` - "uWR",
- `"name"` - "acpi",
- `"version"` - "1.7-1.1",
- `"architecture"` - "amd64",
- `"description"` - "displays information on ACPI devices",
- `"desired"` - "unknown",
- `"status"` - "trigger await",
- `"error"` - "reinstall required"
},
{
"codes": "rh",
"name": "acpid",
"version": "1:2.0.28-1ubuntu1",
"architecture": "amd64",
"description": "Advanced Configuration and Power Interface...",
"desired": "remove",
"status": "half installed"
- `"codes"` - "rh",
- `"name"` - "acpid",
- `"version"` - "1:2.0.28-1ubuntu1",
- `"architecture"` - "amd64",
- `"description"` - "Advanced Configuration and Power Interface...",
- `"desired"` - "remove",
- `"status"` - "half installed"
},
{
"codes": "pn",
"name": "adduser",
"version": "3.116ubuntu1",
"architecture": "all",
"description": "add and remove users and groups",
"desired": "purge",
"status": "not installed"
- `"codes"` - "pn",
- `"name"` - "adduser",
- `"version"` - "3.116ubuntu1",
- `"architecture"` - "all",
- `"description"` - "add and remove users and groups",
- `"desired"` - "purge",
- `"status"` - "not installed"
},
...
]
@ -97,64 +100,73 @@ Examples:
$ dpkg -l | jc --dpkg-l -p -r
[
{
"codes": "ii",
"name": "accountsservice",
"version": "0.6.45-1ubuntu1.3",
"architecture": "amd64",
"description": "query and manipulate user account information"
- `"codes"` - "ii",
- `"name"` - "accountsservice",
- `"version"` - "0.6.45-1ubuntu1.3",
- `"architecture"` - "amd64",
- `"description"` - "query and manipulate user account information"
},
{
"codes": "rc",
"name": "acl",
"version": "2.2.52-3build1",
"architecture": "amd64",
"description": "Access control list utilities"
- `"codes"` - "rc",
- `"name"` - "acl",
- `"version"` - "2.2.52-3build1",
- `"architecture"` - "amd64",
- `"description"` - "Access control list utilities"
},
{
"codes": "uWR",
"name": "acpi",
"version": "1.7-1.1",
"architecture": "amd64",
"description": "displays information on ACPI devices"
- `"codes"` - "uWR",
- `"name"` - "acpi",
- `"version"` - "1.7-1.1",
- `"architecture"` - "amd64",
- `"description"` - "displays information on ACPI devices"
},
{
"codes": "rh",
"name": "acpid",
"version": "1:2.0.28-1ubuntu1",
"architecture": "amd64",
"description": "Advanced Configuration and Power Interface..."
- `"codes"` - "rh",
- `"name"` - "acpid",
- `"version"` - "1:2.0.28-1ubuntu1",
- `"architecture"` - "amd64",
- `"description"` - "Advanced Configuration and Power Interface..."
},
{
"codes": "pn",
"name": "adduser",
"version": "3.116ubuntu1",
"architecture": "all",
"description": "add and remove users and groups"
- `"codes"` - "pn",
- `"name"` - "adduser",
- `"version"` - "3.116ubuntu1",
- `"architecture"` - "all",
- `"description"` - "add and remove users and groups"
},
...
]
<a id="jc.parsers.dpkg_l.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.dpkg_l.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.du"></a>
# jc.parsers.du
jc - JSON CLI output utility `du` command output parser
Usage (cli):
@ -30,33 +32,34 @@ Schema:
}
]
Examples:
**Examples**:
$ du /usr | jc --du -p
[
{
"size": 104608,
"name": "/usr/bin"
- `"size"` - 104608,
- `"name"` - "/usr/bin"
},
{
"size": 56,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - 56,
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
{
"size": 0,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - 0,
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
{
"size": 0,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - 0,
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
{
"size": 0,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - 0,
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
{
"size": 1008,
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - 1008,
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
...
]
@ -64,53 +67,62 @@ Examples:
$ du /usr | jc --du -p -r
[
{
"size": "104608",
"name": "/usr/bin"
- `"size"` - "104608",
- `"name"` - "/usr/bin"
},
{
"size": "56",
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - "56",
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
{
"size": "0",
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - "0",
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
{
"size": "0",
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - "0",
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
{
"size": "0",
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - "0",
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
{
"size": "1008",
"name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
- `"size"` - "1008",
- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..."
},
...
]
<a id="jc.parsers.du.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.du.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.env"></a>
# 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
@ -35,67 +37,77 @@ Schema:
}
]
Examples:
**Examples**:
$ env | jc --env -p
[
{
"name": "XDG_SESSION_ID",
"value": "1"
- `"name"` - "XDG_SESSION_ID",
- `"value"` - "1"
},
{
"name": "HOSTNAME",
"value": "localhost.localdomain"
- `"name"` - "HOSTNAME",
- `"value"` - "localhost.localdomain"
},
{
"name": "TERM",
"value": "vt220"
- `"name"` - "TERM",
- `"value"` - "vt220"
},
{
"name": "SHELL",
"value": "/bin/bash"
- `"name"` - "SHELL",
- `"value"` - "/bin/bash"
},
{
"name": "HISTSIZE",
"value": "1000"
- `"name"` - "HISTSIZE",
- `"value"` - "1000"
},
...
]
$ env | jc --env -p -r
{
"TERM": "xterm-256color",
"SHELL": "/bin/bash",
"USER": "root",
"PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
"PWD": "/root",
"LANG": "en_US.UTF-8",
"HOME": "/root",
"LOGNAME": "root",
"_": "/usr/bin/env"
- `"TERM"` - "xterm-256color",
- `"SHELL"` - "/bin/bash",
- `"USER"` - "root",
- `"PATH"` - "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
- `"PWD"` - "/root",
- `"LANG"` - "en_US.UTF-8",
- `"HOME"` - "/root",
- `"LOGNAME"` - "root",
- `"_"` - "/usr/bin/env"
}
<a id="jc.parsers.env.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.env.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary of raw structured data or
List of Dictionaries of processed structured data

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.file"></a>
# jc.parsers.file
jc - JSON CLI output utility `file` command output parser
Usage (cli):
@ -30,62 +32,72 @@ Schema:
}
]
Examples:
**Examples**:
$ file * | jc --file -p
[
{
"filename": "Applications",
"type": "directory"
- `"filename"` - "Applications",
- `"type"` - "directory"
},
{
"filename": "another file with spaces",
"type": "empty"
- `"filename"` - "another file with spaces",
- `"type"` - "empty"
},
{
"filename": "argstest.py",
"type": "Python script text executable, ASCII text"
- `"filename"` - "argstest.py",
- `"type"` - "Python script text executable, ASCII text"
},
{
"filename": "blkid-p.out",
"type": "ASCII text"
- `"filename"` - "blkid-p.out",
- `"type"` - "ASCII text"
},
{
"filename": "blkid-pi.out",
"type": "ASCII text, with very long lines"
- `"filename"` - "blkid-pi.out",
- `"type"` - "ASCII text, with very long lines"
},
{
"filename": "cd_catalog.xml",
"type": "XML 1.0 document text, ASCII text, with CRLF line ..."
- `"filename"` - "cd_catalog.xml",
- `"type"` - "XML 1.0 document text, ASCII text, with CRLF line ..."
},
{
"filename": "centosserial.sh",
"type": "Bourne-Again shell script text executable, UTF-8 ..."
- `"filename"` - "centosserial.sh",
- `"type"` - "Bourne-Again shell script text executable, UTF-8 ..."
},
...
]
<a id="jc.parsers.file.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.file.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.finger"></a>
# jc.parsers.finger
jc - JSON CLI output utility `finger` command output parser
Supports `-s` output option. Does not support the `-l` detail option.
@ -41,34 +43,35 @@ Schema:
}
]
Examples:
**Examples**:
$ finger | jc --finger -p
[
{
"login": "jdoe",
"name": "John Doe",
"tty": "tty1",
"idle": "14d",
"login_time": "Mar 22 21:14",
"tty_writeable": false,
"idle_minutes": 0,
"idle_hours": 0,
"idle_days": 14,
"total_idle_minutes": 20160
- `"login"` - "jdoe",
- `"name"` - "John Doe",
- `"tty"` - "tty1",
- `"idle"` - "14d",
- `"login_time"` - "Mar 22 21:14",
- `"tty_writeable"` - false,
- `"idle_minutes"` - 0,
- `"idle_hours"` - 0,
- `"idle_days"` - 14,
- `"total_idle_minutes"` - 20160
},
{
"login": "jdoe",
"name": "John Doe",
"tty": "pts/0",
"idle": null,
"login_time": "Apr 5 15:33",
"details": "(192.168.1.22)",
"tty_writeable": true,
"idle_minutes": 0,
"idle_hours": 0,
"idle_days": 0,
"total_idle_minutes": 0
- `"login"` - "jdoe",
- `"name"` - "John Doe",
- `"tty"` - "pts/0",
- `"idle"` - null,
- `"login_time"` - "Apr 5 15:33",
- `"details"` - "(192.168.1.22)",
- `"tty_writeable"` - true,
- `"idle_minutes"` - 0,
- `"idle_hours"` - 0,
- `"idle_days"` - 0,
- `"total_idle_minutes"` - 0
},
...
]
@ -76,44 +79,53 @@ Examples:
$ finger | jc --finger -p -r
[
{
"login": "jdoe",
"name": "John Doe",
"tty": "*tty1",
"idle": "14d",
"login_time": "Mar 22 21:14"
- `"login"` - "jdoe",
- `"name"` - "John Doe",
- `"tty"` - "*tty1",
- `"idle"` - "14d",
- `"login_time"` - "Mar 22 21:14"
},
{
"login": "jdoe",
"name": "John Doe",
"tty": "pts/0",
"idle": null,
"login_time": "Apr 5 15:33",
"details": "(192.168.1.22)"
- `"login"` - "jdoe",
- `"name"` - "John Doe",
- `"tty"` - "pts/0",
- `"idle"` - null,
- `"login_time"` - "Apr 5 15:33",
- `"details"` - "(192.168.1.22)"
},
...
]
<a id="jc.parsers.finger.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.finger.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.free"></a>
# jc.parsers.free
jc - JSON CLI output utility `free` command output parser
Usage (cli):
@ -35,67 +37,77 @@ Schema:
}
]
Examples:
**Examples**:
$ free | jc --free -p
[
{
"type": "Mem",
"total": 3861340,
"used": 220508,
"free": 3381972,
"shared": 11800,
"buff_cache": 258860,
"available": 3397784
- `"type"` - "Mem",
- `"total"` - 3861340,
- `"used"` - 220508,
- `"free"` - 3381972,
- `"shared"` - 11800,
- `"buff_cache"` - 258860,
- `"available"` - 3397784
},
{
"type": "Swap",
"total": 2097148,
"used": 0,
"free": 2097148
- `"type"` - "Swap",
- `"total"` - 2097148,
- `"used"` - 0,
- `"free"` - 2097148
}
]
$ free | jc --free -p -r
[
{
"type": "Mem",
"total": "2017300",
"used": "213104",
"free": "1148452",
"shared": "1176",
"buff_cache": "655744",
"available": "1622204"
- `"type"` - "Mem",
- `"total"` - "2017300",
- `"used"` - "213104",
- `"free"` - "1148452",
- `"shared"` - "1176",
- `"buff_cache"` - "655744",
- `"available"` - "1622204"
},
{
"type": "Swap",
"total": "2097148",
"used": "0",
"free": "2097148"
- `"type"` - "Swap",
- `"total"` - "2097148",
- `"used"` - "0",
- `"free"` - "2097148"
}
]
<a id="jc.parsers.free.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.free.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.fstab"></a>
# jc.parsers.fstab
jc - JSON CLI output utility `fstab` file parser
Usage (cli):
@ -30,85 +32,95 @@ Schema:
}
]
Examples:
**Examples**:
$ cat /etc/fstab | jc --fstab -p
[
{
"fs_spec": "/dev/mapper/centos-root",
"fs_file": "/",
"fs_vfstype": "xfs",
"fs_mntops": "defaults",
"fs_freq": 0,
"fs_passno": 0
- `"fs_spec"` - "/dev/mapper/centos-root",
- `"fs_file"` - "/",
- `"fs_vfstype"` - "xfs",
- `"fs_mntops"` - "defaults",
- `"fs_freq"` - 0,
- `"fs_passno"` - 0
},
{
"fs_spec": "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
"fs_file": "/boot",
"fs_vfstype": "xfs",
"fs_mntops": "defaults",
"fs_freq": 0,
"fs_passno": 0
- `"fs_spec"` - "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
- `"fs_file"` - "/boot",
- `"fs_vfstype"` - "xfs",
- `"fs_mntops"` - "defaults",
- `"fs_freq"` - 0,
- `"fs_passno"` - 0
},
{
"fs_spec": "/dev/mapper/centos-swap",
"fs_file": "swap",
"fs_vfstype": "swap",
"fs_mntops": "defaults",
"fs_freq": 0,
"fs_passno": 0
- `"fs_spec"` - "/dev/mapper/centos-swap",
- `"fs_file"` - "swap",
- `"fs_vfstype"` - "swap",
- `"fs_mntops"` - "defaults",
- `"fs_freq"` - 0,
- `"fs_passno"` - 0
}
]
$ cat /etc/fstab | jc --fstab -p -r
[
{
"fs_spec": "/dev/mapper/centos-root",
"fs_file": "/",
"fs_vfstype": "xfs",
"fs_mntops": "defaults",
"fs_freq": "0",
"fs_passno": "0"
- `"fs_spec"` - "/dev/mapper/centos-root",
- `"fs_file"` - "/",
- `"fs_vfstype"` - "xfs",
- `"fs_mntops"` - "defaults",
- `"fs_freq"` - "0",
- `"fs_passno"` - "0"
},
{
"fs_spec": "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
"fs_file": "/boot",
"fs_vfstype": "xfs",
"fs_mntops": "defaults",
"fs_freq": "0",
"fs_passno": "0"
- `"fs_spec"` - "UUID=05d927bb-5875-49e3-ada1-7f46cb31c932",
- `"fs_file"` - "/boot",
- `"fs_vfstype"` - "xfs",
- `"fs_mntops"` - "defaults",
- `"fs_freq"` - "0",
- `"fs_passno"` - "0"
},
{
"fs_spec": "/dev/mapper/centos-swap",
"fs_file": "swap",
"fs_vfstype": "swap",
"fs_mntops": "defaults",
"fs_freq": "0",
"fs_passno": "0"
- `"fs_spec"` - "/dev/mapper/centos-swap",
- `"fs_file"` - "swap",
- `"fs_vfstype"` - "swap",
- `"fs_mntops"` - "defaults",
- `"fs_freq"` - "0",
- `"fs_passno"` - "0"
}
]
<a id="jc.parsers.fstab.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.fstab.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.group"></a>
# jc.parsers.group
jc - JSON CLI output utility `/etc/group` file parser
Usage (cli):
@ -30,35 +32,36 @@ Schema:
}
]
Examples:
**Examples**:
$ cat /etc/group | jc --group -p
[
{
"group_name": "nobody",
"password": "*",
"gid": -2,
"members": []
- `"group_name"` - "nobody",
- `"password"` - "*",
- `"gid"` - -2,
- `"members"` - []
},
{
"group_name": "nogroup",
"password": "*",
"gid": -1,
"members": []
- `"group_name"` - "nogroup",
- `"password"` - "*",
- `"gid"` - -1,
- `"members"` - []
},
{
"group_name": "wheel",
"password": "*",
"gid": 0,
"members": [
- `"group_name"` - "wheel",
- `"password"` - "*",
- `"gid"` - 0,
- `"members"` - [
"root"
]
},
{
"group_name": "certusers",
"password": "*",
"gid": 29,
"members": [
- `"group_name"` - "certusers",
- `"password"` - "*",
- `"gid"` - 29,
- `"members"` - [
"root",
"_jabber",
"_postfix",
@ -73,34 +76,34 @@ Examples:
$ cat /etc/group | jc --group -p -r
[
{
"group_name": "nobody",
"password": "*",
"gid": "-2",
"members": [
- `"group_name"` - "nobody",
- `"password"` - "*",
- `"gid"` - "-2",
- `"members"` - [
""
]
},
{
"group_name": "nogroup",
"password": "*",
"gid": "-1",
"members": [
- `"group_name"` - "nogroup",
- `"password"` - "*",
- `"gid"` - "-1",
- `"members"` - [
""
]
},
{
"group_name": "wheel",
"password": "*",
"gid": "0",
"members": [
- `"group_name"` - "wheel",
- `"password"` - "*",
- `"gid"` - "0",
- `"members"` - [
"root"
]
},
{
"group_name": "certusers",
"password": "*",
"gid": "29",
"members": [
- `"group_name"` - "certusers",
- `"password"` - "*",
- `"gid"` - "29",
- `"members"` - [
"root",
"_jabber",
"_postfix",
@ -112,27 +115,36 @@ Examples:
...
]
<a id="jc.parsers.group.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.group.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.gshadow"></a>
# jc.parsers.gshadow
jc - JSON CLI output utility `/etc/gshadow` file parser
Usage (cli):
@ -32,21 +34,22 @@ Schema:
}
]
Examples:
**Examples**:
$ cat /etc/gshadow | jc --gshadow -p
[
{
"group_name": "root",
"password": "*",
"administrators": [],
"members": []
- `"group_name"` - "root",
- `"password"` - "*",
- `"administrators"` - [],
- `"members"` - []
},
{
"group_name": "adm",
"password": "*",
"administrators": [],
"members": [
- `"group_name"` - "adm",
- `"password"` - "*",
- `"administrators"` - [],
- `"members"` - [
"syslog",
"joeuser"
]
@ -57,22 +60,22 @@ Examples:
$ cat /etc/gshadow | jc --gshadow -p -r
[
{
"group_name": "root",
"password": "*",
"administrators": [
- `"group_name"` - "root",
- `"password"` - "*",
- `"administrators"` - [
""
],
"members": [
- `"members"` - [
""
]
},
{
"group_name": "adm",
"password": "*",
"administrators": [
- `"group_name"` - "adm",
- `"password"` - "*",
- `"administrators"` - [
""
],
"members": [
- `"members"` - [
"syslog",
"joeuser"
]
@ -80,27 +83,36 @@ Examples:
...
]
<a id="jc.parsers.gshadow.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.gshadow.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.hash"></a>
# jc.parsers.hash
jc - JSON CLI output utility `hash` command output parser
Usage (cli):
@ -26,41 +28,51 @@ Schema:
}
]
Examples:
**Examples**:
$ hash | jc --hash -p
[
{
"hits": 2,
"command": "/bin/cat"
- `"hits"` - 2,
- `"command"` - "/bin/cat"
},
{
"hits": 1,
"command": "/bin/ls"
- `"hits"` - 1,
- `"command"` - "/bin/ls"
}
]
<a id="jc.parsers.hash.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.hash.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.hashsum"></a>
# jc.parsers.hashsum
jc - JSON CLI output utility `hash sum` command output parser
This parser works with the following hash calculation utilities:
@ -40,58 +42,68 @@ Schema:
}
]
Examples:
**Examples**:
$ md5sum * | jc --hashsum -p
[
{
"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
"hash": "65fc958c1add637ec23c4b137aecf3d3"
- `"filename"` - "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
- `"hash"` - "65fc958c1add637ec23c4b137aecf3d3"
},
{
"filename": "digout",
"hash": "5b9312ee5aff080927753c63a347707d"
- `"filename"` - "digout",
- `"hash"` - "5b9312ee5aff080927753c63a347707d"
},
{
"filename": "dmidecode.out",
"hash": "716fd11c2ac00db109281f7110b8fb9d"
- `"filename"` - "dmidecode.out",
- `"hash"` - "716fd11c2ac00db109281f7110b8fb9d"
},
{
"filename": "file with spaces in the name",
"hash": "d41d8cd98f00b204e9800998ecf8427e"
- `"filename"` - "file with spaces in the name",
- `"hash"` - "d41d8cd98f00b204e9800998ecf8427e"
},
{
"filename": "id-centos.out",
"hash": "4295be239a14ad77ef3253103de976d2"
- `"filename"` - "id-centos.out",
- `"hash"` - "4295be239a14ad77ef3253103de976d2"
},
{
"filename": "ifcfg.json",
"hash": "01fda0d9ba9a75618b072e64ff512b43"
- `"filename"` - "ifcfg.json",
- `"hash"` - "01fda0d9ba9a75618b072e64ff512b43"
},
...
]
<a id="jc.parsers.hashsum.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.hashsum.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.hciconfig"></a>
# jc.parsers.hciconfig
jc - JSON CLI output utility `hciconfig` command output parser
Usage (cli):
@ -72,34 +74,35 @@ Schema:
}
]
Examples:
**Examples**:
$ hciconfig -a | jc --hciconfig -p
[
{
"device": "hci0",
"type": "Primary",
"bus": "USB",
"bd_address": "00:1A:7D:DA:71:13",
"acl_mtu": 310,
"acl_mtu_packets": 10,
"sco_mtu": 64,
"sco_mtu_packets": 8,
"state": [
- `"device"` - "hci0",
- `"type"` - "Primary",
- `"bus"` - "USB",
- `"bd_address"` - "00:1A:7D:DA:71:13",
- `"acl_mtu"` - 310,
- `"acl_mtu_packets"` - 10,
- `"sco_mtu"` - 64,
- `"sco_mtu_packets"` - 8,
- `"state"` - [
"UP",
"RUNNING"
],
"rx_bytes": 13905869,
"rx_acl": 0,
"rx_sco": 0,
"rx_events": 393300,
"rx_errors": 0,
"tx_bytes": 62629,
"tx_acl": 0,
"tx_sco": 0,
"tx_commands": 3893,
"tx_errors": 0,
"features": [
- `"rx_bytes"` - 13905869,
- `"rx_acl"` - 0,
- `"rx_sco"` - 0,
- `"rx_events"` - 393300,
- `"rx_errors"` - 0,
- `"tx_bytes"` - 62629,
- `"tx_acl"` - 0,
- `"tx_sco"` - 0,
- `"tx_commands"` - 3893,
- `"tx_errors"` - 0,
- `"features"` - [
"0xff",
"0xff",
"0x8f",
@ -109,7 +112,7 @@ Examples:
"0x5b",
"0x87"
],
"packet_type": [
- `"packet_type"` - [
"DM1",
"DM3",
"DM5",
@ -120,49 +123,49 @@ Examples:
"HV2",
"HV3"
],
"link_policy": [
- `"link_policy"` - [
"RSWITCH",
"HOLD",
"SNIFF",
"PARK"
],
"link_mode": [
- `"link_mode"` - [
"SLAVE",
"ACCEPT"
],
"name": "CSR8510 A10",
"class": "0x000000",
"service_classes": null,
"device_class": "Miscellaneous",
"hci_version": "4.0 (0x6)",
"hci_revision": "0x22bb",
"lmp_version": "4.0 (0x6)",
"lmp_subversion": "0x22bb",
"manufacturer": "Cambridge Silicon Radio (10)"
- `"name"` - "CSR8510 A10",
- `"class"` - "0x000000",
- `"service_classes"` - null,
- `"device_class"` - "Miscellaneous",
- `"hci_version"` - "4.0 (0x6)",
- `"hci_revision"` - "0x22bb",
- `"lmp_version"` - "4.0 (0x6)",
- `"lmp_subversion"` - "0x22bb",
- `"manufacturer"` - "Cambridge Silicon Radio (10)"
},
{
"device": "hci1",
"type": "Primary",
"bus": "USB",
"bd_address": "00:1A:7D:DA:71:13",
"acl_mtu": 310,
"acl_mtu_packets": 10,
"sco_mtu": 64,
"sco_mtu_packets": 8,
"state": [
- `"device"` - "hci1",
- `"type"` - "Primary",
- `"bus"` - "USB",
- `"bd_address"` - "00:1A:7D:DA:71:13",
- `"acl_mtu"` - 310,
- `"acl_mtu_packets"` - 10,
- `"sco_mtu"` - 64,
- `"sco_mtu_packets"` - 8,
- `"state"` - [
"DOWN"
],
"rx_bytes": 4388363,
"rx_acl": 0,
"rx_sco": 0,
"rx_events": 122021,
"rx_errors": 0,
"tx_bytes": 52350,
"tx_acl": 0,
"tx_sco": 0,
"tx_commands": 3480,
"tx_errors": 2,
"features": [
- `"rx_bytes"` - 4388363,
- `"rx_acl"` - 0,
- `"rx_sco"` - 0,
- `"rx_events"` - 122021,
- `"rx_errors"` - 0,
- `"tx_bytes"` - 52350,
- `"tx_acl"` - 0,
- `"tx_sco"` - 0,
- `"tx_commands"` - 3480,
- `"tx_errors"` - 2,
- `"features"` - [
"0xff",
"0xff",
"0x8f",
@ -172,7 +175,7 @@ Examples:
"0x5b",
"0x87"
],
"packet_type": [
- `"packet_type"` - [
"DM1",
"DM3",
"DM5",
@ -183,13 +186,13 @@ Examples:
"HV2",
"HV3"
],
"link_policy": [
- `"link_policy"` - [
"RSWITCH",
"HOLD",
"SNIFF",
"PARK"
],
"link_mode": [
- `"link_mode"` - [
"SLAVE",
"ACCEPT"
]
@ -199,29 +202,29 @@ Examples:
$ hciconfig -a | jc --hciconfig -p -r
[
{
"device": "hci0",
"type": "Primary",
"bus": "USB",
"bd_address": "00:1A:7D:DA:71:13",
"acl_mtu": "310",
"acl_mtu_packets": "10",
"sco_mtu": "64",
"sco_mtu_packets": "8",
"state": [
- `"device"` - "hci0",
- `"type"` - "Primary",
- `"bus"` - "USB",
- `"bd_address"` - "00:1A:7D:DA:71:13",
- `"acl_mtu"` - "310",
- `"acl_mtu_packets"` - "10",
- `"sco_mtu"` - "64",
- `"sco_mtu_packets"` - "8",
- `"state"` - [
"UP",
"RUNNING"
],
"rx_bytes": "13905869",
"rx_acl": "0",
"rx_sco": "0",
"rx_events": "393300",
"rx_errors": "0",
"tx_bytes": "62629",
"tx_acl": "0",
"tx_sco": "0",
"tx_commands": "3893",
"tx_errors": "0",
"features": [
- `"rx_bytes"` - "13905869",
- `"rx_acl"` - "0",
- `"rx_sco"` - "0",
- `"rx_events"` - "393300",
- `"rx_errors"` - "0",
- `"tx_bytes"` - "62629",
- `"tx_acl"` - "0",
- `"tx_sco"` - "0",
- `"tx_commands"` - "3893",
- `"tx_errors"` - "0",
- `"features"` - [
"0xff",
"0xff",
"0x8f",
@ -231,7 +234,7 @@ Examples:
"0x5b",
"0x87"
],
"packet_type": [
- `"packet_type"` - [
"DM1",
"DM3",
"DM5",
@ -242,51 +245,51 @@ Examples:
"HV2",
"HV3"
],
"link_policy": [
- `"link_policy"` - [
"RSWITCH",
"HOLD",
"SNIFF",
"PARK"
],
"link_mode": [
- `"link_mode"` - [
"SLAVE",
"ACCEPT"
],
"name": "CSR8510 A10",
"class": "0x000000",
"service_classes": [
- `"name"` - "CSR8510 A10",
- `"class"` - "0x000000",
- `"service_classes"` - [
"Unspecified"
],
"device_class": "Miscellaneous",
"hci_version": "4.0 (0x6)",
"hci_revision": "0x22bb",
"lmp_version": "4.0 (0x6)",
"lmp_subversion": "0x22bb",
"manufacturer": "Cambridge Silicon Radio (10)"
- `"device_class"` - "Miscellaneous",
- `"hci_version"` - "4.0 (0x6)",
- `"hci_revision"` - "0x22bb",
- `"lmp_version"` - "4.0 (0x6)",
- `"lmp_subversion"` - "0x22bb",
- `"manufacturer"` - "Cambridge Silicon Radio (10)"
},
{
"device": "hci1",
"type": "Primary",
"bus": "USB",
"bd_address": "00:1A:7D:DA:71:13",
"acl_mtu": "310",
"acl_mtu_packets": "10",
"sco_mtu": "64",
"sco_mtu_packets": "8",
"state": [
- `"device"` - "hci1",
- `"type"` - "Primary",
- `"bus"` - "USB",
- `"bd_address"` - "00:1A:7D:DA:71:13",
- `"acl_mtu"` - "310",
- `"acl_mtu_packets"` - "10",
- `"sco_mtu"` - "64",
- `"sco_mtu_packets"` - "8",
- `"state"` - [
"DOWN"
],
"rx_bytes": "4388363",
"rx_acl": "0",
"rx_sco": "0",
"rx_events": "122021",
"rx_errors": "0",
"tx_bytes": "52350",
"tx_acl": "0",
"tx_sco": "0",
"tx_commands": "3480",
"tx_errors": "2",
"features": [
- `"rx_bytes"` - "4388363",
- `"rx_acl"` - "0",
- `"rx_sco"` - "0",
- `"rx_events"` - "122021",
- `"rx_errors"` - "0",
- `"tx_bytes"` - "52350",
- `"tx_acl"` - "0",
- `"tx_sco"` - "0",
- `"tx_commands"` - "3480",
- `"tx_errors"` - "2",
- `"features"` - [
"0xff",
"0xff",
"0x8f",
@ -296,7 +299,7 @@ Examples:
"0x5b",
"0x87"
],
"packet_type": [
- `"packet_type"` - [
"DM1",
"DM3",
"DM5",
@ -307,40 +310,49 @@ Examples:
"HV2",
"HV3"
],
"link_policy": [
- `"link_policy"` - [
"RSWITCH",
"HOLD",
"SNIFF",
"PARK"
],
"link_mode": [
- `"link_mode"` - [
"SLAVE",
"ACCEPT"
]
}
]
<a id="jc.parsers.hciconfig.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.hciconfig.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.history"></a>
# jc.parsers.history
jc - JSON CLI output utility `history` command output parser
This parser will output a list of dictionaries each containing `line` and
@ -34,59 +36,69 @@ Schema:
}
]
Examples:
**Examples**:
$ history | jc --history -p
[
{
"line": 118,
"command": "sleep 100"
- `"line"` - 118,
- `"command"` - "sleep 100"
},
{
"line": 119,
"command": "ls /bin"
- `"line"` - 119,
- `"command"` - "ls /bin"
},
{
"line": 120,
"command": "echo "hello""
- `"line"` - 120,
- `"command"` - "echo \"hello\""
},
{
"line": 121,
"command": "docker images"
- `"line"` - 121,
- `"command"` - "docker images"
},
...
]
$ history | jc --history -p -r
{
"118": "sleep 100",
"119": "ls /bin",
"120": "echo "hello"",
"121": "docker images",
- `"118"` - "sleep 100",
- `"119"` - "ls /bin",
- `"120"` - "echo \"hello\"",
- `"121"` - "docker images",
...
}
<a id="jc.parsers.history.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.history.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary of raw structured data or
List of Dictionaries of processed structured data

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.hosts"></a>
# jc.parsers.hosts
jc - JSON CLI output utility `/etc/hosts` file parser
Usage (cli):
@ -28,76 +30,86 @@ Schema:
}
]
Examples:
**Examples**:
$ cat /etc/hosts | jc --hosts -p
[
{
"ip": "127.0.0.1",
"hostname": [
- `"ip"` - "127.0.0.1",
- `"hostname"` - [
"localhost"
]
},
{
"ip": "127.0.1.1",
"hostname": [
- `"ip"` - "127.0.1.1",
- `"hostname"` - [
"root-ubuntu"
]
},
{
"ip": "::1",
"hostname": [
- `"ip"` - "::1",
- `"hostname"` - [
"ip6-localhost",
"ip6-loopback"
]
},
{
"ip": "fe00::0",
"hostname": [
- `"ip"` - "fe00::0",
- `"hostname"` - [
"ip6-localnet"
]
},
{
"ip": "ff00::0",
"hostname": [
- `"ip"` - "ff00::0",
- `"hostname"` - [
"ip6-mcastprefix"
]
},
{
"ip": "ff02::1",
"hostname": [
- `"ip"` - "ff02::1",
- `"hostname"` - [
"ip6-allnodes"
]
},
{
"ip": "ff02::2",
"hostname": [
- `"ip"` - "ff02::2",
- `"hostname"` - [
"ip6-allrouters"
]
}
]
<a id="jc.parsers.hosts.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.hosts.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.id"></a>
# jc.parsers.id
jc - JSON CLI output utility `id` command output parser
Usage (cli):
@ -50,85 +52,95 @@ Schema:
}
}
Examples:
**Examples**:
$ id | jc --id -p
{
"uid": {
"id": 1000,
"name": "joeuser"
- `"uid"` - {
- `"id"` - 1000,
- `"name"` - "joeuser"
},
"gid": {
"id": 1000,
"name": "joeuser"
- `"gid"` - {
- `"id"` - 1000,
- `"name"` - "joeuser"
},
"groups": [
- `"groups"` - [
{
"id": 1000,
"name": "joeuser"
- `"id"` - 1000,
- `"name"` - "joeuser"
},
{
"id": 10,
"name": "wheel"
- `"id"` - 10,
- `"name"` - "wheel"
}
],
"context": {
"user": "unconfined_u",
"role": "unconfined_r",
"type": "unconfined_t",
"level": "s0-s0:c0.c1023"
- `"context"` - {
- `"user"` - "unconfined_u",
- `"role"` - "unconfined_r",
- `"type"` - "unconfined_t",
- `"level"` - "s0-s0:c0.c1023"
}
}
$ id | jc --id -p -r
{
"uid": {
"id": "1000",
"name": "joeuser"
- `"uid"` - {
- `"id"` - "1000",
- `"name"` - "joeuser"
},
"gid": {
"id": "1000",
"name": "joeuser"
- `"gid"` - {
- `"id"` - "1000",
- `"name"` - "joeuser"
},
"groups": [
- `"groups"` - [
{
"id": "1000",
"name": "joeuser"
- `"id"` - "1000",
- `"name"` - "joeuser"
},
{
"id": "10",
"name": "wheel"
- `"id"` - "10",
- `"name"` - "wheel"
}
],
"context": {
"user": "unconfined_u",
"role": "unconfined_r",
"type": "unconfined_t",
"level": "s0-s0:c0.c1023"
- `"context"` - {
- `"user"` - "unconfined_u",
- `"role"` - "unconfined_r",
- `"type"` - "unconfined_t",
- `"level"` - "s0-s0:c0.c1023"
}
}
<a id="jc.parsers.id.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.id.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ifconfig"></a>
# jc.parsers.ifconfig
jc - JSON CLI output utility `ifconfig` command output parser
Note: No `ifconfig` options are supported.
@ -58,158 +60,262 @@ Schema:
}
]
Examples:
**Examples**:
$ ifconfig | jc --ifconfig -p
[
{
"name": "ens33",
"flags": 4163,
"state": [
- `"name"` - "ens33",
- `"flags"` - 4163,
- `"state"` - [
"UP",
"BROADCAST",
"RUNNING",
"MULTICAST"
],
"mtu": 1500,
"ipv4_addr": "192.168.71.137",
"ipv4_mask": "255.255.255.0",
"ipv4_bcast": "192.168.71.255",
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
"ipv6_mask": 64,
"ipv6_scope": "0x20",
"mac_addr": "00:0c:29:3b:58:0e",
"type": "Ethernet",
"rx_packets": 8061,
"rx_bytes": 1514413,
"rx_errors": 0,
"rx_dropped": 0,
"rx_overruns": 0,
"rx_frame": 0,
"tx_packets": 4502,
"tx_bytes": 866622,
"tx_errors": 0,
"tx_dropped": 0,
"tx_overruns": 0,
"tx_carrier": 0,
"tx_collisions": 0,
"metric": null
- `"mtu"` - 1500,
- `"ipv4_addr"` - "192.168.71.137",
- `"ipv4_mask"` - "255.255.255.0",
- `"ipv4_bcast"` - "192.168.71.255",
- `"ipv6_addr"` - "fe80::c1cb:715d:bc3e:b8a0",
- `"ipv6_mask"` - 64,
- `"ipv6_scope"` - "0x20",
- `"mac_addr"` - "00:0c:29:3b:58:0e",
- `"type"` - "Ethernet",
- `"rx_packets"` - 8061,
- `"rx_bytes"` - 1514413,
- `"rx_errors"` - 0,
- `"rx_dropped"` - 0,
- `"rx_overruns"` - 0,
- `"rx_frame"` - 0,
- `"tx_packets"` - 4502,
- `"tx_bytes"` - 866622,
- `"tx_errors"` - 0,
- `"tx_dropped"` - 0,
- `"tx_overruns"` - 0,
- `"tx_carrier"` - 0,
- `"tx_collisions"` - 0,
- `"metric"` - null
},
{
"name": "lo",
"flags": 73,
"state": [
- `"name"` - "lo",
- `"flags"` - 73,
- `"state"` - [
"UP",
"LOOPBACK",
"RUNNING"
],
"mtu": 65536,
"ipv4_addr": "127.0.0.1",
"ipv4_mask": "255.0.0.0",
"ipv4_bcast": null,
"ipv6_addr": "::1",
"ipv6_mask": 128,
"ipv6_scope": "0x10",
"mac_addr": null,
"type": "Local Loopback",
"rx_packets": 73,
"rx_bytes": 6009,
"rx_errors": 0,
"rx_dropped": 0,
"rx_overruns": 0,
"rx_frame": 0,
"tx_packets": 73,
"tx_bytes": 6009,
"tx_errors": 0,
"tx_dropped": 0,
"tx_overruns": 0,
"tx_carrier": 0,
"tx_collisions": 0,
"metric": null
- `"mtu"` - 65536,
- `"ipv4_addr"` - "127.0.0.1",
- `"ipv4_mask"` - "255.0.0.0",
- `"ipv4_bcast"` - null,
- `"ipv6_addr"` - "::1",
- `"ipv6_mask"` - 128,
- `"ipv6_scope"` - "0x10",
- `"mac_addr"` - null,
- `"type"` - "Local Loopback",
- `"rx_packets"` - 73,
- `"rx_bytes"` - 6009,
- `"rx_errors"` - 0,
- `"rx_dropped"` - 0,
- `"rx_overruns"` - 0,
- `"rx_frame"` - 0,
- `"tx_packets"` - 73,
- `"tx_bytes"` - 6009,
- `"tx_errors"` - 0,
- `"tx_dropped"` - 0,
- `"tx_overruns"` - 0,
- `"tx_carrier"` - 0,
- `"tx_collisions"` - 0,
- `"metric"` - null
}
]
$ ifconfig | jc --ifconfig -p -r
[
{
"name": "ens33",
"flags": "4163",
"state": "UP,BROADCAST,RUNNING,MULTICAST",
"mtu": "1500",
"ipv4_addr": "192.168.71.137",
"ipv4_mask": "255.255.255.0",
"ipv4_bcast": "192.168.71.255",
"ipv6_addr": "fe80::c1cb:715d:bc3e:b8a0",
"ipv6_mask": "64",
"ipv6_scope": "0x20",
"mac_addr": "00:0c:29:3b:58:0e",
"type": "Ethernet",
"rx_packets": "8061",
"rx_bytes": "1514413",
"rx_errors": "0",
"rx_dropped": "0",
"rx_overruns": "0",
"rx_frame": "0",
"tx_packets": "4502",
"tx_bytes": "866622",
"tx_errors": "0",
"tx_dropped": "0",
"tx_overruns": "0",
"tx_carrier": "0",
"tx_collisions": "0",
"metric": null
- `"name"` - "ens33",
- `"flags"` - "4163",
- `"state"` - "UP,BROADCAST,RUNNING,MULTICAST",
- `"mtu"` - "1500",
- `"ipv4_addr"` - "192.168.71.137",
- `"ipv4_mask"` - "255.255.255.0",
- `"ipv4_bcast"` - "192.168.71.255",
- `"ipv6_addr"` - "fe80::c1cb:715d:bc3e:b8a0",
- `"ipv6_mask"` - "64",
- `"ipv6_scope"` - "0x20",
- `"mac_addr"` - "00:0c:29:3b:58:0e",
- `"type"` - "Ethernet",
- `"rx_packets"` - "8061",
- `"rx_bytes"` - "1514413",
- `"rx_errors"` - "0",
- `"rx_dropped"` - "0",
- `"rx_overruns"` - "0",
- `"rx_frame"` - "0",
- `"tx_packets"` - "4502",
- `"tx_bytes"` - "866622",
- `"tx_errors"` - "0",
- `"tx_dropped"` - "0",
- `"tx_overruns"` - "0",
- `"tx_carrier"` - "0",
- `"tx_collisions"` - "0",
- `"metric"` - null
},
{
"name": "lo",
"flags": "73",
"state": "UP,LOOPBACK,RUNNING",
"mtu": "65536",
"ipv4_addr": "127.0.0.1",
"ipv4_mask": "255.0.0.0",
"ipv4_bcast": null,
"ipv6_addr": "::1",
"ipv6_mask": "128",
"ipv6_scope": "0x10",
"mac_addr": null,
"type": "Local Loopback",
"rx_packets": "73",
"rx_bytes": "6009",
"rx_errors": "0",
"rx_dropped": "0",
"rx_overruns": "0",
"rx_frame": "0",
"tx_packets": "73",
"tx_bytes": "6009",
"tx_errors": "0",
"tx_dropped": "0",
"tx_overruns": "0",
"tx_carrier": "0",
"tx_collisions": "0",
"metric": null
- `"name"` - "lo",
- `"flags"` - "73",
- `"state"` - "UP,LOOPBACK,RUNNING",
- `"mtu"` - "65536",
- `"ipv4_addr"` - "127.0.0.1",
- `"ipv4_mask"` - "255.0.0.0",
- `"ipv4_bcast"` - null,
- `"ipv6_addr"` - "::1",
- `"ipv6_mask"` - "128",
- `"ipv6_scope"` - "0x10",
- `"mac_addr"` - null,
- `"type"` - "Local Loopback",
- `"rx_packets"` - "73",
- `"rx_bytes"` - "6009",
- `"rx_errors"` - "0",
- `"rx_dropped"` - "0",
- `"rx_overruns"` - "0",
- `"rx_frame"` - "0",
- `"tx_packets"` - "73",
- `"tx_bytes"` - "6009",
- `"tx_errors"` - "0",
- `"tx_dropped"` - "0",
- `"tx_overruns"` - "0",
- `"tx_carrier"` - "0",
- `"tx_collisions"` - "0",
- `"metric"` - null
}
]
<a id="jc.parsers.ifconfig.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ifconfig._IfconfigParser"></a>
## \_IfconfigParser Objects
```python
parse(data, raw=False, quiet=False)
class _IfconfigParser(object)
```
ifconfig parser module written by threeheadedknight@protonmail.com
<a id="jc.parsers.ifconfig._IfconfigParser.__init__"></a>
#### \_\_init\_\_
```python
def __init__(console_output)
```
**Arguments**:
- `console_output`:
<a id="jc.parsers.ifconfig._IfconfigParser.list_interfaces"></a>
#### list\_interfaces
```python
def list_interfaces()
```
<a id="jc.parsers.ifconfig._IfconfigParser.count_interfaces"></a>
#### count\_interfaces
```python
def count_interfaces()
```
<a id="jc.parsers.ifconfig._IfconfigParser.filter_interfaces"></a>
#### filter\_interfaces
```python
def filter_interfaces(**kwargs)
```
**Arguments**:
- `kwargs`:
<a id="jc.parsers.ifconfig._IfconfigParser.get_interface"></a>
#### get\_interface
```python
def get_interface(name)
```
**Arguments**:
- `name`:
<a id="jc.parsers.ifconfig._IfconfigParser.get_interfaces"></a>
#### get\_interfaces
```python
def get_interfaces()
```
<a id="jc.parsers.ifconfig._IfconfigParser.is_available"></a>
#### is\_available
```python
def is_available(name)
```
**Arguments**:
- `name`:
<a id="jc.parsers.ifconfig._IfconfigParser.parser"></a>
#### parser
```python
def parser(source_data)
```
**Arguments**:
- `source_data`:
<a id="jc.parsers.ifconfig.parse"></a>
#### parse
```python
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ini"></a>
# jc.parsers.ini
jc - JSON CLI output utility `INI` file parser
Parses standard `INI` files and files containing simple key/value pairs.
@ -35,7 +37,8 @@ Schema:
"key2": string
}
Examples:
**Examples**:
$ cat example.ini
[DEFAULT]
@ -53,43 +56,52 @@ Examples:
$ cat example.ini | jc --ini -p
{
"bitbucket.org": {
"serveraliveinterval": "45",
"compression": "yes",
"compressionlevel": "9",
"forwardx11": "yes",
"user": "hg"
- `"bitbucket.org"` - {
- `"serveraliveinterval"` - "45",
- `"compression"` - "yes",
- `"compressionlevel"` - "9",
- `"forwardx11"` - "yes",
- `"user"` - "hg"
},
"topsecret.server.com": {
"serveraliveinterval": "45",
"compression": "yes",
"compressionlevel": "9",
"forwardx11": "no",
"port": "50022"
- `"topsecret.server.com"` - {
- `"serveraliveinterval"` - "45",
- `"compression"` - "yes",
- `"compressionlevel"` - "9",
- `"forwardx11"` - "no",
- `"port"` - "50022"
}
}
<a id="jc.parsers.ini.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ini.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary representing the ini file

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.iostat"></a>
# jc.parsers.iostat
jc - JSON CLI output utility `iostat` command output parser
Note: `iostat` version 11 and higher include a JSON output option
@ -80,109 +82,119 @@ Schema:
}
]
Examples:
**Examples**:
$ iostat | jc --iostat -p
[
{
"percent_user": 0.15,
"percent_nice": 0.0,
"percent_system": 0.18,
"percent_iowait": 0.0,
"percent_steal": 0.0,
"percent_idle": 99.67,
"type": "cpu"
- `"percent_user"` - 0.15,
- `"percent_nice"` - 0.0,
- `"percent_system"` - 0.18,
- `"percent_iowait"` - 0.0,
- `"percent_steal"` - 0.0,
- `"percent_idle"` - 99.67,
- `"type"` - "cpu"
},
{
"device": "sda",
"tps": 0.29,
"kb_read_s": 7.22,
"kb_wrtn_s": 1.25,
"kb_read": 194341,
"kb_wrtn": 33590,
"type": "device"
- `"device"` - "sda",
- `"tps"` - 0.29,
- `"kb_read_s"` - 7.22,
- `"kb_wrtn_s"` - 1.25,
- `"kb_read"` - 194341,
- `"kb_wrtn"` - 33590,
- `"type"` - "device"
},
{
"device": "dm-0",
"tps": 0.29,
"kb_read_s": 5.99,
"kb_wrtn_s": 1.17,
"kb_read": 161361,
"kb_wrtn": 31522,
"type": "device"
- `"device"` - "dm-0",
- `"tps"` - 0.29,
- `"kb_read_s"` - 5.99,
- `"kb_wrtn_s"` - 1.17,
- `"kb_read"` - 161361,
- `"kb_wrtn"` - 31522,
- `"type"` - "device"
},
{
"device": "dm-1",
"tps": 0.0,
"kb_read_s": 0.08,
"kb_wrtn_s": 0.0,
"kb_read": 2204,
"kb_wrtn": 0,
"type": "device"
- `"device"` - "dm-1",
- `"tps"` - 0.0,
- `"kb_read_s"` - 0.08,
- `"kb_wrtn_s"` - 0.0,
- `"kb_read"` - 2204,
- `"kb_wrtn"` - 0,
- `"type"` - "device"
}
]
$ iostat | jc --iostat -p -r
[
{
"percent_user": "0.15",
"percent_nice": "0.00",
"percent_system": "0.18",
"percent_iowait": "0.00",
"percent_steal": "0.00",
"percent_idle": "99.67",
"type": "cpu"
- `"percent_user"` - "0.15",
- `"percent_nice"` - "0.00",
- `"percent_system"` - "0.18",
- `"percent_iowait"` - "0.00",
- `"percent_steal"` - "0.00",
- `"percent_idle"` - "99.67",
- `"type"` - "cpu"
},
{
"device": "sda",
"tps": "0.29",
"kb_read_s": "7.22",
"kb_wrtn_s": "1.25",
"kb_read": "194341",
"kb_wrtn": "33590",
"type": "device"
- `"device"` - "sda",
- `"tps"` - "0.29",
- `"kb_read_s"` - "7.22",
- `"kb_wrtn_s"` - "1.25",
- `"kb_read"` - "194341",
- `"kb_wrtn"` - "33590",
- `"type"` - "device"
},
{
"device": "dm-0",
"tps": "0.29",
"kb_read_s": "5.99",
"kb_wrtn_s": "1.17",
"kb_read": "161361",
"kb_wrtn": "31522",
"type": "device"
- `"device"` - "dm-0",
- `"tps"` - "0.29",
- `"kb_read_s"` - "5.99",
- `"kb_wrtn_s"` - "1.17",
- `"kb_read"` - "161361",
- `"kb_wrtn"` - "31522",
- `"type"` - "device"
},
{
"device": "dm-1",
"tps": "0.00",
"kb_read_s": "0.08",
"kb_wrtn_s": "0.00",
"kb_read": "2204",
"kb_wrtn": "0",
"type": "device"
- `"device"` - "dm-1",
- `"tps"` - "0.00",
- `"kb_read_s"` - "0.08",
- `"kb_wrtn_s"` - "0.00",
- `"kb_read"` - "2204",
- `"kb_wrtn"` - "0",
- `"type"` - "device"
}
]
<a id="jc.parsers.iostat.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.iostat.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.iostat_s"></a>
# jc.parsers.iostat\_s
# jc.parsers.iostat_s
jc - JSON CLI output utility `iostat` command output streaming parser
> This streaming parser outputs JSON Lines
@ -91,7 +93,8 @@ Schema:
}
}
Examples:
**Examples**:
$ iostat | jc --iostat-s
{"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,...}
@ -103,34 +106,45 @@ Examples:
{"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10"...}
...
<a id="jc.parsers.iostat_s.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.iostat_s.parse"></a>
#### 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.
Parameters:
**Arguments**:
data: (iterable) line-based text data to parse
- `data` - (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
**Yields**:
Yields:
Dictionary. Raw or processed structured data.
Returns:
**Returns**:
Iterator object

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.iptables"></a>
# jc.parsers.iptables
jc - JSON CLI output utility `iptables` command output parser
Supports `-vLn` and `--line-numbers` for all tables.
@ -46,61 +48,62 @@ Schema:
}
]
Examples:
**Examples**:
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p
[
{
"chain": "PREROUTING",
"rules": [
- `"chain"` - "PREROUTING",
- `"rules"` - [
{
"num": 1,
"pkts": 2183,
"bytes": 186000,
"target": "PREROUTING_direct",
"prot": "all",
"opt": null,
"in": "any",
"out": "any",
"source": "anywhere",
"destination": "anywhere"
- `"num"` - 1,
- `"pkts"` - 2183,
- `"bytes"` - 186000,
- `"target"` - "PREROUTING_direct",
- `"prot"` - "all",
- `"opt"` - null,
- `"in"` - "any",
- `"out"` - "any",
- `"source"` - "anywhere",
- `"destination"` - "anywhere"
},
{
"num": 2,
"pkts": 2183,
"bytes": 186000,
"target": "PREROUTING_ZONES_SOURCE",
"prot": "all",
"opt": null,
"in": "any",
"out": "any",
"source": "anywhere",
"destination": "anywhere"
- `"num"` - 2,
- `"pkts"` - 2183,
- `"bytes"` - 186000,
- `"target"` - "PREROUTING_ZONES_SOURCE",
- `"prot"` - "all",
- `"opt"` - null,
- `"in"` - "any",
- `"out"` - "any",
- `"source"` - "anywhere",
- `"destination"` - "anywhere"
},
{
"num": 3,
"pkts": 2183,
"bytes": 186000,
"target": "PREROUTING_ZONES",
"prot": "all",
"opt": null,
"in": "any",
"out": "any",
"source": "anywhere",
"destination": "anywhere"
- `"num"` - 3,
- `"pkts"` - 2183,
- `"bytes"` - 186000,
- `"target"` - "PREROUTING_ZONES",
- `"prot"` - "all",
- `"opt"` - null,
- `"in"` - "any",
- `"out"` - "any",
- `"source"` - "anywhere",
- `"destination"` - "anywhere"
},
{
"num": 4,
"pkts": 0,
"bytes": 0,
"target": "DOCKER",
"prot": "all",
"opt": null,
"in": "any",
"out": "any",
"source": "anywhere",
"destination": "anywhere",
"options": "ADDRTYPE match dst-type LOCAL"
- `"num"` - 4,
- `"pkts"` - 0,
- `"bytes"` - 0,
- `"target"` - "DOCKER",
- `"prot"` - "all",
- `"opt"` - null,
- `"in"` - "any",
- `"out"` - "any",
- `"source"` - "anywhere",
- `"destination"` - "anywhere",
- `"options"` - "ADDRTYPE match dst-type LOCAL"
}
]
},
@ -110,83 +113,92 @@ Examples:
$ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r
[
{
"chain": "PREROUTING",
"rules": [
- `"chain"` - "PREROUTING",
- `"rules"` - [
{
"num": "1",
"pkts": "2183",
"bytes": "186K",
"target": "PREROUTING_direct",
"prot": "all",
"opt": "--",
"in": "any",
"out": "any",
"source": "anywhere",
"destination": "anywhere"
- `"num"` - "1",
- `"pkts"` - "2183",
- `"bytes"` - "186K",
- `"target"` - "PREROUTING_direct",
- `"prot"` - "all",
- `"opt"` - "--",
- `"in"` - "any",
- `"out"` - "any",
- `"source"` - "anywhere",
- `"destination"` - "anywhere"
},
{
"num": "2",
"pkts": "2183",
"bytes": "186K",
"target": "PREROUTING_ZONES_SOURCE",
"prot": "all",
"opt": "--",
"in": "any",
"out": "any",
"source": "anywhere",
"destination": "anywhere"
- `"num"` - "2",
- `"pkts"` - "2183",
- `"bytes"` - "186K",
- `"target"` - "PREROUTING_ZONES_SOURCE",
- `"prot"` - "all",
- `"opt"` - "--",
- `"in"` - "any",
- `"out"` - "any",
- `"source"` - "anywhere",
- `"destination"` - "anywhere"
},
{
"num": "3",
"pkts": "2183",
"bytes": "186K",
"target": "PREROUTING_ZONES",
"prot": "all",
"opt": "--",
"in": "any",
"out": "any",
"source": "anywhere",
"destination": "anywhere"
- `"num"` - "3",
- `"pkts"` - "2183",
- `"bytes"` - "186K",
- `"target"` - "PREROUTING_ZONES",
- `"prot"` - "all",
- `"opt"` - "--",
- `"in"` - "any",
- `"out"` - "any",
- `"source"` - "anywhere",
- `"destination"` - "anywhere"
},
{
"num": "4",
"pkts": "0",
"bytes": "0",
"target": "DOCKER",
"prot": "all",
"opt": "--",
"in": "any",
"out": "any",
"source": "anywhere",
"destination": "anywhere",
"options": "ADDRTYPE match dst-type LOCAL"
- `"num"` - "4",
- `"pkts"` - "0",
- `"bytes"` - "0",
- `"target"` - "DOCKER",
- `"prot"` - "all",
- `"opt"` - "--",
- `"in"` - "any",
- `"out"` - "any",
- `"source"` - "anywhere",
- `"destination"` - "anywhere",
- `"options"` - "ADDRTYPE match dst-type LOCAL"
}
]
},
...
]
<a id="jc.parsers.iptables.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.iptables.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.iw_scan"></a>
# jc.parsers.iw\_scan
# jc.parsers.iw_scan
jc - JSON CLI output utility `iw dev <device> scan` command output parser
This parser is considered beta quality. Not all fields are parsed and there
@ -34,17 +36,18 @@ Schema:
}
]
Examples:
**Examples**:
$ iw dev wlan0 scan | jc --iw-scan -p
[
{
"bssid": "71:31:72:65:e1:a2",
"interface": "wlan0",
"freq": 2462,
"capability": "ESS Privacy ShortSlotTime (0x0411)",
"ssid": "WLAN-1234",
"supported_rates": [
- `"bssid"` - "71:31:72:65:e1:a2",
- `"interface"` - "wlan0",
- `"freq"` - 2462,
- `"capability"` - "ESS Privacy ShortSlotTime (0x0411)",
- `"ssid"` - "WLAN-1234",
- `"supported_rates"` - [
1.0,
2.0,
5.5,
@ -54,97 +57,106 @@ Examples:
36.0,
54.0
],
"erp": "<no flags>",
"erp_d4.0": "<no flags>",
"rsn": "Version: 1",
"group_cipher": "CCMP",
"pairwise_ciphers": "CCMP",
"authentication_suites": "PSK",
"capabilities": "0x186c",
"extended_supported_rates": [
- `"erp"` - "<no flags>",
- `"erp_d4.0"` - "<no flags>",
- `"rsn"` - "Version: 1",
- `"group_cipher"` - "CCMP",
- `"pairwise_ciphers"` - "CCMP",
- `"authentication_suites"` - "PSK",
- `"capabilities"` - "0x186c",
- `"extended_supported_rates"` - [
6.0,
9.0,
12.0,
48.0
],
"ht_rx_mcs_rate_indexes_supported": "0-15",
"primary_channel": 11,
"secondary_channel_offset": "no secondary",
"rifs": 1,
"ht_protection": "no",
"non-gf_present": 1,
"obss_non-gf_present": 0,
"dual_beacon": 0,
"dual_cts_protection": 0,
"stbc_beacon": 0,
"l-sig_txop_prot": 0,
"pco_active": 0,
"pco_phase": 0,
"bss_width_channel_transition_delay_factor": 5,
"extended_capabilities": "HT Information Exchange Supported",
"wmm": "Parameter version 1",
"be": "CW 15-1023, AIFSN 3",
"bk": "CW 15-1023, AIFSN 7",
"vi": "CW 7-15, AIFSN 2, TXOP 3008 usec",
"vo": "CW 3-7, AIFSN 2, TXOP 1504 usec",
"wps": "Version: 1.0",
"wi-fi_protected_setup_state": "2 (Configured)",
"selected_registrar": "0x0",
"response_type": "3 (AP)",
"uuid": "00000000-0000-0003-0000-75317074f1a2",
"manufacturer": "Corporation",
"model": "VGV8539JW",
"model_number": "1.47.000",
"serial_number": "J144024542",
"primary_device_type": "6-0050f204-1",
"device_name": "Wireless Router(WFA)",
"config_methods": "Label, PBC",
"rf_bands": "0x3",
"tsf_usec": 212098649788,
"sta_channel_width_mhz": 20,
"passive_dwell_tus": 20,
"active_dwell_tus": 10,
"channel_width_trigger_scan_interval_s": 300,
"scan_passive_total_per_channel_tus": 200,
"scan_active_total_per_channel_tus": 20,
"beacon_interval_tus": 100,
"signal_dbm": -80.0,
"last_seen_ms": 11420,
"selected_rates": [
- `"ht_rx_mcs_rate_indexes_supported"` - "0-15",
- `"primary_channel"` - 11,
- `"secondary_channel_offset"` - "no secondary",
- `"rifs"` - 1,
- `"ht_protection"` - "no",
- `"non-gf_present"` - 1,
- `"obss_non-gf_present"` - 0,
- `"dual_beacon"` - 0,
- `"dual_cts_protection"` - 0,
- `"stbc_beacon"` - 0,
- `"l-sig_txop_prot"` - 0,
- `"pco_active"` - 0,
- `"pco_phase"` - 0,
- `"bss_width_channel_transition_delay_factor"` - 5,
- `"extended_capabilities"` - "HT Information Exchange Supported",
- `"wmm"` - "Parameter version 1",
- `"be"` - "CW 15-1023, AIFSN 3",
- `"bk"` - "CW 15-1023, AIFSN 7",
- `"vi"` - "CW 7-15, AIFSN 2, TXOP 3008 usec",
- `"vo"` - "CW 3-7, AIFSN 2, TXOP 1504 usec",
- `"wps"` - "Version: 1.0",
- `"wi-fi_protected_setup_state"` - "2 (Configured)",
- `"selected_registrar"` - "0x0",
- `"response_type"` - "3 (AP)",
- `"uuid"` - "00000000-0000-0003-0000-75317074f1a2",
- `"manufacturer"` - "Corporation",
- `"model"` - "VGV8539JW",
- `"model_number"` - "1.47.000",
- `"serial_number"` - "J144024542",
- `"primary_device_type"` - "6-0050f204-1",
- `"device_name"` - "Wireless Router(WFA)",
- `"config_methods"` - "Label, PBC",
- `"rf_bands"` - "0x3",
- `"tsf_usec"` - 212098649788,
- `"sta_channel_width_mhz"` - 20,
- `"passive_dwell_tus"` - 20,
- `"active_dwell_tus"` - 10,
- `"channel_width_trigger_scan_interval_s"` - 300,
- `"scan_passive_total_per_channel_tus"` - 200,
- `"scan_active_total_per_channel_tus"` - 20,
- `"beacon_interval_tus"` - 100,
- `"signal_dbm"` - -80.0,
- `"last_seen_ms"` - 11420,
- `"selected_rates"` - [
1.0,
2.0,
5.5,
11.0
],
"obss_scan_activity_threshold_percent": 0.25,
"ds_parameter_set_channel": 11,
"max_amsdu_length_bytes": 7935,
"minimum_rx_ampdu_time_spacing_usec": 16
- `"obss_scan_activity_threshold_percent"` - 0.25,
- `"ds_parameter_set_channel"` - 11,
- `"max_amsdu_length_bytes"` - 7935,
- `"minimum_rx_ampdu_time_spacing_usec"` - 16
},
...
]
<a id="jc.parsers.iw_scan.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.iw_scan.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.jar_manifest"></a>
# jc.parsers.jar\_manifest
# jc.parsers.jar_manifest
jc - JSON CLI output utility `MANIFEST.MF` file parser
Usage (cli):
@ -26,81 +28,91 @@ Schema:
}
]
Examples:
**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...",
"Manifest_Version": "1.0",
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
"Bundle_SymbolicName": "org.apache.logging.log4j.core",
"Built_By": "matt",
"Bnd_LastModified": "1639373735804",
"Implementation_Vendor_Id": "org.apache.logging.log4j",
"Specification_Title": "Apache Log4j Core",
"Log4jReleaseManager": "Matt Sicker",
- `"Import_Package"` - "com.conversantmedia.util.concurrent;resoluti...",
- `"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",
- `"Built_By"` - "matt",
- `"Bnd_LastModified"` - "1639373735804",
- `"Implementation_Vendor_Id"` - "org.apache.logging.log4j",
- `"Specification_Title"` - "Apache Log4j Core",
- `"Log4jReleaseManager"` - "Matt Sicker",
...
}
]
$ 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
[
...
{
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-so...",
"Manifest_Version": "1.0",
"Built_By": "matt",
"Created_By": "Apache Maven 3.8.4",
"Build_Jdk": "1.8.0_312"
- `"Archive"` - "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-so...",
- `"Manifest_Version"` - "1.0",
- `"Built_By"` - "matt",
- `"Created_By"` - "Apache Maven 3.8.4",
- `"Build_Jdk"` - "1.8.0_312"
},
{
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-ja...",
"Manifest_Version": "1.0",
"Built_By": "matt",
"Created_By": "Apache Maven 3.8.4",
"Build_Jdk": "1.8.0_312"
- `"Archive"` - "apache-log4j-2.16.0-bin/log4j-spring-boot-2.16.0-ja...",
- `"Manifest_Version"` - "1.0",
- `"Built_By"` - "matt",
- `"Created_By"` - "Apache Maven 3.8.4",
- `"Build_Jdk"` - "1.8.0_312"
},
{
"Bundle_SymbolicName": "org.apache.logging.log4j.spring-cloud-c...",
"Export_Package": "org.apache.logging.log4j.spring.cloud.config...",
"Archive": "apache-log4j-2.16.0-bin/log4j-spring-cloud-config-c...",
"Manifest_Version": "1.0",
"Bundle_License": "https://www.apache.org/licenses/LICENSE-2.0.txt",
- `"Bundle_SymbolicName"` - "org.apache.logging.log4j.spring-cloud-c...",
- `"Export_Package"` - "org.apache.logging.log4j.spring.cloud.config...",
- `"Archive"` - "apache-log4j-2.16.0-bin/log4j-spring-cloud-config-c...",
- `"Manifest_Version"` - "1.0",
- `"Bundle_License"` - "https://www.apache.org/licenses/LICENSE-2.0.txt",
...
}
...
]
<a id="jc.parsers.jar_manifest.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.jar_manifest.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.jobs"></a>
# jc.parsers.jobs
jc - JSON CLI output utility `jobs` command output parser
Also supports the `-l` option.
@ -34,89 +36,99 @@ Schema:
}
]
Example:
**Example**:
$ jobs -l | jc --jobs -p
[
{
"job_number": 1,
"pid": 5283,
"status": "Running",
"command": "sleep 10000 &"
- `"job_number"` - 1,
- `"pid"` - 5283,
- `"status"` - "Running",
- `"command"` - "sleep 10000 &"
},
{
"job_number": 2,
"pid": 5284,
"status": "Running",
"command": "sleep 10100 &"
- `"job_number"` - 2,
- `"pid"` - 5284,
- `"status"` - "Running",
- `"command"` - "sleep 10100 &"
},
{
"job_number": 3,
"pid": 5285,
"history": "previous",
"status": "Running",
"command": "sleep 10001 &"
- `"job_number"` - 3,
- `"pid"` - 5285,
- `"history"` - "previous",
- `"status"` - "Running",
- `"command"` - "sleep 10001 &"
},
{
"job_number": 4,
"pid": 5286,
"history": "current",
"status": "Running",
"command": "sleep 10112 &"
- `"job_number"` - 4,
- `"pid"` - 5286,
- `"history"` - "current",
- `"status"` - "Running",
- `"command"` - "sleep 10112 &"
}
]
$ jobs -l | jc --jobs -p -r
[
{
"job_number": "1",
"pid": "19510",
"status": "Running",
"command": "sleep 1000 &"
- `"job_number"` - "1",
- `"pid"` - "19510",
- `"status"` - "Running",
- `"command"` - "sleep 1000 &"
},
{
"job_number": "2",
"pid": "19511",
"status": "Running",
"command": "sleep 1001 &"
- `"job_number"` - "2",
- `"pid"` - "19511",
- `"status"` - "Running",
- `"command"` - "sleep 1001 &"
},
{
"job_number": "3",
"pid": "19512",
"history": "previous",
"status": "Running",
"command": "sleep 1002 &"
- `"job_number"` - "3",
- `"pid"` - "19512",
- `"history"` - "previous",
- `"status"` - "Running",
- `"command"` - "sleep 1002 &"
},
{
"job_number": "4",
"pid": "19513",
"history": "current",
"status": "Running",
"command": "sleep 1003 &"
- `"job_number"` - "4",
- `"pid"` - "19513",
- `"history"` - "current",
- `"status"` - "Running",
- `"command"` - "sleep 1003 &"
}
]
<a id="jc.parsers.jobs.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.jobs.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.kv"></a>
# jc.parsers.kv
jc - JSON CLI output utility `Key/Value` file parser
Supports files containing simple key/value pairs. Delimiter can be `=` or
@ -35,13 +37,14 @@ Schema:
"key2": string
}
Examples:
**Examples**:
$ cat keyvalue.txt
# this file contains key/value pairs
name = John Doe
address=555 California Drive
age: 34
- `age` - 34
; comments can include # or ;
# delimiter can be = or :
# quoted values have quotation marks stripped by default
@ -50,35 +53,44 @@ Examples:
$ cat keyvalue.txt | jc --kv -p
{
"name": "John Doe",
"address": "555 California Drive",
"age": "34",
"occupation": "Engineer"
- `"name"` - "John Doe",
- `"address"` - "555 California Drive",
- `"age"` - "34",
- `"occupation"` - "Engineer"
}
<a id="jc.parsers.kv.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.kv.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Note: this is just a wrapper for jc.parsers.ini
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary representing the key/value file

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.last"></a>
# jc.parsers.last
jc - JSON CLI output utility `last` and `lastb` command output parser
Supports `-w` and `-F` options.
@ -43,38 +45,39 @@ Schema:
}
]
Examples:
**Examples**:
$ last -F | jc --last -p
[
{
"user": "kbrazil",
"tty": "ttys002",
"hostname": null,
"login": "Mon Dec 28 17:24:10 2020",
"logout": "still logged in"
- `"user"` - "kbrazil",
- `"tty"` - "ttys002",
- `"hostname"` - null,
- `"login"` - "Mon Dec 28 17:24:10 2020",
- `"logout"` - "still logged in"
},
{
"user": "kbrazil",
"tty": "ttys003",
"hostname": null,
"login": "Mon Dec 28 17:24:10 2020",
"logout": "Mon Dec 28 17:25:01 2020",
"duration": "00:00",
"login_epoch": 1565891826,
"logout_epoch": 1565895404,
"duration_seconds": 3578
- `"user"` - "kbrazil",
- `"tty"` - "ttys003",
- `"hostname"` - null,
- `"login"` - "Mon Dec 28 17:24:10 2020",
- `"logout"` - "Mon Dec 28 17:25:01 2020",
- `"duration"` - "00:00",
- `"login_epoch"` - 1565891826,
- `"logout_epoch"` - 1565895404,
- `"duration_seconds"` - 3578
},
{
"user": "kbrazil",
"tty": "ttys003",
"hostname": null,
"login": "Mon Dec 28 17:24:10 2020",
"logout": "Mon Dec 28 17:25:01 2020",
"duration": "00:00",
"login_epoch": 1565891826,
"logout_epoch": 1565895404,
"duration_seconds": 3578
- `"user"` - "kbrazil",
- `"tty"` - "ttys003",
- `"hostname"` - null,
- `"login"` - "Mon Dec 28 17:24:10 2020",
- `"logout"` - "Mon Dec 28 17:25:01 2020",
- `"duration"` - "00:00",
- `"login_epoch"` - 1565891826,
- `"logout_epoch"` - 1565895404,
- `"duration_seconds"` - 3578
},
...
]
@ -82,53 +85,61 @@ Examples:
$ last | jc --last -p -r
[
{
"user": "kbrazil",
"tty": "ttys002",
"hostname": "-",
"login": "Thu Feb 27 14:31",
"logout": "still_logged_in"
- `"user"` - "kbrazil",
- `"tty"` - "ttys002",
- `"hostname"` - "-",
- `"login"` - "Thu Feb 27 14:31",
- `"logout"` - "still_logged_in"
},
{
"user": "kbrazil",
"tty": "ttys003",
"hostname": "-",
"login": "Thu Feb 27 10:38",
"logout": "10:38",
"duration": "00:00"
- `"user"` - "kbrazil",
- `"tty"` - "ttys003",
- `"hostname"` - "-",
- `"login"` - "Thu Feb 27 10:38",
- `"logout"` - "10:38",
- `"duration"` - "00:00"
},
{
"user": "kbrazil",
"tty": "ttys003",
"hostname": "-",
"login": "Thu Feb 27 10:18",
"logout": "10:18",
"duration": "00:00"
- `"user"` - "kbrazil",
- `"tty"` - "ttys003",
- `"hostname"` - "-",
- `"login"` - "Thu Feb 27 10:18",
- `"logout"` - "10:18",
- `"duration"` - "00:00"
},
...
]
<a id="jc.parsers.last.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.last.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ls"></a>
# jc.parsers.ls
jc - JSON CLI output utility `ls` and `vdir` command output parser
Options supported:
@ -58,15 +60,16 @@ Schema:
[1] timezone aware timestamp if date field is in UTC and can
be converted.
Examples:
**Examples**:
$ ls /usr/bin | jc --ls -p
[
{
"filename": "apropos"
- `"filename"` - "apropos"
},
{
"filename": "arch"
- `"filename"` - "arch"
},
...
]
@ -74,23 +77,23 @@ Examples:
$ ls -l /usr/bin | jc --ls -p
[
{
"filename": "apropos",
"link_to": "whatis",
"flags": "lrwxrwxrwx.",
"links": 1,
"owner": "root",
"group": "root",
"size": 6,
"date": "Aug 15 10:53"
- `"filename"` - "apropos",
- `"link_to"` - "whatis",
- `"flags"` - "lrwxrwxrwx.",
- `"links"` - 1,
- `"owner"` - "root",
- `"group"` - "root",
- `"size"` - 6,
- `"date"` - "Aug 15 10:53"
},
{
"filename": "ar",
"flags": "-rwxr-xr-x.",
"links": 1,
"owner": "root",
"group": "root",
"size": 62744,
"date": "Aug 8 16:14"
- `"filename"` - "ar",
- `"flags"` - "-rwxr-xr-x.",
- `"links"` - 1,
- `"owner"` - "root",
- `"group"` - "root",
- `"size"` - 62744,
- `"date"` - "Aug 8 16:14"
},
...
]
@ -98,48 +101,57 @@ Examples:
$ ls -l /usr/bin | jc --ls -p -r
[
{
"filename": "apropos",
"link_to": "whatis",
"flags": "lrwxrwxrwx.",
"links": "1",
"owner": "root",
"group": "root",
"size": "6",
"date": "Aug 15 10:53"
- `"filename"` - "apropos",
- `"link_to"` - "whatis",
- `"flags"` - "lrwxrwxrwx.",
- `"links"` - "1",
- `"owner"` - "root",
- `"group"` - "root",
- `"size"` - "6",
- `"date"` - "Aug 15 10:53"
},
{
"filename": "arch",
"flags": "-rwxr-xr-x.",
"links": "1",
"owner": "root",
"group": "root",
"size": "33080",
"date": "Aug 19 23:25"
- `"filename"` - "arch",
- `"flags"` - "-rwxr-xr-x.",
- `"links"` - "1",
- `"owner"` - "root",
- `"group"` - "root",
- `"size"` - "33080",
- `"date"` - "Aug 19 23:25"
},
...
]
<a id="jc.parsers.ls.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ls.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ls_s"></a>
# jc.parsers.ls\_s
# jc.parsers.ls_s
jc - JSON CLI output utility `ls` and `vdir` command output streaming
parser
@ -66,7 +68,8 @@ Schema:
[1] timezone aware timestamp if date field is in UTC and can
be converted
Examples:
**Examples**:
$ ls -l /usr/bin | jc --ls-s
{"filename":"2to3-","flags":"-rwxr-xr-x","links":4,"owner":"root","...}
@ -80,34 +83,45 @@ Examples:
{"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1...}
...
<a id="jc.parsers.ls_s.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ls_s.parse"></a>
#### 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.
Parameters:
**Arguments**:
data: (iterable) line-based text data to parse
- `data` - (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
**Yields**:
Yields:
Dictionary. Raw or processed structured data.
Returns:
**Returns**:
Iterator object

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.lsblk"></a>
# jc.parsers.lsblk
jc - JSON CLI output utility `lsblk` command output parser
Usage (cli):
@ -68,236 +70,246 @@ Schema:
}
]
Examples:
**Examples**:
$ lsblk | jc --lsblk -p
[
{
"name": "sda",
"maj_min": "8:0",
"rm": false,
"size": "20G",
"ro": false,
"type": "disk",
"mountpoint": null
- `"name"` - "sda",
- `"maj_min"` - "8:0",
- `"rm"` - false,
- `"size"` - "20G",
- `"ro"` - false,
- `"type"` - "disk",
- `"mountpoint"` - null
},
{
"name": "sda1",
"maj_min": "8:1",
"rm": false,
"size": "1G",
"ro": false,
"type": "part",
"mountpoint": "/boot"
- `"name"` - "sda1",
- `"maj_min"` - "8:1",
- `"rm"` - false,
- `"size"` - "1G",
- `"ro"` - false,
- `"type"` - "part",
- `"mountpoint"` - "/boot"
},
...
]
$ 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
[
{
"name": "sda",
"maj_min": "8:0",
"rm": false,
"size": "20G",
"ro": false,
"type": "disk",
"mountpoint": null,
"kname": "sda",
"fstype": null,
"label": null,
"uuid": null,
"partlabel": null,
"partuuid": null,
"ra": 4096,
"model": "VMware Virtual S",
"serial": null,
"state": "running",
"owner": "root",
"group": "disk",
"mode": "brw-rw----",
"alignment": 0,
"min_io": 512,
"opt_io": 0,
"phy_sec": 512,
"log_sec": 512,
"rota": true,
"sched": "deadline",
"rq_size": 128,
"disc_aln": 0,
"disc_gran": "0B",
"disc_max": "0B",
"disc_zero": false,
"wsame": "32M",
"wwn": null,
"rand": true,
"pkname": null,
"hctl": "0:0:0:0",
"tran": "spi",
"rev": "1.0",
"vendor": "VMware,"
- `"name"` - "sda",
- `"maj_min"` - "8:0",
- `"rm"` - false,
- `"size"` - "20G",
- `"ro"` - false,
- `"type"` - "disk",
- `"mountpoint"` - null,
- `"kname"` - "sda",
- `"fstype"` - null,
- `"label"` - null,
- `"uuid"` - null,
- `"partlabel"` - null,
- `"partuuid"` - null,
- `"ra"` - 4096,
- `"model"` - "VMware Virtual S",
- `"serial"` - null,
- `"state"` - "running",
- `"owner"` - "root",
- `"group"` - "disk",
- `"mode"` - "brw-rw----",
- `"alignment"` - 0,
- `"min_io"` - 512,
- `"opt_io"` - 0,
- `"phy_sec"` - 512,
- `"log_sec"` - 512,
- `"rota"` - true,
- `"sched"` - "deadline",
- `"rq_size"` - 128,
- `"disc_aln"` - 0,
- `"disc_gran"` - "0B",
- `"disc_max"` - "0B",
- `"disc_zero"` - false,
- `"wsame"` - "32M",
- `"wwn"` - null,
- `"rand"` - true,
- `"pkname"` - null,
- `"hctl"` - "0:0:0:0",
- `"tran"` - "spi",
- `"rev"` - "1.0",
- `"vendor"` - "VMware,"
},
{
"name": "sda1",
"maj_min": "8:1",
"rm": false,
"size": "1G",
"ro": false,
"type": "part",
"mountpoint": "/boot",
"kname": "sda1",
"fstype": "xfs",
"label": null,
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
"partlabel": null,
"partuuid": null,
"ra": 4096,
"model": null,
"serial": null,
"state": null,
"owner": "root",
"group": "disk",
"mode": "brw-rw----",
"alignment": 0,
"min_io": 512,
"opt_io": 0,
"phy_sec": 512,
"log_sec": 512,
"rota": true,
"sched": "deadline",
"rq_size": 128,
"disc_aln": 0,
"disc_gran": "0B",
"disc_max": "0B",
"disc_zero": false,
"wsame": "32M",
"wwn": null,
"rand": true,
"pkname": "sda",
"hctl": null,
"tran": null,
"rev": null,
"vendor": null
- `"name"` - "sda1",
- `"maj_min"` - "8:1",
- `"rm"` - false,
- `"size"` - "1G",
- `"ro"` - false,
- `"type"` - "part",
- `"mountpoint"` - "/boot",
- `"kname"` - "sda1",
- `"fstype"` - "xfs",
- `"label"` - null,
- `"uuid"` - "05d927bb-5875-49e3-ada1-7f46cb31c932",
- `"partlabel"` - null,
- `"partuuid"` - null,
- `"ra"` - 4096,
- `"model"` - null,
- `"serial"` - null,
- `"state"` - null,
- `"owner"` - "root",
- `"group"` - "disk",
- `"mode"` - "brw-rw----",
- `"alignment"` - 0,
- `"min_io"` - 512,
- `"opt_io"` - 0,
- `"phy_sec"` - 512,
- `"log_sec"` - 512,
- `"rota"` - true,
- `"sched"` - "deadline",
- `"rq_size"` - 128,
- `"disc_aln"` - 0,
- `"disc_gran"` - "0B",
- `"disc_max"` - "0B",
- `"disc_zero"` - false,
- `"wsame"` - "32M",
- `"wwn"` - null,
- `"rand"` - true,
- `"pkname"` - "sda",
- `"hctl"` - null,
- `"tran"` - null,
- `"rev"` - null,
- `"vendor"` - null
},
...
]
$ 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
[
{
"name": "sda",
"maj_min": "8:0",
"rm": "0",
"size": "20G",
"ro": "0",
"type": "disk",
"mountpoint": null,
"kname": "sda",
"fstype": null,
"label": null,
"uuid": null,
"partlabel": null,
"partuuid": null,
"ra": "4096",
"model": "VMware Virtual S",
"serial": null,
"state": "running",
"owner": "root",
"group": "disk",
"mode": "brw-rw----",
"alignment": "0",
"min_io": "512",
"opt_io": "0",
"phy_sec": "512",
"log_sec": "512",
"rota": "1",
"sched": "deadline",
"rq_size": "128",
"disc_aln": "0",
"disc_gran": "0B",
"disc_max": "0B",
"disc_zero": "0",
"wsame": "32M",
"wwn": null,
"rand": "1",
"pkname": null,
"hctl": "0:0:0:0",
"tran": "spi",
"rev": "1.0",
"vendor": "VMware,"
- `"name"` - "sda",
- `"maj_min"` - "8:0",
- `"rm"` - "0",
- `"size"` - "20G",
- `"ro"` - "0",
- `"type"` - "disk",
- `"mountpoint"` - null,
- `"kname"` - "sda",
- `"fstype"` - null,
- `"label"` - null,
- `"uuid"` - null,
- `"partlabel"` - null,
- `"partuuid"` - null,
- `"ra"` - "4096",
- `"model"` - "VMware Virtual S",
- `"serial"` - null,
- `"state"` - "running",
- `"owner"` - "root",
- `"group"` - "disk",
- `"mode"` - "brw-rw----",
- `"alignment"` - "0",
- `"min_io"` - "512",
- `"opt_io"` - "0",
- `"phy_sec"` - "512",
- `"log_sec"` - "512",
- `"rota"` - "1",
- `"sched"` - "deadline",
- `"rq_size"` - "128",
- `"disc_aln"` - "0",
- `"disc_gran"` - "0B",
- `"disc_max"` - "0B",
- `"disc_zero"` - "0",
- `"wsame"` - "32M",
- `"wwn"` - null,
- `"rand"` - "1",
- `"pkname"` - null,
- `"hctl"` - "0:0:0:0",
- `"tran"` - "spi",
- `"rev"` - "1.0",
- `"vendor"` - "VMware,"
},
{
"name": "sda1",
"maj_min": "8:1",
"rm": "0",
"size": "1G",
"ro": "0",
"type": "part",
"mountpoint": "/boot",
"kname": "sda1",
"fstype": "xfs",
"label": null,
"uuid": "05d927bb-5875-49e3-ada1-7f46cb31c932",
"partlabel": null,
"partuuid": null,
"ra": "4096",
"model": null,
"serial": null,
"state": null,
"owner": "root",
"group": "disk",
"mode": "brw-rw----",
"alignment": "0",
"min_io": "512",
"opt_io": "0",
"phy_sec": "512",
"log_sec": "512",
"rota": "1",
"sched": "deadline",
"rq_size": "128",
"disc_aln": "0",
"disc_gran": "0B",
"disc_max": "0B",
"disc_zero": "0",
"wsame": "32M",
"wwn": null,
"rand": "1",
"pkname": "sda",
"hctl": null,
"tran": null,
"rev": null,
"vendor": null
- `"name"` - "sda1",
- `"maj_min"` - "8:1",
- `"rm"` - "0",
- `"size"` - "1G",
- `"ro"` - "0",
- `"type"` - "part",
- `"mountpoint"` - "/boot",
- `"kname"` - "sda1",
- `"fstype"` - "xfs",
- `"label"` - null,
- `"uuid"` - "05d927bb-5875-49e3-ada1-7f46cb31c932",
- `"partlabel"` - null,
- `"partuuid"` - null,
- `"ra"` - "4096",
- `"model"` - null,
- `"serial"` - null,
- `"state"` - null,
- `"owner"` - "root",
- `"group"` - "disk",
- `"mode"` - "brw-rw----",
- `"alignment"` - "0",
- `"min_io"` - "512",
- `"opt_io"` - "0",
- `"phy_sec"` - "512",
- `"log_sec"` - "512",
- `"rota"` - "1",
- `"sched"` - "deadline",
- `"rq_size"` - "128",
- `"disc_aln"` - "0",
- `"disc_gran"` - "0B",
- `"disc_max"` - "0B",
- `"disc_zero"` - "0",
- `"wsame"` - "32M",
- `"wwn"` - null,
- `"rand"` - "1",
- `"pkname"` - "sda",
- `"hctl"` - null,
- `"tran"` - null,
- `"rev"` - null,
- `"vendor"` - null
},
...
]
<a id="jc.parsers.lsblk.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.lsblk.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.lsmod"></a>
# jc.parsers.lsmod
jc - JSON CLI output utility `lsmod` command output parser
Usage (cli):
@ -34,41 +36,42 @@ Schema:
}
]
Examples:
**Examples**:
$ lsmod | jc --lsmod -p
[
...
{
"module": "nf_nat",
"size": 26583,
"used": 3,
"by": [
- `"module"` - "nf_nat",
- `"size"` - 26583,
- `"used"` - 3,
- `"by"` - [
"nf_nat_ipv4",
"nf_nat_ipv6",
"nf_nat_masquerade_ipv4"
]
},
{
"module": "iptable_mangle",
"size": 12695,
"used": 1
- `"module"` - "iptable_mangle",
- `"size"` - 12695,
- `"used"` - 1
},
{
"module": "iptable_security",
"size": 12705,
"used": 1
- `"module"` - "iptable_security",
- `"size"` - 12705,
- `"used"` - 1
},
{
"module": "iptable_raw",
"size": 12678,
"used": 1
- `"module"` - "iptable_raw",
- `"size"` - 12678,
- `"used"` - 1
},
{
"module": "nf_conntrack",
"size": 139224,
"used": 7,
"by": [
- `"module"` - "nf_conntrack",
- `"size"` - 139224,
- `"used"` - 7,
- `"by"` - [
"nf_nat",
"nf_nat_ipv4",
"nf_nat_ipv6",
@ -85,10 +88,10 @@ Examples:
[
...
{
"module": "nf_conntrack",
"size": "139224",
"used": "7",
"by": [
- `"module"` - "nf_conntrack",
- `"size"` - "139224",
- `"used"` - "7",
- `"by"` - [
"nf_nat",
"nf_nat_ipv4",
"nf_nat_ipv6",
@ -99,28 +102,28 @@ Examples:
]
},
{
"module": "ip_set",
"size": "45799",
"used": "0"
- `"module"` - "ip_set",
- `"size"` - "45799",
- `"used"` - "0"
},
{
"module": "nfnetlink",
"size": "14519",
"used": "1",
"by": [
- `"module"` - "nfnetlink",
- `"size"` - "14519",
- `"used"` - "1",
- `"by"` - [
"ip_set"
]
},
{
"module": "ebtable_filter",
"size": "12827",
"used": "1"
- `"module"` - "ebtable_filter",
- `"size"` - "12827",
- `"used"` - "1"
},
{
"module": "ebtables",
"size": "35009",
"used": "2",
"by": [
- `"module"` - "ebtables",
- `"size"` - "35009",
- `"used"` - "2",
- `"by"` - [
"ebtable_nat",
"ebtable_filter"
]
@ -128,27 +131,36 @@ Examples:
...
]
<a id="jc.parsers.lsmod.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.lsmod.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.lsof"></a>
# jc.parsers.lsof
jc - JSON CLI output utility `lsof` command output parser
Usage (cli):
@ -38,45 +40,46 @@ Schema:
}
]
Examples:
**Examples**:
$ sudo lsof | jc --lsof -p
[
{
"command": "systemd",
"pid": 1,
"tid": null,
"user": "root",
"fd": "cwd",
"type": "DIR",
"device": "253,0",
"size_off": 224,
"node": 64,
"name": "/"
- `"command"` - "systemd",
- `"pid"` - 1,
- `"tid"` - null,
- `"user"` - "root",
- `"fd"` - "cwd",
- `"type"` - "DIR",
- `"device"` - "253,0",
- `"size_off"` - 224,
- `"node"` - 64,
- `"name"` - "/"
},
{
"command": "systemd",
"pid": 1,
"tid": null,
"user": "root",
"fd": "rtd",
"type": "DIR",
"device": "253,0",
"size_off": 224,
"node": 64,
"name": "/"
- `"command"` - "systemd",
- `"pid"` - 1,
- `"tid"` - null,
- `"user"` - "root",
- `"fd"` - "rtd",
- `"type"` - "DIR",
- `"device"` - "253,0",
- `"size_off"` - 224,
- `"node"` - 64,
- `"name"` - "/"
},
{
"command": "systemd",
"pid": 1,
"tid": null,
"user": "root",
"fd": "txt",
"type": "REG",
"device": "253,0",
"size_off": 1624520,
"node": 50360451,
"name": "/usr/lib/systemd/systemd"
- `"command"` - "systemd",
- `"pid"` - 1,
- `"tid"` - null,
- `"user"` - "root",
- `"fd"` - "txt",
- `"type"` - "REG",
- `"device"` - "253,0",
- `"size_off"` - 1624520,
- `"node"` - 50360451,
- `"name"` - "/usr/lib/systemd/systemd"
},
...
]
@ -84,65 +87,74 @@ Examples:
$ sudo lsof | jc --lsof -p -r
[
{
"command": "systemd",
"pid": "1",
"tid": null,
"user": "root",
"fd": "cwd",
"type": "DIR",
"device": "8,2",
"size_off": "4096",
"node": "2",
"name": "/"
- `"command"` - "systemd",
- `"pid"` - "1",
- `"tid"` - null,
- `"user"` - "root",
- `"fd"` - "cwd",
- `"type"` - "DIR",
- `"device"` - "8,2",
- `"size_off"` - "4096",
- `"node"` - "2",
- `"name"` - "/"
},
{
"command": "systemd",
"pid": "1",
"tid": null,
"user": "root",
"fd": "rtd",
"type": "DIR",
"device": "8,2",
"size_off": "4096",
"node": "2",
"name": "/"
- `"command"` - "systemd",
- `"pid"` - "1",
- `"tid"` - null,
- `"user"` - "root",
- `"fd"` - "rtd",
- `"type"` - "DIR",
- `"device"` - "8,2",
- `"size_off"` - "4096",
- `"node"` - "2",
- `"name"` - "/"
},
{
"command": "systemd",
"pid": "1",
"tid": null,
"user": "root",
"fd": "txt",
"type": "REG",
"device": "8,2",
"size_off": "1595792",
"node": "668802",
"name": "/lib/systemd/systemd"
- `"command"` - "systemd",
- `"pid"` - "1",
- `"tid"` - null,
- `"user"` - "root",
- `"fd"` - "txt",
- `"type"` - "REG",
- `"device"` - "8,2",
- `"size_off"` - "1595792",
- `"node"` - "668802",
- `"name"` - "/lib/systemd/systemd"
},
...
]
<a id="jc.parsers.lsof.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.lsof.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.lsusb"></a>
# jc.parsers.lsusb
jc - JSON CLI output utility `lsusb` command output parser
Supports the `-v` option or no options.
@ -144,80 +146,81 @@ Schema:
}
]
Examples:
**Examples**:
$ lsusb -v | jc --lsusb -p
[
{
"bus": "002",
"device": "001",
"id": "1d6b:0001",
"description": "Linux Foundation 1.1 root hub",
"device_descriptor": {
"bLength": {
"value": "18"
- `"bus"` - "002",
- `"device"` - "001",
- `"id"` - "1d6b:0001",
- `"description"` - "Linux Foundation 1.1 root hub",
- `"device_descriptor"` - {
- `"bLength"` - {
- `"value"` - "18"
},
"bDescriptorType": {
"value": "1"
- `"bDescriptorType"` - {
- `"value"` - "1"
},
"bcdUSB": {
"value": "1.10"
- `"bcdUSB"` - {
- `"value"` - "1.10"
},
...
"bNumConfigurations": {
"value": "1"
- `"bNumConfigurations"` - {
- `"value"` - "1"
},
"configuration_descriptor": {
"bLength": {
"value": "9"
- `"configuration_descriptor"` - {
- `"bLength"` - {
- `"value"` - "9"
},
...
"iConfiguration": {
"value": "0"
- `"iConfiguration"` - {
- `"value"` - "0"
},
"bmAttributes": {
"value": "0xe0",
"attributes": [
- `"bmAttributes"` - {
- `"value"` - "0xe0",
- `"attributes"` - [
"Self Powered",
"Remote Wakeup"
]
},
"MaxPower": {
"description": "0mA"
- `"MaxPower"` - {
- `"description"` - "0mA"
},
"interface_descriptors": [
- `"interface_descriptors"` - [
{
"bLength": {
"value": "9"
- `"bLength"` - {
- `"value"` - "9"
},
...
"bInterfaceProtocol": {
"value": "0",
"description": "Full speed (or root) hub"
- `"bInterfaceProtocol"` - {
- `"value"` - "0",
- `"description"` - "Full speed (or root) hub"
},
"iInterface": {
"value": "0"
- `"iInterface"` - {
- `"value"` - "0"
},
"endpoint_descriptors": [
- `"endpoint_descriptors"` - [
{
"bLength": {
"value": "7"
- `"bLength"` - {
- `"value"` - "7"
},
...
"bmAttributes": {
"value": "3",
"attributes": [
- `"bmAttributes"` - {
- `"value"` - "3",
- `"attributes"` - [
"Transfer Type Interrupt",
"Synch Type None",
"Usage Type Data"
]
},
"wMaxPacketSize": {
"value": "0x0002",
"description": "1x 2 bytes"
- `"wMaxPacketSize"` - {
- `"value"` - "0x0002",
- `"description"` - "1x 2 bytes"
},
"bInterval": {
"value": "255"
- `"bInterval"` - {
- `"value"` - "255"
}
}
]
@ -225,31 +228,31 @@ Examples:
]
}
},
"hub_descriptor": {
"bLength": {
"value": "9"
- `"hub_descriptor"` - {
- `"bLength"` - {
- `"value"` - "9"
},
...
"wHubCharacteristic": {
"value": "0x000a",
"attributes": [
- `"wHubCharacteristic"` - {
- `"value"` - "0x000a",
- `"attributes"` - [
"No power switching (usb 1.0)",
"Per-port overcurrent protection"
]
},
...
"hub_port_status": {
- `"hub_port_status"` - {
"Port 1": {
"value": "0000.0103",
"attributes": [
- `"value"` - "0000.0103",
- `"attributes"` - [
"power",
"enable",
"connect"
]
},
"Port 2": {
"value": "0000.0103",
"attributes": [
- `"value"` - "0000.0103",
- `"attributes"` - [
"power",
"enable",
"connect"
@ -257,34 +260,43 @@ Examples:
}
}
},
"device_status": {
"value": "0x0001",
"description": "Self Powered"
- `"device_status"` - {
- `"value"` - "0x0001",
- `"description"` - "Self Powered"
}
}
]
<a id="jc.parsers.lsusb.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.lsusb.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.mount"></a>
# jc.parsers.mount
jc - JSON CLI output utility `mount` command output parser
Usage (cli):
@ -34,15 +36,16 @@ Schema:
}
]
Example:
**Example**:
$ mount | jc --mount -p
[
{
"filesystem": "sysfs",
"mount_point": "/sys",
"type": "sysfs",
"access": [
- `"filesystem"` - "sysfs",
- `"mount_point"` - "/sys",
- `"type"` - "sysfs",
- `"access"` - [
"rw",
"nosuid",
"nodev",
@ -51,10 +54,10 @@ Example:
]
},
{
"filesystem": "proc",
"mount_point": "/proc",
"type": "proc",
"access": [
- `"filesystem"` - "proc",
- `"mount_point"` - "/proc",
- `"type"` - "proc",
- `"access"` - [
"rw",
"nosuid",
"nodev",
@ -63,10 +66,10 @@ Example:
]
},
{
"filesystem": "udev",
"mount_point": "/dev",
"type": "devtmpfs",
"access": [
- `"filesystem"` - "udev",
- `"mount_point"` - "/dev",
- `"type"` - "devtmpfs",
- `"access"` - [
"rw",
"nosuid",
"relatime",
@ -78,27 +81,36 @@ Example:
...
]
<a id="jc.parsers.mount.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.mount.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.netstat"></a>
# jc.parsers.netstat
jc - JSON CLI output utility `netstat` command output parser
Caveats:
@ -127,154 +129,155 @@ Schema:
}
]
Examples:
**Examples**:
# netstat -apee | jc --netstat -p
[
{
"proto": "tcp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "0.0.0.0",
"state": "LISTEN",
"user": "systemd-resolve",
"inode": 26958,
"program_name": "systemd-resolve",
"kind": "network",
"pid": 887,
"local_port": "domain",
"foreign_port": "*",
"transport_protocol": "tcp",
"network_protocol": "ipv4"
- `"proto"` - "tcp",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "localhost",
- `"foreign_address"` - "0.0.0.0",
- `"state"` - "LISTEN",
- `"user"` - "systemd-resolve",
- `"inode"` - 26958,
- `"program_name"` - "systemd-resolve",
- `"kind"` - "network",
- `"pid"` - 887,
- `"local_port"` - "domain",
- `"foreign_port"` - "*",
- `"transport_protocol"` - "tcp",
- `"network_protocol"` - "ipv4"
},
{
"proto": "tcp",
"recv_q": 0,
"send_q": 0,
"local_address": "0.0.0.0",
"foreign_address": "0.0.0.0",
"state": "LISTEN",
"user": "root",
"inode": 30499,
"program_name": "sshd",
"kind": "network",
"pid": 1186,
"local_port": "ssh",
"foreign_port": "*",
"transport_protocol": "tcp",
"network_protocol": "ipv4"
- `"proto"` - "tcp",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "0.0.0.0",
- `"foreign_address"` - "0.0.0.0",
- `"state"` - "LISTEN",
- `"user"` - "root",
- `"inode"` - 30499,
- `"program_name"` - "sshd",
- `"kind"` - "network",
- `"pid"` - 1186,
- `"local_port"` - "ssh",
- `"foreign_port"` - "*",
- `"transport_protocol"` - "tcp",
- `"network_protocol"` - "ipv4"
},
{
"proto": "tcp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "localhost",
"state": "ESTABLISHED",
"user": "root",
"inode": 46829,
"program_name": "sshd: root",
"kind": "network",
"pid": 2242,
"local_port": "ssh",
"foreign_port": "52186",
"transport_protocol": "tcp",
"network_protocol": "ipv4",
"foreign_port_num": 52186
- `"proto"` - "tcp",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "localhost",
- `"foreign_address"` - "localhost",
- `"state"` - "ESTABLISHED",
- `"user"` - "root",
- `"inode"` - 46829,
- `"program_name"` - "sshd: root",
- `"kind"` - "network",
- `"pid"` - 2242,
- `"local_port"` - "ssh",
- `"foreign_port"` - "52186",
- `"transport_protocol"` - "tcp",
- `"network_protocol"` - "ipv4",
- `"foreign_port_num"` - 52186
},
{
"proto": "tcp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "localhost",
"state": "ESTABLISHED",
"user": "root",
"inode": 46828,
"program_name": "ssh",
"kind": "network",
"pid": 2241,
"local_port": "52186",
"foreign_port": "ssh",
"transport_protocol": "tcp",
"network_protocol": "ipv4",
"local_port_num": 52186
- `"proto"` - "tcp",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "localhost",
- `"foreign_address"` - "localhost",
- `"state"` - "ESTABLISHED",
- `"user"` - "root",
- `"inode"` - 46828,
- `"program_name"` - "ssh",
- `"kind"` - "network",
- `"pid"` - 2241,
- `"local_port"` - "52186",
- `"foreign_port"` - "ssh",
- `"transport_protocol"` - "tcp",
- `"network_protocol"` - "ipv4",
- `"local_port_num"` - 52186
},
{
"proto": "tcp6",
"recv_q": 0,
"send_q": 0,
"local_address": "[::]",
"foreign_address": "[::]",
"state": "LISTEN",
"user": "root",
"inode": 30510,
"program_name": "sshd",
"kind": "network",
"pid": 1186,
"local_port": "ssh",
"foreign_port": "*",
"transport_protocol": "tcp",
"network_protocol": "ipv6"
- `"proto"` - "tcp6",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "[::]",
- `"foreign_address"` - "[::]",
- `"state"` - "LISTEN",
- `"user"` - "root",
- `"inode"` - 30510,
- `"program_name"` - "sshd",
- `"kind"` - "network",
- `"pid"` - 1186,
- `"local_port"` - "ssh",
- `"foreign_port"` - "*",
- `"transport_protocol"` - "tcp",
- `"network_protocol"` - "ipv6"
},
{
"proto": "udp",
"recv_q": 0,
"send_q": 0,
"local_address": "localhost",
"foreign_address": "0.0.0.0",
"state": null,
"user": "systemd-resolve",
"inode": 26957,
"program_name": "systemd-resolve",
"kind": "network",
"pid": 887,
"local_port": "domain",
"foreign_port": "*",
"transport_protocol": "udp",
"network_protocol": "ipv4"
- `"proto"` - "udp",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "localhost",
- `"foreign_address"` - "0.0.0.0",
- `"state"` - null,
- `"user"` - "systemd-resolve",
- `"inode"` - 26957,
- `"program_name"` - "systemd-resolve",
- `"kind"` - "network",
- `"pid"` - 887,
- `"local_port"` - "domain",
- `"foreign_port"` - "*",
- `"transport_protocol"` - "udp",
- `"network_protocol"` - "ipv4"
},
{
"proto": "raw6",
"recv_q": 0,
"send_q": 0,
"local_address": "[::]",
"foreign_address": "[::]",
"state": "7",
"user": "systemd-network",
"inode": 27001,
"program_name": "systemd-network",
"kind": "network",
"pid": 867,
"local_port": "ipv6-icmp",
"foreign_port": "*",
"transport_protocol": null,
"network_protocol": "ipv6"
- `"proto"` - "raw6",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "[::]",
- `"foreign_address"` - "[::]",
- `"state"` - "7",
- `"user"` - "systemd-network",
- `"inode"` - 27001,
- `"program_name"` - "systemd-network",
- `"kind"` - "network",
- `"pid"` - 867,
- `"local_port"` - "ipv6-icmp",
- `"foreign_port"` - "*",
- `"transport_protocol"` - null,
- `"network_protocol"` - "ipv6"
},
{
"proto": "unix",
"refcnt": 2,
"flags": null,
"type": "DGRAM",
"state": null,
"inode": 33322,
"program_name": "systemd",
"path": "/run/user/1000/systemd/notify",
"kind": "socket",
"pid": 1607
- `"proto"` - "unix",
- `"refcnt"` - 2,
- `"flags"` - null,
- `"type"` - "DGRAM",
- `"state"` - null,
- `"inode"` - 33322,
- `"program_name"` - "systemd",
- `"path"` - "/run/user/1000/systemd/notify",
- `"kind"` - "socket",
- `"pid"` - 1607
},
{
"proto": "unix",
"refcnt": 2,
"flags": "ACC",
"type": "SEQPACKET",
"state": "LISTENING",
"inode": 20835,
"program_name": "init",
"path": "/run/udev/control",
"kind": "socket",
"pid": 1
- `"proto"` - "unix",
- `"refcnt"` - 2,
- `"flags"` - "ACC",
- `"type"` - "SEQPACKET",
- `"state"` - "LISTENING",
- `"inode"` - 20835,
- `"program_name"` - "init",
- `"path"` - "/run/udev/control",
- `"kind"` - "socket",
- `"pid"` - 1
},
...
]
@ -282,45 +285,45 @@ Examples:
$ netstat -r | jc --netstat -p
[
{
"destination": "default",
"gateway": "gateway",
"genmask": "0.0.0.0",
"route_flags": "UG",
"mss": 0,
"window": 0,
"irtt": 0,
"iface": "ens33",
"kind": "route",
"route_flags_pretty": [
- `"destination"` - "default",
- `"gateway"` - "gateway",
- `"genmask"` - "0.0.0.0",
- `"route_flags"` - "UG",
- `"mss"` - 0,
- `"window"` - 0,
- `"irtt"` - 0,
- `"iface"` - "ens33",
- `"kind"` - "route",
- `"route_flags_pretty"` - [
"UP",
"GATEWAY"
]
},
{
"destination": "172.17.0.0",
"gateway": "0.0.0.0",
"genmask": "255.255.0.0",
"route_flags": "U",
"mss": 0,
"window": 0,
"irtt": 0,
"iface": "docker0",
"kind": "route",
"route_flags_pretty": [
- `"destination"` - "172.17.0.0",
- `"gateway"` - "0.0.0.0",
- `"genmask"` - "255.255.0.0",
- `"route_flags"` - "U",
- `"mss"` - 0,
- `"window"` - 0,
- `"irtt"` - 0,
- `"iface"` - "docker0",
- `"kind"` - "route",
- `"route_flags_pretty"` - [
"UP"
]
},
{
"destination": "192.168.71.0",
"gateway": "0.0.0.0",
"genmask": "255.255.255.0",
"route_flags": "U",
"mss": 0,
"window": 0,
"irtt": 0,
"iface": "ens33",
"kind": "route",
"route_flags_pretty": [
- `"destination"` - "192.168.71.0",
- `"gateway"` - "0.0.0.0",
- `"genmask"` - "255.255.255.0",
- `"route_flags"` - "U",
- `"mss"` - 0,
- `"window"` - 0,
- `"irtt"` - 0,
- `"iface"` - "ens33",
- `"kind"` - "route",
- `"route_flags_pretty"` - [
"UP"
]
}
@ -329,56 +332,65 @@ Examples:
$ netstat -i | jc --netstat -p
[
{
"iface": "ens33",
"mtu": 1500,
"rx_ok": 476,
"rx_err": 0,
"rx_drp": 0,
"rx_ovr": 0,
"tx_ok": 312,
"tx_err": 0,
"tx_drp": 0,
"tx_ovr": 0,
"flg": "BMRU",
"kind": "interface"
- `"iface"` - "ens33",
- `"mtu"` - 1500,
- `"rx_ok"` - 476,
- `"rx_err"` - 0,
- `"rx_drp"` - 0,
- `"rx_ovr"` - 0,
- `"tx_ok"` - 312,
- `"tx_err"` - 0,
- `"tx_drp"` - 0,
- `"tx_ovr"` - 0,
- `"flg"` - "BMRU",
- `"kind"` - "interface"
},
{
"iface": "lo",
"mtu": 65536,
"rx_ok": 0,
"rx_err": 0,
"rx_drp": 0,
"rx_ovr": 0,
"tx_ok": 0,
"tx_err": 0,
"tx_drp": 0,
"tx_ovr": 0,
"flg": "LRU",
"kind": "interface"
- `"iface"` - "lo",
- `"mtu"` - 65536,
- `"rx_ok"` - 0,
- `"rx_err"` - 0,
- `"rx_drp"` - 0,
- `"rx_ovr"` - 0,
- `"tx_ok"` - 0,
- `"tx_err"` - 0,
- `"tx_drp"` - 0,
- `"tx_ovr"` - 0,
- `"flg"` - "LRU",
- `"kind"` - "interface"
}
]
<a id="jc.parsers.netstat.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.netstat.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ntpq"></a>
# jc.parsers.ntpq
jc - JSON CLI output utility `ntpq -p` command output parser
Usage (cli):
@ -39,197 +41,207 @@ Schema:
},
]
Examples:
**Examples**:
$ ntpq -p | jc --ntpq -p
[
{
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": 2,
"t": "u",
"when": 1,
"poll": 64,
"reach": 1,
"delay": 23.399,
"offset": -2.805,
"jitter": 2.131,
"state": null
- `"remote"` - "44.190.6.254",
- `"refid"` - "127.67.113.92",
- `"st"` - 2,
- `"t"` - "u",
- `"when"` - 1,
- `"poll"` - 64,
- `"reach"` - 1,
- `"delay"` - 23.399,
- `"offset"` - -2.805,
- `"jitter"` - 2.131,
- `"state"` - null
},
{
"remote": "ntp.wdc1.us.lea",
"refid": "130.133.1.10",
"st": 2,
"t": "u",
"when": null,
"poll": 64,
"reach": 1,
"delay": 93.053,
"offset": -0.807,
"jitter": 2.839,
"state": null
- `"remote"` - "ntp.wdc1.us.lea",
- `"refid"` - "130.133.1.10",
- `"st"` - 2,
- `"t"` - "u",
- `"when"` - null,
- `"poll"` - 64,
- `"reach"` - 1,
- `"delay"` - 93.053,
- `"offset"` - -0.807,
- `"jitter"` - 2.839,
- `"state"` - null
},
{
"remote": "clock.team-cymr",
"refid": "204.9.54.119",
"st": 2,
"t": "u",
"when": null,
"poll": 64,
"reach": 1,
"delay": 70.337,
"offset": -2.909,
"jitter": 2.6,
"state": null
- `"remote"` - "clock.team-cymr",
- `"refid"` - "204.9.54.119",
- `"st"` - 2,
- `"t"` - "u",
- `"when"` - null,
- `"poll"` - 64,
- `"reach"` - 1,
- `"delay"` - 70.337,
- `"offset"` - -2.909,
- `"jitter"` - 2.6,
- `"state"` - null
},
{
"remote": "mirror1.sjc02.s",
"refid": "216.218.254.202",
"st": 2,
"t": "u",
"when": 2,
"poll": 64,
"reach": 1,
"delay": 29.325,
"offset": 1.044,
"jitter": 4.069,
"state": null,
- `"remote"` - "mirror1.sjc02.s",
- `"refid"` - "216.218.254.202",
- `"st"` - 2,
- `"t"` - "u",
- `"when"` - 2,
- `"poll"` - 64,
- `"reach"` - 1,
- `"delay"` - 29.325,
- `"offset"` - 1.044,
- `"jitter"` - 4.069,
- `"state"` - null,
}
]
$ ntpq -pn| jc --ntpq -p
[
{
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": 2,
"t": "u",
"when": 66,
"poll": 64,
"reach": 377,
"delay": 22.69,
"offset": -0.392,
"jitter": 2.085,
"state": "+"
- `"remote"` - "44.190.6.254",
- `"refid"` - "127.67.113.92",
- `"st"` - 2,
- `"t"` - "u",
- `"when"` - 66,
- `"poll"` - 64,
- `"reach"` - 377,
- `"delay"` - 22.69,
- `"offset"` - -0.392,
- `"jitter"` - 2.085,
- `"state"` - "+"
},
{
"remote": "108.59.2.24",
"refid": "130.133.1.10",
"st": 2,
"t": "u",
"when": 63,
"poll": 64,
"reach": 377,
"delay": 90.805,
"offset": 2.84,
"jitter": 1.908,
"state": "-"
- `"remote"` - "108.59.2.24",
- `"refid"` - "130.133.1.10",
- `"st"` - 2,
- `"t"` - "u",
- `"when"` - 63,
- `"poll"` - 64,
- `"reach"` - 377,
- `"delay"` - 90.805,
- `"offset"` - 2.84,
- `"jitter"` - 1.908,
- `"state"` - "-"
},
{
"remote": "38.229.71.1",
"refid": "204.9.54.119",
"st": 2,
"t": "u",
"when": 64,
"poll": 64,
"reach": 377,
"delay": 68.699,
"offset": -0.61,
"jitter": 2.576,
"state": "+"
- `"remote"` - "38.229.71.1",
- `"refid"` - "204.9.54.119",
- `"st"` - 2,
- `"t"` - "u",
- `"when"` - 64,
- `"poll"` - 64,
- `"reach"` - 377,
- `"delay"` - 68.699,
- `"offset"` - -0.61,
- `"jitter"` - 2.576,
- `"state"` - "+"
},
{
"remote": "72.5.72.15",
"refid": "216.218.254.202",
"st": 2,
"t": "u",
"when": 63,
"poll": 64,
"reach": 377,
"delay": 22.654,
"offset": 0.231,
"jitter": 1.964,
"state": "*"
- `"remote"` - "72.5.72.15",
- `"refid"` - "216.218.254.202",
- `"st"` - 2,
- `"t"` - "u",
- `"when"` - 63,
- `"poll"` - 64,
- `"reach"` - 377,
- `"delay"` - 22.654,
- `"offset"` - 0.231,
- `"jitter"` - 1.964,
- `"state"` - "*"
}
]
$ ntpq -pn| jc --ntpq -p -r
[
{
"s": "+",
"remote": "44.190.6.254",
"refid": "127.67.113.92",
"st": "2",
"t": "u",
"when": "66",
"poll": "64",
"reach": "377",
"delay": "22.690",
"offset": "-0.392",
"jitter": "2.085"
- `"s"` - "+",
- `"remote"` - "44.190.6.254",
- `"refid"` - "127.67.113.92",
- `"st"` - "2",
- `"t"` - "u",
- `"when"` - "66",
- `"poll"` - "64",
- `"reach"` - "377",
- `"delay"` - "22.690",
- `"offset"` - "-0.392",
- `"jitter"` - "2.085"
},
{
"s": "-",
"remote": "108.59.2.24",
"refid": "130.133.1.10",
"st": "2",
"t": "u",
"when": "63",
"poll": "64",
"reach": "377",
"delay": "90.805",
"offset": "2.840",
"jitter": "1.908"
- `"s"` - "-",
- `"remote"` - "108.59.2.24",
- `"refid"` - "130.133.1.10",
- `"st"` - "2",
- `"t"` - "u",
- `"when"` - "63",
- `"poll"` - "64",
- `"reach"` - "377",
- `"delay"` - "90.805",
- `"offset"` - "2.840",
- `"jitter"` - "1.908"
},
{
"s": "+",
"remote": "38.229.71.1",
"refid": "204.9.54.119",
"st": "2",
"t": "u",
"when": "64",
"poll": "64",
"reach": "377",
"delay": "68.699",
"offset": "-0.610",
"jitter": "2.576"
- `"s"` - "+",
- `"remote"` - "38.229.71.1",
- `"refid"` - "204.9.54.119",
- `"st"` - "2",
- `"t"` - "u",
- `"when"` - "64",
- `"poll"` - "64",
- `"reach"` - "377",
- `"delay"` - "68.699",
- `"offset"` - "-0.610",
- `"jitter"` - "2.576"
},
{
"s": "*",
"remote": "72.5.72.15",
"refid": "216.218.254.202",
"st": "2",
"t": "u",
"when": "63",
"poll": "64",
"reach": "377",
"delay": "22.654",
"offset": "0.231",
"jitter": "1.964"
- `"s"` - "*",
- `"remote"` - "72.5.72.15",
- `"refid"` - "216.218.254.202",
- `"st"` - "2",
- `"t"` - "u",
- `"when"` - "63",
- `"poll"` - "64",
- `"reach"` - "377",
- `"delay"` - "22.654",
- `"offset"` - "0.231",
- `"jitter"` - "1.964"
}
]
<a id="jc.parsers.ntpq.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ntpq.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.passwd"></a>
# jc.parsers.passwd
jc - JSON CLI output utility `/etc/passwd` file Parser
Usage (cli):
@ -31,36 +33,37 @@ Schema:
}
]
Examples:
**Examples**:
$ cat /etc/passwd | jc --passwd -p
[
{
"username": "nobody",
"password": "*",
"uid": -2,
"gid": -2,
"comment": "Unprivileged User",
"home": "/var/empty",
"shell": "/usr/bin/false"
- `"username"` - "nobody",
- `"password"` - "*",
- `"uid"` - -2,
- `"gid"` - -2,
- `"comment"` - "Unprivileged User",
- `"home"` - "/var/empty",
- `"shell"` - "/usr/bin/false"
},
{
"username": "root",
"password": "*",
"uid": 0,
"gid": 0,
"comment": "System Administrator",
"home": "/var/root",
"shell": "/bin/sh"
- `"username"` - "root",
- `"password"` - "*",
- `"uid"` - 0,
- `"gid"` - 0,
- `"comment"` - "System Administrator",
- `"home"` - "/var/root",
- `"shell"` - "/bin/sh"
},
{
"username": "daemon",
"password": "*",
"uid": 1,
"gid": 1,
"comment": "System Services",
"home": "/var/root",
"shell": "/usr/bin/false"
- `"username"` - "daemon",
- `"password"` - "*",
- `"uid"` - 1,
- `"gid"` - 1,
- `"comment"` - "System Services",
- `"home"` - "/var/root",
- `"shell"` - "/usr/bin/false"
},
...
]
@ -68,56 +71,65 @@ Examples:
$ cat /etc/passwd | jc --passwd -p -r
[
{
"username": "nobody",
"password": "*",
"uid": "-2",
"gid": "-2",
"comment": "Unprivileged User",
"home": "/var/empty",
"shell": "/usr/bin/false"
- `"username"` - "nobody",
- `"password"` - "*",
- `"uid"` - "-2",
- `"gid"` - "-2",
- `"comment"` - "Unprivileged User",
- `"home"` - "/var/empty",
- `"shell"` - "/usr/bin/false"
},
{
"username": "root",
"password": "*",
"uid": "0",
"gid": "0",
"comment": "System Administrator",
"home": "/var/root",
"shell": "/bin/sh"
- `"username"` - "root",
- `"password"` - "*",
- `"uid"` - "0",
- `"gid"` - "0",
- `"comment"` - "System Administrator",
- `"home"` - "/var/root",
- `"shell"` - "/bin/sh"
},
{
"username": "daemon",
"password": "*",
"uid": "1",
"gid": "1",
"comment": "System Services",
"home": "/var/root",
"shell": "/usr/bin/false"
- `"username"` - "daemon",
- `"password"` - "*",
- `"uid"` - "1",
- `"gid"` - "1",
- `"comment"` - "System Services",
- `"home"` - "/var/root",
- `"shell"` - "/usr/bin/false"
},
...
]
<a id="jc.parsers.passwd.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.passwd.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ping"></a>
# jc.parsers.ping
jc - JSON CLI output utility `ping` command output parser
Supports `ping` and `ping6` output.
@ -73,119 +75,129 @@ Schema:
[1] only if an 'unparsable_line' type
[2] hex value converted to decimal
Examples:
**Examples**:
$ ping -c 3 -p ff cnn.com | jc --ping -p
{
"destination_ip": "151.101.1.67",
"data_bytes": 56,
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": 3,
"packets_received": 3,
"packet_loss_percent": 0.0,
"duplicates": 0,
"round_trip_ms_min": 28.015,
"round_trip_ms_avg": 32.848,
"round_trip_ms_max": 39.376,
"round_trip_ms_stddev": 4.79,
"responses": [
- `"destination_ip"` - "151.101.1.67",
- `"data_bytes"` - 56,
- `"pattern"` - "0xff",
- `"destination"` - "cnn.com",
- `"packets_transmitted"` - 3,
- `"packets_received"` - 3,
- `"packet_loss_percent"` - 0.0,
- `"duplicates"` - 0,
- `"round_trip_ms_min"` - 28.015,
- `"round_trip_ms_avg"` - 32.848,
- `"round_trip_ms_max"` - 39.376,
- `"round_trip_ms_stddev"` - 4.79,
- `"responses"` - [
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 0,
"ttl": 59,
"time_ms": 28.015,
"duplicate": false
- `"type"` - "reply",
- `"bytes"` - 64,
- `"response_ip"` - "151.101.1.67",
- `"icmp_seq"` - 0,
- `"ttl"` - 59,
- `"time_ms"` - 28.015,
- `"duplicate"` - false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 1,
"ttl": 59,
"time_ms": 39.376,
"duplicate": false
- `"type"` - "reply",
- `"bytes"` - 64,
- `"response_ip"` - "151.101.1.67",
- `"icmp_seq"` - 1,
- `"ttl"` - 59,
- `"time_ms"` - 39.376,
- `"duplicate"` - false
},
{
"type": "reply",
"bytes": 64,
"response_ip": "151.101.1.67",
"icmp_seq": 2,
"ttl": 59,
"time_ms": 31.153,
"duplicate": false
- `"type"` - "reply",
- `"bytes"` - 64,
- `"response_ip"` - "151.101.1.67",
- `"icmp_seq"` - 2,
- `"ttl"` - 59,
- `"time_ms"` - 31.153,
- `"duplicate"` - false
}
]
}
$ ping -c 3 -p ff cnn.com | jc --ping -p -r
{
"destination_ip": "151.101.129.67",
"data_bytes": "56",
"pattern": "0xff",
"destination": "cnn.com",
"packets_transmitted": "3",
"packets_received": "3",
"packet_loss_percent": "0.0",
"duplicates": "0",
"round_trip_ms_min": "25.078",
"round_trip_ms_avg": "29.543",
"round_trip_ms_max": "32.553",
"round_trip_ms_stddev": "3.221",
"responses": [
- `"destination_ip"` - "151.101.129.67",
- `"data_bytes"` - "56",
- `"pattern"` - "0xff",
- `"destination"` - "cnn.com",
- `"packets_transmitted"` - "3",
- `"packets_received"` - "3",
- `"packet_loss_percent"` - "0.0",
- `"duplicates"` - "0",
- `"round_trip_ms_min"` - "25.078",
- `"round_trip_ms_avg"` - "29.543",
- `"round_trip_ms_max"` - "32.553",
- `"round_trip_ms_stddev"` - "3.221",
- `"responses"` - [
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "0",
"ttl": "59",
"time_ms": "25.078",
"duplicate": false
- `"type"` - "reply",
- `"bytes"` - "64",
- `"response_ip"` - "151.101.129.67",
- `"icmp_seq"` - "0",
- `"ttl"` - "59",
- `"time_ms"` - "25.078",
- `"duplicate"` - false
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "1",
"ttl": "59",
"time_ms": "30.999",
"duplicate": false
- `"type"` - "reply",
- `"bytes"` - "64",
- `"response_ip"` - "151.101.129.67",
- `"icmp_seq"` - "1",
- `"ttl"` - "59",
- `"time_ms"` - "30.999",
- `"duplicate"` - false
},
{
"type": "reply",
"bytes": "64",
"response_ip": "151.101.129.67",
"icmp_seq": "2",
"ttl": "59",
"time_ms": "32.553",
"duplicate": false
- `"type"` - "reply",
- `"bytes"` - "64",
- `"response_ip"` - "151.101.129.67",
- `"icmp_seq"` - "2",
- `"ttl"` - "59",
- `"time_ms"` - "32.553",
- `"duplicate"` - false
}
]
}
<a id="jc.parsers.ping.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ping.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ping_s"></a>
# jc.parsers.ping\_s
# jc.parsers.ping_s
jc - JSON CLI output utility `ping` command output streaming parser
> This streaming parser outputs JSON Lines
@ -72,7 +74,8 @@ Schema:
[0] 'reply', 'timeout', 'summary', etc. See `_error_type.type_map`
for all options.
Examples:
**Examples**:
$ ping 1.1.1.1 | jc --ping-s
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...}
@ -86,34 +89,45 @@ Examples:
{"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...}
...
<a id="jc.parsers.ping_s.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ping_s.parse"></a>
#### 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.
Parameters:
**Arguments**:
data: (iterable) line-based text data to parse
- `data` - (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
**Yields**:
Yields:
Dictionary. Raw or processed structured data.
Returns:
**Returns**:
Iterator object

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.pip_list"></a>
# jc.parsers.pip\_list
# jc.parsers.pip_list
jc - JSON CLI output utility `pip-list` command output parser
Usage (cli):
@ -31,46 +33,56 @@ Schema:
}
]
Examples:
**Examples**:
$ pip list | jc --pip-list -p
[
{
"package": "ansible",
"version": "2.8.5"
- `"package"` - "ansible",
- `"version"` - "2.8.5"
},
{
"package": "antlr4-python3-runtime",
"version": "4.7.2"
- `"package"` - "antlr4-python3-runtime",
- `"version"` - "4.7.2"
},
{
"package": "asn1crypto",
"version": "0.24.0"
- `"package"` - "asn1crypto",
- `"version"` - "0.24.0"
},
...
]
<a id="jc.parsers.pip_list.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.pip_list.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.pip_show"></a>
# jc.parsers.pip\_show
# jc.parsers.pip_show
jc - JSON CLI output utility `pip-show` command output parser
Usage (cli):
@ -38,57 +40,67 @@ Schema:
}
]
Examples:
**Examples**:
$ pip show wrapt jc wheel | jc --pip-show -p
[
{
"name": "wrapt",
"version": "1.11.2",
"summary": "Module for decorators, wrappers and monkey patching.",
"home_page": "https://github.com/GrahamDumpleton/wrapt",
"author": "Graham Dumpleton",
"author_email": "Graham.Dumpleton@gmail.com",
"license": "BSD",
"location": "/usr/local/lib/python3.7/site-packages",
"requires": null,
"required_by": "astroid"
- `"name"` - "wrapt",
- `"version"` - "1.11.2",
- `"summary"` - "Module for decorators, wrappers and monkey patching.",
- `"home_page"` - "https://github.com/GrahamDumpleton/wrapt",
- `"author"` - "Graham Dumpleton",
- `"author_email"` - "Graham.Dumpleton@gmail.com",
- `"license"` - "BSD",
- `"location"` - "/usr/local/lib/python3.7/site-packages",
- `"requires"` - null,
- `"required_by"` - "astroid"
},
{
"name": "wheel",
"version": "0.33.4",
"summary": "A built-package format for Python.",
"home_page": "https://github.com/pypa/wheel",
"author": "Daniel Holth",
"author_email": "dholth@fastmail.fm",
"license": "MIT",
"location": "/usr/local/lib/python3.7/site-packages",
"requires": null,
"required_by": null
- `"name"` - "wheel",
- `"version"` - "0.33.4",
- `"summary"` - "A built-package format for Python.",
- `"home_page"` - "https://github.com/pypa/wheel",
- `"author"` - "Daniel Holth",
- `"author_email"` - "dholth@fastmail.fm",
- `"license"` - "MIT",
- `"location"` - "/usr/local/lib/python3.7/site-packages",
- `"requires"` - null,
- `"required_by"` - null
}
]
<a id="jc.parsers.pip_show.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.pip_show.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ps"></a>
# jc.parsers.ps
jc - JSON CLI output utility `ps` command output parser
`ps` options supported:
@ -49,39 +51,40 @@ Schema:
}
]
Examples:
**Examples**:
$ ps -ef | jc --ps -p
[
{
"uid": "root",
"pid": 1,
"ppid": 0,
"c": 0,
"stime": "Nov01",
"tty": null,
"time": "00:00:11",
"cmd": "/usr/lib/systemd/systemd --switched-root --system --dese..."
- `"uid"` - "root",
- `"pid"` - 1,
- `"ppid"` - 0,
- `"c"` - 0,
- `"stime"` - "Nov01",
- `"tty"` - null,
- `"time"` - "00:00:11",
- `"cmd"` - "/usr/lib/systemd/systemd --switched-root --system --dese..."
},
{
"uid": "root",
"pid": 2,
"ppid": 0,
"c": 0,
"stime": "Nov01",
"tty": null,
"time": "00:00:00",
"cmd": "[kthreadd]"
- `"uid"` - "root",
- `"pid"` - 2,
- `"ppid"` - 0,
- `"c"` - 0,
- `"stime"` - "Nov01",
- `"tty"` - null,
- `"time"` - "00:00:00",
- `"cmd"` - "[kthreadd]"
},
{
"uid": "root",
"pid": 4,
"ppid": 2,
"c": 0,
"stime": "Nov01",
"tty": null,
"time": "00:00:00",
"cmd": "[kworker/0:0H]"
- `"uid"` - "root",
- `"pid"` - 4,
- `"ppid"` - 2,
- `"c"` - 0,
- `"stime"` - "Nov01",
- `"tty"` - null,
- `"time"` - "00:00:00",
- `"cmd"` - "[kworker/0:0H]"
},
...
]
@ -89,34 +92,34 @@ Examples:
$ ps -ef | jc --ps -p -r
[
{
"uid": "root",
"pid": "1",
"ppid": "0",
"c": "0",
"stime": "Nov01",
"tty": "?",
"time": "00:00:11",
"cmd": "/usr/lib/systemd/systemd --switched-root --system --dese..."
- `"uid"` - "root",
- `"pid"` - "1",
- `"ppid"` - "0",
- `"c"` - "0",
- `"stime"` - "Nov01",
- `"tty"` - "?",
- `"time"` - "00:00:11",
- `"cmd"` - "/usr/lib/systemd/systemd --switched-root --system --dese..."
},
{
"uid": "root",
"pid": "2",
"ppid": "0",
"c": "0",
"stime": "Nov01",
"tty": "?",
"time": "00:00:00",
"cmd": "[kthreadd]"
- `"uid"` - "root",
- `"pid"` - "2",
- `"ppid"` - "0",
- `"c"` - "0",
- `"stime"` - "Nov01",
- `"tty"` - "?",
- `"time"` - "00:00:00",
- `"cmd"` - "[kthreadd]"
},
{
"uid": "root",
"pid": "4",
"ppid": "2",
"c": "0",
"stime": "Nov01",
"tty": "?",
"time": "00:00:00",
"cmd": "[kworker/0:0H]"
- `"uid"` - "root",
- `"pid"` - "4",
- `"ppid"` - "2",
- `"c"` - "0",
- `"stime"` - "Nov01",
- `"tty"` - "?",
- `"time"` - "00:00:00",
- `"cmd"` - "[kworker/0:0H]"
},
...
]
@ -124,43 +127,43 @@ Examples:
$ ps axu | jc --ps -p
[
{
"user": "root",
"pid": 1,
"cpu_percent": 0.0,
"mem_percent": 0.1,
"vsz": 128072,
"rss": 6784,
"tty": null,
"stat": "Ss",
"start": "Nov09",
"time": "0:08",
"command": "/usr/lib/systemd/systemd --switched-root --system --..."
- `"user"` - "root",
- `"pid"` - 1,
- `"cpu_percent"` - 0.0,
- `"mem_percent"` - 0.1,
- `"vsz"` - 128072,
- `"rss"` - 6784,
- `"tty"` - null,
- `"stat"` - "Ss",
- `"start"` - "Nov09",
- `"time"` - "0:08",
- `"command"` - "/usr/lib/systemd/systemd --switched-root --system --..."
},
{
"user": "root",
"pid": 2,
"cpu_percent": 0.0,
"mem_percent": 0.0,
"vsz": 0,
"rss": 0,
"tty": null,
"stat": "S",
"start": "Nov09",
"time": "0:00",
"command": "[kthreadd]"
- `"user"` - "root",
- `"pid"` - 2,
- `"cpu_percent"` - 0.0,
- `"mem_percent"` - 0.0,
- `"vsz"` - 0,
- `"rss"` - 0,
- `"tty"` - null,
- `"stat"` - "S",
- `"start"` - "Nov09",
- `"time"` - "0:00",
- `"command"` - "[kthreadd]"
},
{
"user": "root",
"pid": 4,
"cpu_percent": 0.0,
"mem_percent": 0.0,
"vsz": 0,
"rss": 0,
"tty": null,
"stat": "S<",
"start": "Nov09",
"time": "0:00",
"command": "[kworker/0:0H]"
- `"user"` - "root",
- `"pid"` - 4,
- `"cpu_percent"` - 0.0,
- `"mem_percent"` - 0.0,
- `"vsz"` - 0,
- `"rss"` - 0,
- `"tty"` - null,
- `"stat"` - "S<",
- `"start"` - "Nov09",
- `"time"` - "0:00",
- `"command"` - "[kworker/0:0H]"
},
...
]
@ -168,68 +171,77 @@ Examples:
$ ps axu | jc --ps -p -r
[
{
"user": "root",
"pid": "1",
"cpu_percent": "0.0",
"mem_percent": "0.1",
"vsz": "128072",
"rss": "6784",
"tty": "?",
"stat": "Ss",
"start": "Nov09",
"time": "0:08",
"command": "/usr/lib/systemd/systemd --switched-root --system --..."
- `"user"` - "root",
- `"pid"` - "1",
- `"cpu_percent"` - "0.0",
- `"mem_percent"` - "0.1",
- `"vsz"` - "128072",
- `"rss"` - "6784",
- `"tty"` - "?",
- `"stat"` - "Ss",
- `"start"` - "Nov09",
- `"time"` - "0:08",
- `"command"` - "/usr/lib/systemd/systemd --switched-root --system --..."
},
{
"user": "root",
"pid": "2",
"cpu_percent": "0.0",
"mem_percent": "0.0",
"vsz": "0",
"rss": "0",
"tty": "?",
"stat": "S",
"start": "Nov09",
"time": "0:00",
"command": "[kthreadd]"
- `"user"` - "root",
- `"pid"` - "2",
- `"cpu_percent"` - "0.0",
- `"mem_percent"` - "0.0",
- `"vsz"` - "0",
- `"rss"` - "0",
- `"tty"` - "?",
- `"stat"` - "S",
- `"start"` - "Nov09",
- `"time"` - "0:00",
- `"command"` - "[kthreadd]"
},
{
"user": "root",
"pid": "4",
"cpu_percent": "0.0",
"mem_percent": "0.0",
"vsz": "0",
"rss": "0",
"tty": "?",
"stat": "S<",
"start": "Nov09",
"time": "0:00",
"command": "[kworker/0:0H]"
- `"user"` - "root",
- `"pid"` - "4",
- `"cpu_percent"` - "0.0",
- `"mem_percent"` - "0.0",
- `"vsz"` - "0",
- `"rss"` - "0",
- `"tty"` - "?",
- `"stat"` - "S<",
- `"start"` - "Nov09",
- `"time"` - "0:00",
- `"command"` - "[kworker/0:0H]"
},
...
]
<a id="jc.parsers.ps.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ps.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.route"></a>
# jc.parsers.route
jc - JSON CLI output utility `route` command output parser
Usage (cli):
@ -42,40 +44,41 @@ Schema:
}
]
Examples:
**Examples**:
$ route -ee | jc --route -p
[
{
"destination": "default",
"gateway": "_gateway",
"genmask": "0.0.0.0",
"flags": "UG",
"metric": 202,
"ref": 0,
"use": 0,
"iface": "ens33",
"mss": 0,
"window": 0,
"irtt": 0,
"flags_pretty": [
- `"destination"` - "default",
- `"gateway"` - "_gateway",
- `"genmask"` - "0.0.0.0",
- `"flags"` - "UG",
- `"metric"` - 202,
- `"ref"` - 0,
- `"use"` - 0,
- `"iface"` - "ens33",
- `"mss"` - 0,
- `"window"` - 0,
- `"irtt"` - 0,
- `"flags_pretty"` - [
"UP",
"GATEWAY"
]
},
{
"destination": "192.168.71.0",
"gateway": "0.0.0.0",
"genmask": "255.255.255.0",
"flags": "U",
"metric": 202,
"ref": 0,
"use": 0,
"iface": "ens33",
"mss": 0,
"window": 0,
"irtt": 0,
"flags_pretty": [
- `"destination"` - "192.168.71.0",
- `"gateway"` - "0.0.0.0",
- `"genmask"` - "255.255.255.0",
- `"flags"` - "U",
- `"metric"` - 202,
- `"ref"` - 0,
- `"use"` - 0,
- `"iface"` - "ens33",
- `"mss"` - 0,
- `"window"` - 0,
- `"irtt"` - 0,
- `"flags_pretty"` - [
"UP"
]
}
@ -84,54 +87,63 @@ Examples:
$ route -ee | jc --route -p -r
[
{
"destination": "default",
"gateway": "_gateway",
"genmask": "0.0.0.0",
"flags": "UG",
"metric": "202",
"ref": "0",
"use": "0",
"iface": "ens33",
"mss": "0",
"window": "0",
"irtt": "0"
- `"destination"` - "default",
- `"gateway"` - "_gateway",
- `"genmask"` - "0.0.0.0",
- `"flags"` - "UG",
- `"metric"` - "202",
- `"ref"` - "0",
- `"use"` - "0",
- `"iface"` - "ens33",
- `"mss"` - "0",
- `"window"` - "0",
- `"irtt"` - "0"
},
{
"destination": "192.168.71.0",
"gateway": "0.0.0.0",
"genmask": "255.255.255.0",
"flags": "U",
"metric": "202",
"ref": "0",
"use": "0",
"iface": "ens33",
"mss": "0",
"window": "0",
"irtt": "0"
- `"destination"` - "192.168.71.0",
- `"gateway"` - "0.0.0.0",
- `"genmask"` - "255.255.255.0",
- `"flags"` - "U",
- `"metric"` - "202",
- `"ref"` - "0",
- `"use"` - "0",
- `"iface"` - "ens33",
- `"mss"` - "0",
- `"window"` - "0",
- `"irtt"` - "0"
}
]
<a id="jc.parsers.route.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.route.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.rpm_qi"></a>
# 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`.
@ -62,58 +64,59 @@ Schema:
[0] naive timestamp
[1] Aware timestamp if timezone is UTC
Examples:
**Examples**:
$ rpm -qia | jc --rpm-qi -p
[
{
"name": "make",
"epoch": 1,
"version": "3.82",
"release": "24.el7",
"architecture": "x86_64",
"install_date": "Wed 16 Oct 2019 09:21:42 AM PDT",
"group": "Development/Tools",
"size": 1160660,
"license": "GPLv2+",
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
"source_rpm": "make-3.82-24.el7.src.rpm",
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
"build_host": "x86-01.bsys.centos.org",
"relocations": "(not relocatable)",
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
"vendor": "CentOS",
"url": "http://www.gnu.org/software/make/",
"summary": "A GNU tool which simplifies the build process for ...",
"description": "A GNU tool for controlling the generation of ex...",
"build_epoch": 1565311645,
"build_epoch_utc": null,
"install_date_epoch": 1571242902,
"install_date_epoch_utc": null
- `"name"` - "make",
- `"epoch"` - 1,
- `"version"` - "3.82",
- `"release"` - "24.el7",
- `"architecture"` - "x86_64",
- `"install_date"` - "Wed 16 Oct 2019 09:21:42 AM PDT",
- `"group"` - "Development/Tools",
- `"size"` - 1160660,
- `"license"` - "GPLv2+",
- `"signature"` - "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
- `"source_rpm"` - "make-3.82-24.el7.src.rpm",
- `"build_date"` - "Thu 08 Aug 2019 05:47:25 PM PDT",
- `"build_host"` - "x86-01.bsys.centos.org",
- `"relocations"` - "(not relocatable)",
- `"packager"` - "CentOS BuildSystem <http://bugs.centos.org>",
- `"vendor"` - "CentOS",
- `"url"` - "http://www.gnu.org/software/make/",
- `"summary"` - "A GNU tool which simplifies the build process for ...",
- `"description"` - "A GNU tool for controlling the generation of ex...",
- `"build_epoch"` - 1565311645,
- `"build_epoch_utc"` - null,
- `"install_date_epoch"` - 1571242902,
- `"install_date_epoch_utc"` - null
},
{
"name": "kbd-legacy",
"version": "1.15.5",
"release": "15.el7",
"architecture": "noarch",
"install_date": "Thu 15 Aug 2019 10:53:08 AM PDT",
"group": "System Environment/Base",
"size": 503608,
"license": "GPLv2+",
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
"build_host": "x86-01.bsys.centos.org",
"relocations": "(not relocatable)",
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
"vendor": "CentOS",
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
"summary": "Legacy data for kbd package",
"description": "The kbd-legacy package contains original keymap...",
"build_epoch": 1540939200,
"build_epoch_utc": null,
"install_date_epoch": 1565891588,
"install_date_epoch_utc": null
- `"name"` - "kbd-legacy",
- `"version"` - "1.15.5",
- `"release"` - "15.el7",
- `"architecture"` - "noarch",
- `"install_date"` - "Thu 15 Aug 2019 10:53:08 AM PDT",
- `"group"` - "System Environment/Base",
- `"size"` - 503608,
- `"license"` - "GPLv2+",
- `"signature"` - "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
- `"source_rpm"` - "kbd-1.15.5-15.el7.src.rpm",
- `"build_date"` - "Tue 30 Oct 2018 03:40:00 PM PDT",
- `"build_host"` - "x86-01.bsys.centos.org",
- `"relocations"` - "(not relocatable)",
- `"packager"` - "CentOS BuildSystem <http://bugs.centos.org>",
- `"vendor"` - "CentOS",
- `"url"` - "http://ftp.altlinux.org/pub/people/legion/kbd",
- `"summary"` - "Legacy data for kbd package",
- `"description"` - "The kbd-legacy package contains original keymap...",
- `"build_epoch"` - 1540939200,
- `"build_epoch_utc"` - null,
- `"install_date_epoch"` - 1565891588,
- `"install_date_epoch_utc"` - null
},
...
]
@ -121,70 +124,79 @@ Examples:
$ rpm -qia | jc --rpm-qi -p -r
[
{
"name": "make",
"epoch": "1",
"version": "3.82",
"release": "24.el7",
"architecture": "x86_64",
"install_date": "Wed 16 Oct 2019 09:21:42 AM PDT",
"group": "Development/Tools",
"size": "1160660",
"license": "GPLv2+",
"signature": "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
"source_rpm": "make-3.82-24.el7.src.rpm",
"build_date": "Thu 08 Aug 2019 05:47:25 PM PDT",
"build_host": "x86-01.bsys.centos.org",
"relocations": "(not relocatable)",
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
"vendor": "CentOS",
"url": "http://www.gnu.org/software/make/",
"summary": "A GNU tool which simplifies the build process for...",
"description": "A GNU tool for controlling the generation of exe..."
- `"name"` - "make",
- `"epoch"` - "1",
- `"version"` - "3.82",
- `"release"` - "24.el7",
- `"architecture"` - "x86_64",
- `"install_date"` - "Wed 16 Oct 2019 09:21:42 AM PDT",
- `"group"` - "Development/Tools",
- `"size"` - "1160660",
- `"license"` - "GPLv2+",
- `"signature"` - "RSA/SHA256, Thu 22 Aug 2019 02:34:59 PM PDT, Key ...",
- `"source_rpm"` - "make-3.82-24.el7.src.rpm",
- `"build_date"` - "Thu 08 Aug 2019 05:47:25 PM PDT",
- `"build_host"` - "x86-01.bsys.centos.org",
- `"relocations"` - "(not relocatable)",
- `"packager"` - "CentOS BuildSystem <http://bugs.centos.org>",
- `"vendor"` - "CentOS",
- `"url"` - "http://www.gnu.org/software/make/",
- `"summary"` - "A GNU tool which simplifies the build process for...",
- `"description"` - "A GNU tool for controlling the generation of exe..."
},
{
"name": "kbd-legacy",
"version": "1.15.5",
"release": "15.el7",
"architecture": "noarch",
"install_date": "Thu 15 Aug 2019 10:53:08 AM PDT",
"group": "System Environment/Base",
"size": "503608",
"license": "GPLv2+",
"signature": "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
"source_rpm": "kbd-1.15.5-15.el7.src.rpm",
"build_date": "Tue 30 Oct 2018 03:40:00 PM PDT",
"build_host": "x86-01.bsys.centos.org",
"relocations": "(not relocatable)",
"packager": "CentOS BuildSystem <http://bugs.centos.org>",
"vendor": "CentOS",
"url": "http://ftp.altlinux.org/pub/people/legion/kbd",
"summary": "Legacy data for kbd package",
"description": "The kbd-legacy package contains original keymaps..."
- `"name"` - "kbd-legacy",
- `"version"` - "1.15.5",
- `"release"` - "15.el7",
- `"architecture"` - "noarch",
- `"install_date"` - "Thu 15 Aug 2019 10:53:08 AM PDT",
- `"group"` - "System Environment/Base",
- `"size"` - "503608",
- `"license"` - "GPLv2+",
- `"signature"` - "RSA/SHA256, Mon 12 Nov 2018 07:17:49 AM PST, Key ...",
- `"source_rpm"` - "kbd-1.15.5-15.el7.src.rpm",
- `"build_date"` - "Tue 30 Oct 2018 03:40:00 PM PDT",
- `"build_host"` - "x86-01.bsys.centos.org",
- `"relocations"` - "(not relocatable)",
- `"packager"` - "CentOS BuildSystem <http://bugs.centos.org>",
- `"vendor"` - "CentOS",
- `"url"` - "http://ftp.altlinux.org/pub/people/legion/kbd",
- `"summary"` - "Legacy data for kbd package",
- `"description"` - "The kbd-legacy package contains original keymaps..."
},
...
]
<a id="jc.parsers.rpm_qi.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.rpm_qi.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.sfdisk"></a>
# jc.parsers.sfdisk
jc - JSON CLI output utility `sfdisk` command output parser
Supports the following `sfdisk` options:
@ -73,159 +75,169 @@ Schema:
[0] will be integer when using deprecated -d sfdisk option
Examples:
**Examples**:
# sfdisk -l | jc --sfdisk -p
[
{
"disk": "/dev/sda",
"cylinders": 2610,
"heads": 255,
"sectors_per_track": 63,
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, ...",
"partitions": [
- `"disk"` - "/dev/sda",
- `"cylinders"` - 2610,
- `"heads"` - 255,
- `"sectors_per_track"` - 63,
- `"units"` - "cylinders of 8225280 bytes, blocks of 1024 bytes, ...",
- `"partitions"` - [
{
"device": "/dev/sda1",
"boot": true,
"start": 0,
"end": 130,
"cyls": 131,
"blocks": 1048576,
"id": "83",
"system": "Linux"
- `"device"` - "/dev/sda1",
- `"boot"` - true,
- `"start"` - 0,
- `"end"` - 130,
- `"cyls"` - 131,
- `"blocks"` - 1048576,
- `"id"` - "83",
- `"system"` - "Linux"
},
{
"device": "/dev/sda2",
"boot": false,
"start": 130,
"end": 2610,
"cyls": 2481,
"blocks": 19921920,
"id": "8e",
"system": "Linux LVM"
- `"device"` - "/dev/sda2",
- `"boot"` - false,
- `"start"` - 130,
- `"end"` - 2610,
- `"cyls"` - 2481,
- `"blocks"` - 19921920,
- `"id"` - "8e",
- `"system"` - "Linux LVM"
},
{
"device": "/dev/sda3",
"boot": false,
"start": 0,
"end": null,
"cyls": 0,
"blocks": 0,
"id": "0",
"system": "Empty"
- `"device"` - "/dev/sda3",
- `"boot"` - false,
- `"start"` - 0,
- `"end"` - null,
- `"cyls"` - 0,
- `"blocks"` - 0,
- `"id"` - "0",
- `"system"` - "Empty"
},
{
"device": "/dev/sda4",
"boot": false,
"start": 0,
"end": null,
"cyls": 0,
"blocks": 0,
"id": "0",
"system": "Empty"
- `"device"` - "/dev/sda4",
- `"boot"` - false,
- `"start"` - 0,
- `"end"` - null,
- `"cyls"` - 0,
- `"blocks"` - 0,
- `"id"` - "0",
- `"system"` - "Empty"
}
]
},
{
"disk": "/dev/mapper/centos-root",
"cylinders": 2218,
"heads": 255,
"sectors_per_track": 63
- `"disk"` - "/dev/mapper/centos-root",
- `"cylinders"` - 2218,
- `"heads"` - 255,
- `"sectors_per_track"` - 63
},
{
"disk": "/dev/mapper/centos-swap",
"cylinders": 261,
"heads": 255,
"sectors_per_track": 63
- `"disk"` - "/dev/mapper/centos-swap",
- `"cylinders"` - 261,
- `"heads"` - 255,
- `"sectors_per_track"` - 63
}
]
# sfdisk -l | jc --sfdisk -p -r
[
{
"disk": "/dev/sda",
"cylinders": "2610",
"heads": "255",
"sectors_per_track": "63",
"units": "cylinders of 8225280 bytes, blocks of 1024 bytes, co...",
"partitions": [
- `"disk"` - "/dev/sda",
- `"cylinders"` - "2610",
- `"heads"` - "255",
- `"sectors_per_track"` - "63",
- `"units"` - "cylinders of 8225280 bytes, blocks of 1024 bytes, co...",
- `"partitions"` - [
{
"device": "/dev/sda1",
"boot": "*",
"start": "0+",
"end": "130-",
"cyls": "131-",
"blocks": "1048576",
"id": "83",
"system": "Linux"
- `"device"` - "/dev/sda1",
- `"boot"` - "*",
- `"start"` - "0+",
- `"end"` - "130-",
- `"cyls"` - "131-",
- `"blocks"` - "1048576",
- `"id"` - "83",
- `"system"` - "Linux"
},
{
"device": "/dev/sda2",
"boot": null,
"start": "130+",
"end": "2610-",
"cyls": "2481-",
"blocks": "19921920",
"id": "8e",
"system": "Linux LVM"
- `"device"` - "/dev/sda2",
- `"boot"` - null,
- `"start"` - "130+",
- `"end"` - "2610-",
- `"cyls"` - "2481-",
- `"blocks"` - "19921920",
- `"id"` - "8e",
- `"system"` - "Linux LVM"
},
{
"device": "/dev/sda3",
"boot": null,
"start": "0",
"end": "-",
"cyls": "0",
"blocks": "0",
"id": "0",
"system": "Empty"
- `"device"` - "/dev/sda3",
- `"boot"` - null,
- `"start"` - "0",
- `"end"` - "-",
- `"cyls"` - "0",
- `"blocks"` - "0",
- `"id"` - "0",
- `"system"` - "Empty"
},
{
"device": "/dev/sda4",
"boot": null,
"start": "0",
"end": "-",
"cyls": "0",
"blocks": "0",
"id": "0",
"system": "Empty"
- `"device"` - "/dev/sda4",
- `"boot"` - null,
- `"start"` - "0",
- `"end"` - "-",
- `"cyls"` - "0",
- `"blocks"` - "0",
- `"id"` - "0",
- `"system"` - "Empty"
}
]
},
{
"disk": "/dev/mapper/centos-root",
"cylinders": "2218",
"heads": "255",
"sectors_per_track": "63"
- `"disk"` - "/dev/mapper/centos-root",
- `"cylinders"` - "2218",
- `"heads"` - "255",
- `"sectors_per_track"` - "63"
},
{
"disk": "/dev/mapper/centos-swap",
"cylinders": "261",
"heads": "255",
"sectors_per_track": "63"
- `"disk"` - "/dev/mapper/centos-swap",
- `"cylinders"` - "261",
- `"heads"` - "255",
- `"sectors_per_track"` - "63"
}
]
<a id="jc.parsers.sfdisk.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.sfdisk.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.shadow"></a>
# jc.parsers.shadow
jc - JSON CLI output utility `/etc/shadow` file parser
Usage (cli):
@ -32,39 +34,40 @@ Schema:
}
]
Examples:
**Examples**:
$ sudo cat /etc/shadow | jc --shadow -p
[
{
"username": "root",
"password": "*",
"last_changed": 18113,
"minimum": 0,
"maximum": 99999,
"warn": 7,
"inactive": null,
"expire": null
- `"username"` - "root",
- `"password"` - "*",
- `"last_changed"` - 18113,
- `"minimum"` - 0,
- `"maximum"` - 99999,
- `"warn"` - 7,
- `"inactive"` - null,
- `"expire"` - null
},
{
"username": "daemon",
"password": "*",
"last_changed": 18113,
"minimum": 0,
"maximum": 99999,
"warn": 7,
"inactive": null,
"expire": null
- `"username"` - "daemon",
- `"password"` - "*",
- `"last_changed"` - 18113,
- `"minimum"` - 0,
- `"maximum"` - 99999,
- `"warn"` - 7,
- `"inactive"` - null,
- `"expire"` - null
},
{
"username": "bin",
"password": "*",
"last_changed": 18113,
"minimum": 0,
"maximum": 99999,
"warn": 7,
"inactive": null,
"expire": null
- `"username"` - "bin",
- `"password"` - "*",
- `"last_changed"` - 18113,
- `"minimum"` - 0,
- `"maximum"` - 99999,
- `"warn"` - 7,
- `"inactive"` - null,
- `"expire"` - null
},
...
]
@ -72,59 +75,68 @@ Examples:
$ sudo cat /etc/shadow | jc --shadow -p -r
[
{
"username": "root",
"password": "*",
"last_changed": "18113",
"minimum": "0",
"maximum": "99999",
"warn": "7",
"inactive": "",
"expire": ""
- `"username"` - "root",
- `"password"` - "*",
- `"last_changed"` - "18113",
- `"minimum"` - "0",
- `"maximum"` - "99999",
- `"warn"` - "7",
- `"inactive"` - "",
- `"expire"` - ""
},
{
"username": "daemon",
"password": "*",
"last_changed": "18113",
"minimum": "0",
"maximum": "99999",
"warn": "7",
"inactive": "",
"expire": ""
- `"username"` - "daemon",
- `"password"` - "*",
- `"last_changed"` - "18113",
- `"minimum"` - "0",
- `"maximum"` - "99999",
- `"warn"` - "7",
- `"inactive"` - "",
- `"expire"` - ""
},
{
"username": "bin",
"password": "*",
"last_changed": "18113",
"minimum": "0",
"maximum": "99999",
"warn": "7",
"inactive": "",
"expire": ""
- `"username"` - "bin",
- `"password"` - "*",
- `"last_changed"` - "18113",
- `"minimum"` - "0",
- `"maximum"` - "99999",
- `"warn"` - "7",
- `"inactive"` - "",
- `"expire"` - ""
},
...
]
<a id="jc.parsers.shadow.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.shadow.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ss"></a>
# 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
@ -49,261 +51,271 @@ Schema:
}
]
Examples:
**Examples**:
$ sudo ss -a | jc --ss -p
[
{
"netid": "nl",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
"peer_address": "*",
"channel": "rtnl:kernel"
- `"netid"` - "nl",
- `"state"` - "UNCONN",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"peer_address"` - "*",
- `"channel"` - "rtnl:kernel"
},
{
"netid": "nl",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
"peer_address": "*",
"pid": 893,
"channel": "rtnl:systemd-resolve"
- `"netid"` - "nl",
- `"state"` - "UNCONN",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"peer_address"` - "*",
- `"pid"` - 893,
- `"channel"` - "rtnl:systemd-resolve"
},
...
{
"netid": "p_raw",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
"peer_address": "*",
"link_layer": "LLDP",
"interface": "ens33"
- `"netid"` - "p_raw",
- `"state"` - "UNCONN",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"peer_address"` - "*",
- `"link_layer"` - "LLDP",
- `"interface"` - "ens33"
},
{
"netid": "u_dgr",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
"local_port": "93066",
"peer_address": "*",
"peer_port": "0",
"path": "/run/user/1000/systemd/notify"
- `"netid"` - "u_dgr",
- `"state"` - "UNCONN",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_port"` - "93066",
- `"peer_address"` - "*",
- `"peer_port"` - "0",
- `"path"` - "/run/user/1000/systemd/notify"
},
{
"netid": "u_seq",
"state": "LISTEN",
"recv_q": 0,
"send_q": 128,
"local_port": "20699",
"peer_address": "*",
"peer_port": "0",
"path": "/run/udev/control"
- `"netid"` - "u_seq",
- `"state"` - "LISTEN",
- `"recv_q"` - 0,
- `"send_q"` - 128,
- `"local_port"` - "20699",
- `"peer_address"` - "*",
- `"peer_port"` - "0",
- `"path"` - "/run/udev/control"
},
...
{
"netid": "icmp6",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
"local_address": "*",
"local_port": "ipv6-icmp",
"peer_address": "*",
"peer_port": "*",
"interface": "ens33"
- `"netid"` - "icmp6",
- `"state"` - "UNCONN",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "*",
- `"local_port"` - "ipv6-icmp",
- `"peer_address"` - "*",
- `"peer_port"` - "*",
- `"interface"` - "ens33"
},
{
"netid": "udp",
"state": "UNCONN",
"recv_q": 0,
"send_q": 0,
"local_address": "127.0.0.53",
"local_port": "domain",
"peer_address": "0.0.0.0",
"peer_port": "*",
"interface": "lo"
- `"netid"` - "udp",
- `"state"` - "UNCONN",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "127.0.0.53",
- `"local_port"` - "domain",
- `"peer_address"` - "0.0.0.0",
- `"peer_port"` - "*",
- `"interface"` - "lo"
},
{
"netid": "tcp",
"state": "LISTEN",
"recv_q": 0,
"send_q": 128,
"local_address": "127.0.0.53",
"local_port": "domain",
"peer_address": "0.0.0.0",
"peer_port": "*",
"interface": "lo"
- `"netid"` - "tcp",
- `"state"` - "LISTEN",
- `"recv_q"` - 0,
- `"send_q"` - 128,
- `"local_address"` - "127.0.0.53",
- `"local_port"` - "domain",
- `"peer_address"` - "0.0.0.0",
- `"peer_port"` - "*",
- `"interface"` - "lo"
},
{
"netid": "tcp",
"state": "LISTEN",
"recv_q": 0,
"send_q": 128,
"local_address": "0.0.0.0",
"local_port": "ssh",
"peer_address": "0.0.0.0",
"peer_port": "*"
- `"netid"` - "tcp",
- `"state"` - "LISTEN",
- `"recv_q"` - 0,
- `"send_q"` - 128,
- `"local_address"` - "0.0.0.0",
- `"local_port"` - "ssh",
- `"peer_address"` - "0.0.0.0",
- `"peer_port"` - "*"
},
{
"netid": "tcp",
"state": "LISTEN",
"recv_q": 0,
"send_q": 128,
"local_address": "[::]",
"local_port": "ssh",
"peer_address": "[::]",
"peer_port": "*"
- `"netid"` - "tcp",
- `"state"` - "LISTEN",
- `"recv_q"` - 0,
- `"send_q"` - 128,
- `"local_address"` - "[::]",
- `"local_port"` - "ssh",
- `"peer_address"` - "[::]",
- `"peer_port"` - "*"
},
{
"netid": "v_str",
"state": "ESTAB",
"recv_q": 0,
"send_q": 0,
"local_address": "999900439",
"local_port": "1023",
"peer_address": "0",
"peer_port": "976",
"local_port_num": 1023,
"peer_port_num": 976
- `"netid"` - "v_str",
- `"state"` - "ESTAB",
- `"recv_q"` - 0,
- `"send_q"` - 0,
- `"local_address"` - "999900439",
- `"local_port"` - "1023",
- `"peer_address"` - "0",
- `"peer_port"` - "976",
- `"local_port_num"` - 1023,
- `"peer_port_num"` - 976
}
]
$ sudo ss -a | jc --ss -p -r
[
{
"netid": "nl",
"state": "UNCONN",
"recv_q": "0",
"send_q": "0",
"peer_address": "*",
"channel": "rtnl:kernel"
- `"netid"` - "nl",
- `"state"` - "UNCONN",
- `"recv_q"` - "0",
- `"send_q"` - "0",
- `"peer_address"` - "*",
- `"channel"` - "rtnl:kernel"
},
{
"netid": "nl",
"state": "UNCONN",
"recv_q": "0",
"send_q": "0",
"peer_address": "*",
"pid": "893",
"channel": "rtnl:systemd-resolve"
- `"netid"` - "nl",
- `"state"` - "UNCONN",
- `"recv_q"` - "0",
- `"send_q"` - "0",
- `"peer_address"` - "*",
- `"pid"` - "893",
- `"channel"` - "rtnl:systemd-resolve"
},
...
{
"netid": "p_raw",
"state": "UNCONN",
"recv_q": "0",
"send_q": "0",
"peer_address": "*",
"link_layer": "LLDP",
"interface": "ens33"
- `"netid"` - "p_raw",
- `"state"` - "UNCONN",
- `"recv_q"` - "0",
- `"send_q"` - "0",
- `"peer_address"` - "*",
- `"link_layer"` - "LLDP",
- `"interface"` - "ens33"
},
{
"netid": "u_dgr",
"state": "UNCONN",
"recv_q": "0",
"send_q": "0",
"local_port": "93066",
"peer_address": "*",
"peer_port": "0",
"path": "/run/user/1000/systemd/notify"
- `"netid"` - "u_dgr",
- `"state"` - "UNCONN",
- `"recv_q"` - "0",
- `"send_q"` - "0",
- `"local_port"` - "93066",
- `"peer_address"` - "*",
- `"peer_port"` - "0",
- `"path"` - "/run/user/1000/systemd/notify"
},
{
"netid": "u_seq",
"state": "LISTEN",
"recv_q": "0",
"send_q": "128",
"local_port": "20699",
"peer_address": "*",
"peer_port": "0",
"path": "/run/udev/control"
- `"netid"` - "u_seq",
- `"state"` - "LISTEN",
- `"recv_q"` - "0",
- `"send_q"` - "128",
- `"local_port"` - "20699",
- `"peer_address"` - "*",
- `"peer_port"` - "0",
- `"path"` - "/run/udev/control"
},
...
{
"netid": "icmp6",
"state": "UNCONN",
"recv_q": "0",
"send_q": "0",
"local_address": "*",
"local_port": "ipv6-icmp",
"peer_address": "*",
"peer_port": "*",
"interface": "ens33"
- `"netid"` - "icmp6",
- `"state"` - "UNCONN",
- `"recv_q"` - "0",
- `"send_q"` - "0",
- `"local_address"` - "*",
- `"local_port"` - "ipv6-icmp",
- `"peer_address"` - "*",
- `"peer_port"` - "*",
- `"interface"` - "ens33"
},
{
"netid": "udp",
"state": "UNCONN",
"recv_q": "0",
"send_q": "0",
"local_address": "127.0.0.53",
"local_port": "domain",
"peer_address": "0.0.0.0",
"peer_port": "*",
"interface": "lo"
- `"netid"` - "udp",
- `"state"` - "UNCONN",
- `"recv_q"` - "0",
- `"send_q"` - "0",
- `"local_address"` - "127.0.0.53",
- `"local_port"` - "domain",
- `"peer_address"` - "0.0.0.0",
- `"peer_port"` - "*",
- `"interface"` - "lo"
},
{
"netid": "tcp",
"state": "LISTEN",
"recv_q": "0",
"send_q": "128",
"local_address": "127.0.0.53",
"local_port": "domain",
"peer_address": "0.0.0.0",
"peer_port": "*",
"interface": "lo"
- `"netid"` - "tcp",
- `"state"` - "LISTEN",
- `"recv_q"` - "0",
- `"send_q"` - "128",
- `"local_address"` - "127.0.0.53",
- `"local_port"` - "domain",
- `"peer_address"` - "0.0.0.0",
- `"peer_port"` - "*",
- `"interface"` - "lo"
},
{
"netid": "tcp",
"state": "LISTEN",
"recv_q": "0",
"send_q": "128",
"local_address": "0.0.0.0",
"local_port": "ssh",
"peer_address": "0.0.0.0",
"peer_port": "*"
- `"netid"` - "tcp",
- `"state"` - "LISTEN",
- `"recv_q"` - "0",
- `"send_q"` - "128",
- `"local_address"` - "0.0.0.0",
- `"local_port"` - "ssh",
- `"peer_address"` - "0.0.0.0",
- `"peer_port"` - "*"
},
{
"netid": "tcp",
"state": "LISTEN",
"recv_q": "0",
"send_q": "128",
"local_address": "[::]",
"local_port": "ssh",
"peer_address": "[::]",
"peer_port": "*"
- `"netid"` - "tcp",
- `"state"` - "LISTEN",
- `"recv_q"` - "0",
- `"send_q"` - "128",
- `"local_address"` - "[::]",
- `"local_port"` - "ssh",
- `"peer_address"` - "[::]",
- `"peer_port"` - "*"
},
{
"netid": "v_str",
"state": "ESTAB",
"recv_q": "0",
"send_q": "0",
"local_address": "999900439",
"local_port": "1023",
"peer_address": "0",
"peer_port": "976"
- `"netid"` - "v_str",
- `"state"` - "ESTAB",
- `"recv_q"` - "0",
- `"send_q"` - "0",
- `"local_address"` - "999900439",
- `"local_port"` - "1023",
- `"peer_address"` - "0",
- `"peer_port"` - "976"
}
]
<a id="jc.parsers.ss.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ss.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.stat"></a>
# 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
@ -65,65 +67,66 @@ Schema:
}
]
Examples:
**Examples**:
$ stat /bin/* | jc --stat -p
[
{
"file": "/bin/bash",
"size": 1113504,
"blocks": 2176,
"io_blocks": 4096,
"type": "regular file",
"device": "802h/2050d",
"inode": 131099,
"links": 1,
"access": "0755",
"flags": "-rwxr-xr-x",
"uid": 0,
"user": "root",
"gid": 0,
"group": "root",
"access_time": "2019-11-14 08:18:03.509681766 +0000",
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
"change_time": "2019-08-12 17:21:29.521945390 +0000",
"birth_time": null,
"access_time_epoch": 1573748283,
"access_time_epoch_utc": 1573719483,
"modify_time_epoch": 1559885295,
"modify_time_epoch_utc": 1559860095,
"change_time_epoch": 1565655689,
"change_time_epoch_utc": 1565630489,
"birth_time_epoch": null,
"birth_time_epoch_utc": null
- `"file"` - "/bin/bash",
- `"size"` - 1113504,
- `"blocks"` - 2176,
- `"io_blocks"` - 4096,
- `"type"` - "regular file",
- `"device"` - "802h/2050d",
- `"inode"` - 131099,
- `"links"` - 1,
- `"access"` - "0755",
- `"flags"` - "-rwxr-xr-x",
- `"uid"` - 0,
- `"user"` - "root",
- `"gid"` - 0,
- `"group"` - "root",
- `"access_time"` - "2019-11-14 08:18:03.509681766 +0000",
- `"modify_time"` - "2019-06-06 22:28:15.000000000 +0000",
- `"change_time"` - "2019-08-12 17:21:29.521945390 +0000",
- `"birth_time"` - null,
- `"access_time_epoch"` - 1573748283,
- `"access_time_epoch_utc"` - 1573719483,
- `"modify_time_epoch"` - 1559885295,
- `"modify_time_epoch_utc"` - 1559860095,
- `"change_time_epoch"` - 1565655689,
- `"change_time_epoch_utc"` - 1565630489,
- `"birth_time_epoch"` - null,
- `"birth_time_epoch_utc"` - null
},
{
"file": "/bin/btrfs",
"size": 716464,
"blocks": 1400,
"io_blocks": 4096,
"type": "regular file",
"device": "802h/2050d",
"inode": 131100,
"links": 1,
"access": "0755",
"flags": "-rwxr-xr-x",
"uid": 0,
"user": "root",
"gid": 0,
"group": "root",
"access_time": "2019-11-14 08:18:28.990834276 +0000",
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
"change_time": "2019-08-12 17:21:29.545944399 +0000",
"birth_time": null,
"access_time_epoch": 1573748308,
"access_time_epoch_utc": 1573719508,
"modify_time_epoch": 1520921067,
"modify_time_epoch_utc": 1520895867,
"change_time_epoch": 1565655689,
"change_time_epoch_utc": 1565630489,
"birth_time_epoch": null,
"birth_time_epoch_utc": null
- `"file"` - "/bin/btrfs",
- `"size"` - 716464,
- `"blocks"` - 1400,
- `"io_blocks"` - 4096,
- `"type"` - "regular file",
- `"device"` - "802h/2050d",
- `"inode"` - 131100,
- `"links"` - 1,
- `"access"` - "0755",
- `"flags"` - "-rwxr-xr-x",
- `"uid"` - 0,
- `"user"` - "root",
- `"gid"` - 0,
- `"group"` - "root",
- `"access_time"` - "2019-11-14 08:18:28.990834276 +0000",
- `"modify_time"` - "2018-03-12 23:04:27.000000000 +0000",
- `"change_time"` - "2019-08-12 17:21:29.545944399 +0000",
- `"birth_time"` - null,
- `"access_time_epoch"` - 1573748308,
- `"access_time_epoch_utc"` - 1573719508,
- `"modify_time_epoch"` - 1520921067,
- `"modify_time_epoch_utc"` - 1520895867,
- `"change_time_epoch"` - 1565655689,
- `"change_time_epoch_utc"` - 1565630489,
- `"birth_time_epoch"` - null,
- `"birth_time_epoch_utc"` - null
},
...
]
@ -131,69 +134,78 @@ Examples:
$ stat /bin/* | jc --stat -p -r
[
{
"file": "/bin/bash",
"size": "1113504",
"blocks": "2176",
"io_blocks": "4096",
"type": "regular file",
"device": "802h/2050d",
"inode": "131099",
"links": "1",
"access": "0755",
"flags": "-rwxr-xr-x",
"uid": "0",
"user": "root",
"gid": "0",
"group": "root",
"access_time": "2019-11-14 08:18:03.509681766 +0000",
"modify_time": "2019-06-06 22:28:15.000000000 +0000",
"change_time": "2019-08-12 17:21:29.521945390 +0000",
"birth_time": null
- `"file"` - "/bin/bash",
- `"size"` - "1113504",
- `"blocks"` - "2176",
- `"io_blocks"` - "4096",
- `"type"` - "regular file",
- `"device"` - "802h/2050d",
- `"inode"` - "131099",
- `"links"` - "1",
- `"access"` - "0755",
- `"flags"` - "-rwxr-xr-x",
- `"uid"` - "0",
- `"user"` - "root",
- `"gid"` - "0",
- `"group"` - "root",
- `"access_time"` - "2019-11-14 08:18:03.509681766 +0000",
- `"modify_time"` - "2019-06-06 22:28:15.000000000 +0000",
- `"change_time"` - "2019-08-12 17:21:29.521945390 +0000",
- `"birth_time"` - null
},
{
"file": "/bin/btrfs",
"size": "716464",
"blocks": "1400",
"io_blocks": "4096",
"type": "regular file",
"device": "802h/2050d",
"inode": "131100",
"links": "1",
"access": "0755",
"flags": "-rwxr-xr-x",
"uid": "0",
"user": "root",
"gid": "0",
"group": "root",
"access_time": "2019-11-14 08:18:28.990834276 +0000",
"modify_time": "2018-03-12 23:04:27.000000000 +0000",
"change_time": "2019-08-12 17:21:29.545944399 +0000",
"birth_time": null
- `"file"` - "/bin/btrfs",
- `"size"` - "716464",
- `"blocks"` - "1400",
- `"io_blocks"` - "4096",
- `"type"` - "regular file",
- `"device"` - "802h/2050d",
- `"inode"` - "131100",
- `"links"` - "1",
- `"access"` - "0755",
- `"flags"` - "-rwxr-xr-x",
- `"uid"` - "0",
- `"user"` - "root",
- `"gid"` - "0",
- `"group"` - "root",
- `"access_time"` - "2019-11-14 08:18:28.990834276 +0000",
- `"modify_time"` - "2018-03-12 23:04:27.000000000 +0000",
- `"change_time"` - "2019-08-12 17:21:29.545944399 +0000",
- `"birth_time"` - null
},
...
]
<a id="jc.parsers.stat.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.stat.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.stat_s"></a>
# jc.parsers.stat\_s
# jc.parsers.stat_s
jc - JSON CLI output utility `stat` command output streaming parser
> This streaming parser outputs JSON Lines
@ -76,7 +78,8 @@ Schema:
}
}
Examples:
**Examples**:
$ stat | jc --stat-s
{"file":"(stdin)","unix_device":1027739696,"inode":1155,"flags":"cr...}
@ -84,34 +87,45 @@ Examples:
$ stat | jc --stat-s -r
{"file":"(stdin)","unix_device":"1027739696","inode":"1155","flag...}
<a id="jc.parsers.stat_s.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.stat_s.parse"></a>
#### 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.
Parameters:
**Arguments**:
data: (iterable) line-based text data to parse
- `data` - (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
**Yields**:
Yields:
Dictionary. Raw or processed structured data.
Returns:
**Returns**:
Iterator object

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.sysctl"></a>
# 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
@ -34,53 +36,63 @@ Schema:
"key3": string/integer/float
}
Examples:
**Examples**:
$ sysctl -a | jc --sysctl -p
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": 99,
"user.bc_dim_max": 2048,
"user.bc_scale_max": 99,
"user.bc_string_max": 1000,
"user.coll_weights_max": 2,
"user.expr_nest_max": 32
- `"user.cs_path"` - "/usr/bin:/bin:/usr/sbin:/sbin",
- `"user.bc_base_max"` - 99,
- `"user.bc_dim_max"` - 2048,
- `"user.bc_scale_max"` - 99,
- `"user.bc_string_max"` - 1000,
- `"user.coll_weights_max"` - 2,
- `"user.expr_nest_max"` - 32
...
}
$ sysctl -a | jc --sysctl -p -r
{
"user.cs_path": "/usr/bin:/bin:/usr/sbin:/sbin",
"user.bc_base_max": "99",
"user.bc_dim_max": "2048",
"user.bc_scale_max": "99",
"user.bc_string_max": "1000",
"user.coll_weights_max": "2",
"user.expr_nest_max": "32",
- `"user.cs_path"` - "/usr/bin:/bin:/usr/sbin:/sbin",
- `"user.bc_base_max"` - "99",
- `"user.bc_dim_max"` - "2048",
- `"user.bc_scale_max"` - "99",
- `"user.bc_string_max"` - "1000",
- `"user.coll_weights_max"` - "2",
- `"user.expr_nest_max"` - "32",
...
}
<a id="jc.parsers.sysctl.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.sysctl.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.systemctl"></a>
# jc.parsers.systemctl
jc - JSON CLI output utility `systemctl` command output parser
Usage (cli):
@ -33,55 +35,65 @@ Schema:
}
]
Examples:
**Examples**:
$ systemctl -a | jc --systemctl -p
[
{
"unit": "proc-sys-fs-binfmt_misc.automount",
"load": "loaded",
"active": "active",
"sub": "waiting",
"description": "Arbitrary Executable File Formats File System ..."
- `"unit"` - "proc-sys-fs-binfmt_misc.automount",
- `"load"` - "loaded",
- `"active"` - "active",
- `"sub"` - "waiting",
- `"description"` - "Arbitrary Executable File Formats File System ..."
},
{
"unit": "dev-block-8:2.device",
"load": "loaded",
"active": "active",
"sub": "plugged",
"description": "LVM PV 3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM o..."
- `"unit"` - "dev-block-8:2.device",
- `"load"` - "loaded",
- `"active"` - "active",
- `"sub"` - "plugged",
- `"description"` - "LVM PV 3klkIj-w1qk-DkJi-0XBJ-y3o7-i2Ac-vHqWBM o..."
},
{
"unit": "dev-cdrom.device",
"load": "loaded",
"active": "active",
"sub": "plugged",
"description": "VMware_Virtual_IDE_CDROM_Drive"
- `"unit"` - "dev-cdrom.device",
- `"load"` - "loaded",
- `"active"` - "active",
- `"sub"` - "plugged",
- `"description"` - "VMware_Virtual_IDE_CDROM_Drive"
},
...
]
<a id="jc.parsers.systemctl.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.systemctl.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.systemctl_lj"></a>
# jc.parsers.systemctl\_lj
# jc.parsers.systemctl_lj
jc - JSON CLI output utility `systemctl list-jobs` command output parser
Usage (cli):
@ -32,73 +34,83 @@ Schema:
}
]
Examples:
**Examples**:
$ systemctl list-jobs| jc --systemctl-lj -p
[
{
"job": 3543,
"unit": "nginxAfterGlusterfs.service",
"type": "start",
"state": "waiting"
- `"job"` - 3543,
- `"unit"` - "nginxAfterGlusterfs.service",
- `"type"` - "start",
- `"state"` - "waiting"
},
{
"job": 3545,
"unit": "glusterReadyForLocalhostMount.service",
"type": "start",
"state": "running"
- `"job"` - 3545,
- `"unit"` - "glusterReadyForLocalhostMount.service",
- `"type"` - "start",
- `"state"` - "running"
},
{
"job": 3506,
"unit": "nginx.service",
"type": "start",
"state": "waiting"
- `"job"` - 3506,
- `"unit"` - "nginx.service",
- `"type"` - "start",
- `"state"` - "waiting"
}
]
$ systemctl list-jobs| jc --systemctl-lj -p -r
[
{
"job": "3543",
"unit": "nginxAfterGlusterfs.service",
"type": "start",
"state": "waiting"
- `"job"` - "3543",
- `"unit"` - "nginxAfterGlusterfs.service",
- `"type"` - "start",
- `"state"` - "waiting"
},
{
"job": "3545",
"unit": "glusterReadyForLocalhostMount.service",
"type": "start",
"state": "running"
- `"job"` - "3545",
- `"unit"` - "glusterReadyForLocalhostMount.service",
- `"type"` - "start",
- `"state"` - "running"
},
{
"job": "3506",
"unit": "nginx.service",
"type": "start",
"state": "waiting"
- `"job"` - "3506",
- `"unit"` - "nginx.service",
- `"type"` - "start",
- `"state"` - "waiting"
}
]
<a id="jc.parsers.systemctl_lj.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.systemctl_lj.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.systemctl_ls"></a>
# jc.parsers.systemctl\_ls
# jc.parsers.systemctl_ls
jc - JSON CLI output utility `systemctl list-sockets` command output
parser
@ -32,49 +34,59 @@ Schema:
}
]
Examples:
**Examples**:
$ systemctl list-sockets | jc --systemctl-ls -p
[
{
"listen": "/dev/log",
"unit": "systemd-journald.socket",
"activates": "systemd-journald.service"
- `"listen"` - "/dev/log",
- `"unit"` - "systemd-journald.socket",
- `"activates"` - "systemd-journald.service"
},
{
"listen": "/run/dbus/system_bus_socket",
"unit": "dbus.socket",
"activates": "dbus.service"
- `"listen"` - "/run/dbus/system_bus_socket",
- `"unit"` - "dbus.socket",
- `"activates"` - "dbus.service"
},
{
"listen": "/run/dmeventd-client",
"unit": "dm-event.socket",
"activates": "dm-event.service"
- `"listen"` - "/run/dmeventd-client",
- `"unit"` - "dm-event.socket",
- `"activates"` - "dm-event.service"
},
...
]
<a id="jc.parsers.systemctl_ls.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.systemctl_ls.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.systemctl_luf"></a>
# jc.parsers.systemctl\_luf
# jc.parsers.systemctl_luf
jc - JSON CLI output utility `systemctl list-unit-files` command output
parser
@ -31,46 +33,56 @@ Schema:
}
]
Examples:
**Examples**:
$ systemctl list-unit-files | jc --systemctl-luf -p
[
{
"unit_file": "proc-sys-fs-binfmt_misc.automount",
"state": "static"
- `"unit_file"` - "proc-sys-fs-binfmt_misc.automount",
- `"state"` - "static"
},
{
"unit_file": "dev-hugepages.mount",
"state": "static"
- `"unit_file"` - "dev-hugepages.mount",
- `"state"` - "static"
},
{
"unit_file": "dev-mqueue.mount",
"state": "static"
- `"unit_file"` - "dev-mqueue.mount",
- `"state"` - "static"
},
...
]
<a id="jc.parsers.systemctl_luf.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.systemctl_luf.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.systeminfo"></a>
# jc.parsers.systeminfo
jc - JSON CLI output utility `systeminfo` command output parser
Blank or missing elements are set to `null`.
@ -92,149 +94,159 @@ Schema:
[0] naive timestamp
[1] timezone-aware timestamp
Examples:
**Examples**:
$ systeminfo | jc --systeminfo -p
{
"host_name": "TESTLAPTOP",
"os_name": "Microsoft Windows 10 Enterprise",
"os_version": "10.0.17134 N/A Build 17134",
"os_manufacturer": "Microsoft Corporation",
"os_configuration": "Member Workstation",
"os_build_type": "Multiprocessor Free",
"registered_owner": "Test, Inc.",
"registered_organization": "Test, Inc.",
"product_id": "11111-11111-11111-AA111",
"original_install_date": "3/26/2019, 3:51:30 PM",
"system_boot_time": "3/30/2021, 6:13:59 AM",
"system_manufacturer": "Dell Inc.",
"system_model": "Precision 5530",
"system_type": "x64-based PC",
"processors": [
- `"host_name"` - "TESTLAPTOP",
- `"os_name"` - "Microsoft Windows 10 Enterprise",
- `"os_version"` - "10.0.17134 N/A Build 17134",
- `"os_manufacturer"` - "Microsoft Corporation",
- `"os_configuration"` - "Member Workstation",
- `"os_build_type"` - "Multiprocessor Free",
- `"registered_owner"` - "Test, Inc.",
- `"registered_organization"` - "Test, Inc.",
- `"product_id"` - "11111-11111-11111-AA111",
- `"original_install_date"` - "3/26/2019, 3:51:30 PM",
- `"system_boot_time"` - "3/30/2021, 6:13:59 AM",
- `"system_manufacturer"` - "Dell Inc.",
- `"system_model"` - "Precision 5530",
- `"system_type"` - "x64-based PC",
- `"processors"` - [
"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",
"system_locale": "en-us;English (United States)",
"input_locale": "en-us;English (United States)",
"time_zone": "(UTC+00:00) UTC",
"total_physical_memory_mb": 32503,
"available_physical_memory_mb": 19743,
"virtual_memory_max_size_mb": 37367,
"virtual_memory_available_mb": 22266,
"virtual_memory_in_use_mb": 15101,
"page_file_locations": "C:\pagefile.sys",
"domain": "test.com",
"logon_server": "\\TESTDC01",
"hotfixs": [
- `"bios_version"` - "Dell Inc. 1.16.2, 4/21/2020",
- `"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",
- `"total_physical_memory_mb"` - 32503,
- `"available_physical_memory_mb"` - 19743,
- `"virtual_memory_max_size_mb"` - 37367,
- `"virtual_memory_available_mb"` - 22266,
- `"virtual_memory_in_use_mb"` - 15101,
- `"page_file_locations"` - "C:\\pagefile.sys",
- `"domain"` - "test.com",
- `"logon_server"` - "\\\\TESTDC01",
- `"hotfixs"` - [
"KB2693643",
"KB4601054"
],
"network_cards": [
- `"network_cards"` - [
{
"name": "Intel(R) Wireless-AC 9260 160MHz",
"connection_name": "Wi-Fi",
"status": null,
"dhcp_enabled": true,
"dhcp_server": "192.168.2.1",
"ip_addresses": [
- `"name"` - "Intel(R) Wireless-AC 9260 160MHz",
- `"connection_name"` - "Wi-Fi",
- `"status"` - null,
- `"dhcp_enabled"` - true,
- `"dhcp_server"` - "192.168.2.1",
- `"ip_addresses"` - [
"192.168.2.219"
]
}
],
"hyperv_requirements": {
"vm_monitor_mode_extensions": true,
"virtualization_enabled_in_firmware": true,
"second_level_address_translation": false,
"data_execution_prevention_available": true
- `"hyperv_requirements"` - {
- `"vm_monitor_mode_extensions"` - true,
- `"virtualization_enabled_in_firmware"` - true,
- `"second_level_address_translation"` - false,
- `"data_execution_prevention_available"` - true
},
"original_install_date_epoch": 1553640690,
"original_install_date_epoch_utc": 1553615490,
"system_boot_time_epoch": 1617110039,
"system_boot_time_epoch_utc": 1617084839
- `"original_install_date_epoch"` - 1553640690,
- `"original_install_date_epoch_utc"` - 1553615490,
- `"system_boot_time_epoch"` - 1617110039,
- `"system_boot_time_epoch_utc"` - 1617084839
}
$ systeminfo | jc --systeminfo -p -r
{
"host_name": "TESTLAPTOP",
"os_name": "Microsoft Windows 10 Enterprise",
"os_version": "10.0.17134 N/A Build 17134",
"os_manufacturer": "Microsoft Corporation",
"os_configuration": "Member Workstation",
"os_build_type": "Multiprocessor Free",
"registered_owner": "Test, Inc.",
"registered_organization": "Test, Inc.",
"product_id": "11111-11111-11111-AA111",
"original_install_date": "3/26/2019, 3:51:30 PM",
"system_boot_time": "3/30/2021, 6:13:59 AM",
"system_manufacturer": "Dell Inc.",
"system_model": "Precision 5530",
"system_type": "x64-based PC",
"processors": [
- `"host_name"` - "TESTLAPTOP",
- `"os_name"` - "Microsoft Windows 10 Enterprise",
- `"os_version"` - "10.0.17134 N/A Build 17134",
- `"os_manufacturer"` - "Microsoft Corporation",
- `"os_configuration"` - "Member Workstation",
- `"os_build_type"` - "Multiprocessor Free",
- `"registered_owner"` - "Test, Inc.",
- `"registered_organization"` - "Test, Inc.",
- `"product_id"` - "11111-11111-11111-AA111",
- `"original_install_date"` - "3/26/2019, 3:51:30 PM",
- `"system_boot_time"` - "3/30/2021, 6:13:59 AM",
- `"system_manufacturer"` - "Dell Inc.",
- `"system_model"` - "Precision 5530",
- `"system_type"` - "x64-based PC",
- `"processors"` - [
"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",
"system_locale": "en-us;English (United States)",
"input_locale": "en-us;English (United States)",
"time_zone": "(UTC+00:00) UTC",
"total_physical_memory_mb": "32,503 MB",
"available_physical_memory_mb": "19,743 MB",
"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",
"domain": "test.com",
"logon_server": "\\TESTDC01",
"hotfixs": [
- `"bios_version"` - "Dell Inc. 1.16.2, 4/21/2020",
- `"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",
- `"total_physical_memory_mb"` - "32,503 MB",
- `"available_physical_memory_mb"` - "19,743 MB",
- `"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",
- `"domain"` - "test.com",
- `"logon_server"` - "\\\\TESTDC01",
- `"hotfixs"` - [
"KB2693643",
"KB4601054"
],
"network_cards": [
- `"network_cards"` - [
{
"name": "Intel(R) Wireless-AC 9260 160MHz",
"connection_name": "Wi-Fi",
"status": "",
"dhcp_enabled": "Yes",
"dhcp_server": "192.168.2.1",
"ip_addresses": [
- `"name"` - "Intel(R) Wireless-AC 9260 160MHz",
- `"connection_name"` - "Wi-Fi",
- `"status"` - "",
- `"dhcp_enabled"` - "Yes",
- `"dhcp_server"` - "192.168.2.1",
- `"ip_addresses"` - [
"192.168.2.219"
]
}
],
"hyperv_requirements": {
"vm_monitor_mode_extensions": "Yes",
"virtualization_enabled_in_firmware": "Yes",
"second_level_address_translation": "No",
"data_execution_prevention_available": "Yes"
- `"hyperv_requirements"` - {
- `"vm_monitor_mode_extensions"` - "Yes",
- `"virtualization_enabled_in_firmware"` - "Yes",
- `"second_level_address_translation"` - "No",
- `"data_execution_prevention_available"` - "Yes"
}
}
<a id="jc.parsers.systeminfo.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.systeminfo.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.time"></a>
# 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):
@ -72,90 +74,100 @@ Schema:
[0] aka File system inputs
[1] aka File system outputs
Examples:
**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",
"user_time": 0.0,
"system_time": 0.0,
"cpu_percent": 0,
"elapsed_time": "0:02.00",
"average_shared_text_size": 0,
"average_unshared_data_size": 0,
"average_stack_size": 0,
"average_total_size": 0,
"maximum_resident_set_size": 2084,
"average_resident_set_size": 0,
"major_pagefaults": 0,
"minor_pagefaults": 72,
"voluntary_context_switches": 2,
"involuntary_context_switches": 1,
"swaps": 0,
"block_input_operations": 0,
"block_output_operations": 0,
"messages_sent": 0,
"messages_received": 0,
"signals_delivered": 0,
"page_size": 4096,
"exit_status": 0,
"elapsed_time_hours": 0,
"elapsed_time_minutes": 0,
"elapsed_time_seconds": 2,
"elapsed_time_centiseconds": 50,
"elapsed_time_total_seconds": 2.5
- `"command_being_timed"` - "sleep 2",
- `"user_time"` - 0.0,
- `"system_time"` - 0.0,
- `"cpu_percent"` - 0,
- `"elapsed_time"` - "0:02.00",
- `"average_shared_text_size"` - 0,
- `"average_unshared_data_size"` - 0,
- `"average_stack_size"` - 0,
- `"average_total_size"` - 0,
- `"maximum_resident_set_size"` - 2084,
- `"average_resident_set_size"` - 0,
- `"major_pagefaults"` - 0,
- `"minor_pagefaults"` - 72,
- `"voluntary_context_switches"` - 2,
- `"involuntary_context_switches"` - 1,
- `"swaps"` - 0,
- `"block_input_operations"` - 0,
- `"block_output_operations"` - 0,
- `"messages_sent"` - 0,
- `"messages_received"` - 0,
- `"signals_delivered"` - 0,
- `"page_size"` - 4096,
- `"exit_status"` - 0,
- `"elapsed_time_hours"` - 0,
- `"elapsed_time_minutes"` - 0,
- `"elapsed_time_seconds"` - 2,
- `"elapsed_time_centiseconds"` - 50,
- `"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"",
"user_time": "0.00",
"system_time": "0.00",
"cpu_percent": "0",
"elapsed_time": "0:02.00",
"average_shared_text_size": "0",
"average_unshared_data_size": "0",
"average_stack_size": "0",
"average_total_size": "0",
"maximum_resident_set_size": "2084",
"average_resident_set_size": "0",
"major_pagefaults": "0",
"minor_pagefaults": "72",
"voluntary_context_switches": "2",
"involuntary_context_switches": "0",
"swaps": "0",
"block_input_operations": "0",
"block_output_operations": "0",
"messages_sent": "0",
"messages_received": "0",
"signals_delivered": "0",
"page_size": "4096",
"exit_status": "0"
- `"command_being_timed"` - "\"sleep 2\"",
- `"user_time"` - "0.00",
- `"system_time"` - "0.00",
- `"cpu_percent"` - "0",
- `"elapsed_time"` - "0:02.00",
- `"average_shared_text_size"` - "0",
- `"average_unshared_data_size"` - "0",
- `"average_stack_size"` - "0",
- `"average_total_size"` - "0",
- `"maximum_resident_set_size"` - "2084",
- `"average_resident_set_size"` - "0",
- `"major_pagefaults"` - "0",
- `"minor_pagefaults"` - "72",
- `"voluntary_context_switches"` - "2",
- `"involuntary_context_switches"` - "0",
- `"swaps"` - "0",
- `"block_input_operations"` - "0",
- `"block_output_operations"` - "0",
- `"messages_sent"` - "0",
- `"messages_received"` - "0",
- `"signals_delivered"` - "0",
- `"page_size"` - "4096",
- `"exit_status"` - "0"
}
<a id="jc.parsers.time.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.time.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.timedatectl"></a>
# jc.parsers.timedatectl
jc - JSON CLI output utility `timedatectl` command output parser
The `epoch_utc` calculated timestamp field is timezone-aware and is only
@ -40,54 +42,64 @@ Schema:
"dst_active": boolean
}
Examples:
**Examples**:
$ timedatectl | jc --timedatectl -p
{
"local_time": "Tue 2020-03-10 17:53:21 PDT",
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
"rtc_time": "Wed 2020-03-11 00:53:21",
"time_zone": "America/Los_Angeles (PDT, -0700)",
"ntp_enabled": true,
"ntp_synchronized": true,
"rtc_in_local_tz": false,
"dst_active": true,
"epoch_utc": 1583888001
- `"local_time"` - "Tue 2020-03-10 17:53:21 PDT",
- `"universal_time"` - "Wed 2020-03-11 00:53:21 UTC",
- `"rtc_time"` - "Wed 2020-03-11 00:53:21",
- `"time_zone"` - "America/Los_Angeles (PDT, -0700)",
- `"ntp_enabled"` - true,
- `"ntp_synchronized"` - true,
- `"rtc_in_local_tz"` - false,
- `"dst_active"` - true,
- `"epoch_utc"` - 1583888001
}
$ timedatectl | jc --timedatectl -p -r
{
"local_time": "Tue 2020-03-10 17:53:21 PDT",
"universal_time": "Wed 2020-03-11 00:53:21 UTC",
"rtc_time": "Wed 2020-03-11 00:53:21",
"time_zone": "America/Los_Angeles (PDT, -0700)",
"ntp_enabled": "yes",
"ntp_synchronized": "yes",
"rtc_in_local_tz": "no",
"dst_active": "yes"
- `"local_time"` - "Tue 2020-03-10 17:53:21 PDT",
- `"universal_time"` - "Wed 2020-03-11 00:53:21 UTC",
- `"rtc_time"` - "Wed 2020-03-11 00:53:21",
- `"time_zone"` - "America/Los_Angeles (PDT, -0700)",
- `"ntp_enabled"` - "yes",
- `"ntp_synchronized"` - "yes",
- `"rtc_in_local_tz"` - "no",
- `"dst_active"` - "yes"
}
<a id="jc.parsers.timedatectl.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.timedatectl.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.tracepath"></a>
# jc.parsers.tracepath
jc - JSON CLI output utility `tracepath` command output parser
Supports `tracepath` and `tracepath6` output.
@ -42,119 +44,129 @@ Schema:
]
}
Examples:
**Examples**:
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p
{
"pmtu": 1480,
"forward_hops": 2,
"return_hops": 2,
"hops": [
- `"pmtu"` - 1480,
- `"forward_hops"` - 2,
- `"return_hops"` - 2,
- `"hops"` - [
{
"ttl": 1,
"guess": true,
"host": "[LOCALHOST]",
"reply_ms": null,
"pmtu": 1500,
"asymmetric_difference": null,
"reached": false
- `"ttl"` - 1,
- `"guess"` - true,
- `"host"` - "[LOCALHOST]",
- `"reply_ms"` - null,
- `"pmtu"` - 1500,
- `"asymmetric_difference"` - null,
- `"reached"` - false
},
{
"ttl": 1,
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": 0.411,
"pmtu": null,
"asymmetric_difference": null,
"reached": false
- `"ttl"` - 1,
- `"guess"` - false,
- `"host"` - "dust.inr.ac.ru",
- `"reply_ms"` - 0.411,
- `"pmtu"` - null,
- `"asymmetric_difference"` - null,
- `"reached"` - false
},
{
"ttl": 2,
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": 0.39,
"pmtu": 1480,
"asymmetric_difference": 1,
"reached": false
- `"ttl"` - 2,
- `"guess"` - false,
- `"host"` - "dust.inr.ac.ru",
- `"reply_ms"` - 0.39,
- `"pmtu"` - 1480,
- `"asymmetric_difference"` - 1,
- `"reached"` - false
},
{
"ttl": 2,
"guess": false,
"host": "3ffe:2400:0:109::2",
"reply_ms": 463.514,
"pmtu": null,
"asymmetric_difference": null,
"reached": true
- `"ttl"` - 2,
- `"guess"` - false,
- `"host"` - "3ffe:2400:0:109::2",
- `"reply_ms"` - 463.514,
- `"pmtu"` - null,
- `"asymmetric_difference"` - null,
- `"reached"` - true
}
]
}
$ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p -r
{
"pmtu": "1480",
"forward_hops": "2",
"return_hops": "2",
"hops": [
- `"pmtu"` - "1480",
- `"forward_hops"` - "2",
- `"return_hops"` - "2",
- `"hops"` - [
{
"ttl": "1",
"guess": true,
"host": "[LOCALHOST]",
"reply_ms": null,
"pmtu": "1500",
"asymmetric_difference": null,
"reached": false
- `"ttl"` - "1",
- `"guess"` - true,
- `"host"` - "[LOCALHOST]",
- `"reply_ms"` - null,
- `"pmtu"` - "1500",
- `"asymmetric_difference"` - null,
- `"reached"` - false
},
{
"ttl": "1",
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": "0.411",
"pmtu": null,
"asymmetric_difference": null,
"reached": false
- `"ttl"` - "1",
- `"guess"` - false,
- `"host"` - "dust.inr.ac.ru",
- `"reply_ms"` - "0.411",
- `"pmtu"` - null,
- `"asymmetric_difference"` - null,
- `"reached"` - false
},
{
"ttl": "2",
"guess": false,
"host": "dust.inr.ac.ru",
"reply_ms": "0.390",
"pmtu": "1480",
"asymmetric_difference": "1",
"reached": false
- `"ttl"` - "2",
- `"guess"` - false,
- `"host"` - "dust.inr.ac.ru",
- `"reply_ms"` - "0.390",
- `"pmtu"` - "1480",
- `"asymmetric_difference"` - "1",
- `"reached"` - false
},
{
"ttl": "2",
"guess": false,
"host": "3ffe:2400:0:109::2",
"reply_ms": "463.514",
"pmtu": null,
"asymmetric_difference": null,
"reached": true
- `"ttl"` - "2",
- `"guess"` - false,
- `"host"` - "3ffe:2400:0:109::2",
- `"reply_ms"` - "463.514",
- `"pmtu"` - null,
- `"asymmetric_difference"` - null,
- `"reached"` - true
}
]
}
<a id="jc.parsers.tracepath.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.tracepath.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.traceroute"></a>
# jc.parsers.traceroute
jc - JSON CLI output utility `traceroute` command output parser
Supports `traceroute` and `traceroute6` output.
@ -51,36 +53,37 @@ Schema:
]
}
Examples:
**Examples**:
$ traceroute google.com | jc --traceroute -p
{
"destination_ip": "216.58.194.46",
"destination_name": "google.com",
"hops": [
- `"destination_ip"` - "216.58.194.46",
- `"destination_name"` - "google.com",
- `"hops"` - [
{
"hop": 1,
"probes": [
- `"hop"` - 1,
- `"probes"` - [
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": 198.574
- `"annotation"` - null,
- `"asn"` - null,
- `"ip"` - "216.230.231.141",
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
- `"rtt"` - 198.574
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": null
- `"annotation"` - null,
- `"asn"` - null,
- `"ip"` - "216.230.231.141",
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
- `"rtt"` - null
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": 198.65
- `"annotation"` - null,
- `"asn"` - null,
- `"ip"` - "216.230.231.141",
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
- `"rtt"` - 198.65
}
]
},
@ -90,32 +93,32 @@ Examples:
$ traceroute google.com | jc --traceroute -p -r
{
"destination_ip": "216.58.194.46",
"destination_name": "google.com",
"hops": [
- `"destination_ip"` - "216.58.194.46",
- `"destination_name"` - "google.com",
- `"hops"` - [
{
"hop": "1",
"probes": [
- `"hop"` - "1",
- `"probes"` - [
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": "198.574"
- `"annotation"` - null,
- `"asn"` - null,
- `"ip"` - "216.230.231.141",
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
- `"rtt"` - "198.574"
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": null
- `"annotation"` - null,
- `"asn"` - null,
- `"ip"` - "216.230.231.141",
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
- `"rtt"` - null
},
{
"annotation": null,
"asn": null,
"ip": "216.230.231.141",
"name": "216-230-231-141.static.houston.tx.oplink.net",
"rtt": "198.650"
- `"annotation"` - null,
- `"asn"` - null,
- `"ip"` - "216.230.231.141",
- `"name"` - "216-230-231-141.static.houston.tx.oplink.net",
- `"rtt"` - "198.650"
}
]
},
@ -123,27 +126,84 @@ Examples:
]
}
<a id="jc.parsers.traceroute.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.traceroute.__version__"></a>
#### \_\_version\_\_
Copyright (C) 2015 Luis Benitez
Parses the output of a traceroute execution into an AST (Abstract Syntax Tree).
The MIT License (MIT)
Copyright (c) 2014 Luis Benitez
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
<a id="jc.parsers.traceroute._Hop"></a>
## \_Hop Objects
```python
parse(data, raw=False, quiet=False)
class _Hop(object)
```
<a id="jc.parsers.traceroute._Hop.add_probe"></a>
#### add\_probe
```python
def add_probe(probe)
```
Adds a Probe instance to this hop's results.
<a id="jc.parsers.traceroute.parse"></a>
#### parse
```python
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ufw"></a>
# jc.parsers.ufw
jc - JSON CLI output utility `ufw status` command output parser
Usage (cli):
@ -71,68 +73,69 @@ Schema:
[0] null if any 'to' ports or port_ranges are set
[1] null if any 'from' ports or port_ranges are set
Examples:
**Examples**:
$ ufw status verbose | jc --ufw -p
{
"status": "active",
"logging": "on",
"logging_level": "low",
"default": "deny (incoming), allow (outgoing), disabled (routed)",
"new_profiles": "skip",
"rules": [
- `"status"` - "active",
- `"logging"` - "on",
- `"logging_level"` - "low",
- `"default"` - "deny (incoming), allow (outgoing), disabled (routed)",
- `"new_profiles"` - "skip",
- `"rules"` - [
{
"action": "ALLOW",
"action_direction": "IN",
"index": null,
"network_protocol": "ipv4",
"to_interface": "any",
"to_transport": "any",
"to_service": null,
"to_ports": [
- `"action"` - "ALLOW",
- `"action_direction"` - "IN",
- `"index"` - null,
- `"network_protocol"` - "ipv4",
- `"to_interface"` - "any",
- `"to_transport"` - "any",
- `"to_service"` - null,
- `"to_ports"` - [
22
],
"to_ip": "0.0.0.0",
"to_ip_prefix": 0,
"comment": null,
"from_ip": "0.0.0.0",
"from_ip_prefix": 0,
"from_interface": "any",
"from_transport": "any",
"from_port_ranges": [
- `"to_ip"` - "0.0.0.0",
- `"to_ip_prefix"` - 0,
- `"comment"` - null,
- `"from_ip"` - "0.0.0.0",
- `"from_ip_prefix"` - 0,
- `"from_interface"` - "any",
- `"from_transport"` - "any",
- `"from_port_ranges"` - [
{
"start": 0,
"end": 65535
- `"start"` - 0,
- `"end"` - 65535
}
],
"from_service": null
- `"from_service"` - null
},
{
"action": "ALLOW",
"action_direction": "IN",
"index": null,
"network_protocol": "ipv4",
"to_interface": "any",
"to_transport": "tcp",
"to_service": null,
"to_ports": [
- `"action"` - "ALLOW",
- `"action_direction"` - "IN",
- `"index"` - null,
- `"network_protocol"` - "ipv4",
- `"to_interface"` - "any",
- `"to_transport"` - "tcp",
- `"to_service"` - null,
- `"to_ports"` - [
80,
443
],
"to_ip": "0.0.0.0",
"to_ip_prefix": 0,
"comment": null,
"from_ip": "0.0.0.0",
"from_ip_prefix": 0,
"from_interface": "any",
"from_transport": "any",
"from_port_ranges": [
- `"to_ip"` - "0.0.0.0",
- `"to_ip_prefix"` - 0,
- `"comment"` - null,
- `"from_ip"` - "0.0.0.0",
- `"from_ip_prefix"` - 0,
- `"from_interface"` - "any",
- `"from_transport"` - "any",
- `"from_port_ranges"` - [
{
"start": 0,
"end": 65535
- `"start"` - 0,
- `"end"` - 65535
}
],
"from_service": null
- `"from_service"` - null
},
...
]
@ -140,90 +143,99 @@ Examples:
$ ufw status verbose | jc --ufw -p -r
{
"status": "active",
"logging": "on",
"logging_level": "low",
"default": "deny (incoming), allow (outgoing), disabled (routed)",
"new_profiles": "skip",
"rules": [
- `"status"` - "active",
- `"logging"` - "on",
- `"logging_level"` - "low",
- `"default"` - "deny (incoming), allow (outgoing), disabled (routed)",
- `"new_profiles"` - "skip",
- `"rules"` - [
{
"action": "ALLOW",
"action_direction": "IN",
"index": null,
"network_protocol": "ipv4",
"to_interface": "any",
"to_transport": "any",
"to_service": null,
"to_ports": [
- `"action"` - "ALLOW",
- `"action_direction"` - "IN",
- `"index"` - null,
- `"network_protocol"` - "ipv4",
- `"to_interface"` - "any",
- `"to_transport"` - "any",
- `"to_service"` - null,
- `"to_ports"` - [
"22"
],
"to_ip": "0.0.0.0",
"to_ip_prefix": "0",
"comment": null,
"from_ip": "0.0.0.0",
"from_ip_prefix": "0",
"from_interface": "any",
"from_transport": "any",
"from_port_ranges": [
- `"to_ip"` - "0.0.0.0",
- `"to_ip_prefix"` - "0",
- `"comment"` - null,
- `"from_ip"` - "0.0.0.0",
- `"from_ip_prefix"` - "0",
- `"from_interface"` - "any",
- `"from_transport"` - "any",
- `"from_port_ranges"` - [
{
"start": "0",
"end": "65535"
- `"start"` - "0",
- `"end"` - "65535"
}
],
"from_service": null
- `"from_service"` - null
},
{
"action": "ALLOW",
"action_direction": "IN",
"index": null,
"network_protocol": "ipv4",
"to_interface": "any",
"to_transport": "tcp",
"to_service": null,
"to_ports": [
- `"action"` - "ALLOW",
- `"action_direction"` - "IN",
- `"index"` - null,
- `"network_protocol"` - "ipv4",
- `"to_interface"` - "any",
- `"to_transport"` - "tcp",
- `"to_service"` - null,
- `"to_ports"` - [
"80",
"443"
],
"to_ip": "0.0.0.0",
"to_ip_prefix": "0",
"comment": null,
"from_ip": "0.0.0.0",
"from_ip_prefix": "0",
"from_interface": "any",
"from_transport": "any",
"from_port_ranges": [
- `"to_ip"` - "0.0.0.0",
- `"to_ip_prefix"` - "0",
- `"comment"` - null,
- `"from_ip"` - "0.0.0.0",
- `"from_ip_prefix"` - "0",
- `"from_interface"` - "any",
- `"from_transport"` - "any",
- `"from_port_ranges"` - [
{
"start": "0",
"end": "65535"
- `"start"` - "0",
- `"end"` - "65535"
}
],
"from_service": null
- `"from_service"` - null
},
...
]
}
<a id="jc.parsers.ufw.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ufw.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.ufw_appinfo"></a>
# jc.parsers.ufw\_appinfo
# jc.parsers.ufw_appinfo
jc - JSON CLI output utility `ufw app info [application]` command
output parser
@ -79,39 +81,40 @@ Schema:
[1] duplicates and overlapping are removed
[2] overlapping are merged
Examples:
**Examples**:
$ ufw app info MSN | jc --ufw-appinfo -p
[
{
"profile": "MSN",
"title": "MSN Chat",
"description": "MSN chat protocol (with file transfer and voice)",
"tcp_list": [
- `"profile"` - "MSN",
- `"title"` - "MSN Chat",
- `"description"` - "MSN chat protocol (with file transfer and voice)",
- `"tcp_list"` - [
1863,
6901
],
"udp_list": [
- `"udp_list"` - [
1863,
6901
],
"tcp_ranges": [
- `"tcp_ranges"` - [
{
"start": 6891,
"end": 6900
- `"start"` - 6891,
- `"end"` - 6900
}
],
"normalized_tcp_list": [
- `"normalized_tcp_list"` - [
1863,
6901
],
"normalized_tcp_ranges": [
- `"normalized_tcp_ranges"` - [
{
"start": 6891,
"end": 6900
- `"start"` - 6891,
- `"end"` - 6900
}
],
"normalized_udp_list": [
- `"normalized_udp_list"` - [
1863,
6901
]
@ -121,47 +124,56 @@ Examples:
$ ufw app info MSN | jc --ufw-appinfo -p -r
[
{
"profile": "MSN",
"title": "MSN Chat",
"description": "MSN chat protocol (with file transfer and voice)",
"tcp_list": [
- `"profile"` - "MSN",
- `"title"` - "MSN Chat",
- `"description"` - "MSN chat protocol (with file transfer and voice)",
- `"tcp_list"` - [
"1863",
"6901"
],
"udp_list": [
- `"udp_list"` - [
"1863",
"6901"
],
"tcp_ranges": [
- `"tcp_ranges"` - [
{
"start": "6891",
"end": "6900"
- `"start"` - "6891",
- `"end"` - "6900"
}
]
}
]
<a id="jc.parsers.ufw_appinfo.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.ufw_appinfo.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.uname"></a>
# jc.parsers.uname
jc - JSON CLI output utility `uname -a` command output parser
Note: Must use `uname -a`
@ -36,41 +38,51 @@ Schema:
"kernel_version": string
}
Example:
**Example**:
$ uname -a | jc --uname -p
{
"kernel_name": "Linux",
"node_name": "user-ubuntu",
"kernel_release": "4.15.0-65-generic",
"operating_system": "GNU/Linux",
"hardware_platform": "x86_64",
"processor": "x86_64",
"machine": "x86_64",
"kernel_version": "#74-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
- `"kernel_name"` - "Linux",
- `"node_name"` - "user-ubuntu",
- `"kernel_release"` - "4.15.0-65-generic",
- `"operating_system"` - "GNU/Linux",
- `"hardware_platform"` - "x86_64",
- `"processor"` - "x86_64",
- `"machine"` - "x86_64",
- `"kernel_version"` - "`74`-Ubuntu SMP Tue Sep 17 17:06:04 UTC 2019"
}
<a id="jc.parsers.uname.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.uname.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,17 +1,23 @@
<a id="jc.parsers.universal"></a>
# jc.parsers.universal
jc - JSON CLI output utility universal Parsers
## simple_table_parse
<a id="jc.parsers.universal.simple_table_parse"></a>
#### simple\_table\_parse
```python
simple_table_parse(data)
def simple_table_parse(data)
```
Parse simple tables. The last column may contain data with spaces.
Parameters:
**Arguments**:
data: (list) Text data to parse that has been split into lines
- `data` - (list) Text data to parse that has been split into lines
via .splitlines(). Item 0 must be the header row.
Any spaces in header names should be changed to
underscore '_'. You should also ensure headers are
@ -20,21 +26,26 @@ Parameters:
Also, ensure there are no blank lines (list items)
in the data.
Returns:
**Returns**:
List of Dictionaries
<a id="jc.parsers.universal.sparse_table_parse"></a>
#### sparse\_table\_parse
## sparse_table_parse
```python
sparse_table_parse(data, delim='\u2063')
def sparse_table_parse(data, delim='\u2063')
```
Parse tables with missing column data or with spaces in column data.
Parameters:
**Arguments**:
data: (list) Text data to parse that has been split into lines
- `data` - (list) Text data to parse that has been split into lines
via .splitlines(). Item 0 must be the header row.
Any spaces in header names should be changed to
underscore '_'. You should also ensure headers are
@ -45,13 +56,15 @@ 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
delimiter conflict with your data.
Returns:
**Returns**:
List of Dictionaries

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.upower"></a>
# 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
@ -91,137 +93,147 @@ Schema:
[0] null if date-time conversion fails
Examples:
**Examples**:
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p
[
{
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
"vendor": "NOTEBOOK",
"model": "BAT",
"serial": "0001",
"power_supply": true,
"updated": "Thu 11 Mar 2021 06:28:08 PM UTC",
"has_history": true,
"has_statistics": true,
"detail": {
"type": "battery",
"present": true,
"rechargeable": true,
"state": "charging",
"energy": 22.3998,
"energy_empty": 0.0,
"energy_full": 52.6473,
"energy_full_design": 62.16,
"energy_rate": 31.6905,
"voltage": 12.191,
"time_to_full": 57.3,
"percentage": 42.5469,
"capacity": 84.6964,
"technology": "lithium-ion",
"energy_unit": "Wh",
"energy_empty_unit": "Wh",
"energy_full_unit": "Wh",
"energy_full_design_unit": "Wh",
"energy_rate_unit": "W",
"voltage_unit": "V",
"time_to_full_unit": "minutes"
- `"native_path"` - "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
- `"vendor"` - "NOTEBOOK",
- `"model"` - "BAT",
- `"serial"` - "0001",
- `"power_supply"` - true,
- `"updated"` - "Thu 11 Mar 2021 06:28:08 PM UTC",
- `"has_history"` - true,
- `"has_statistics"` - true,
- `"detail"` - {
- `"type"` - "battery",
- `"present"` - true,
- `"rechargeable"` - true,
- `"state"` - "charging",
- `"energy"` - 22.3998,
- `"energy_empty"` - 0.0,
- `"energy_full"` - 52.6473,
- `"energy_full_design"` - 62.16,
- `"energy_rate"` - 31.6905,
- `"voltage"` - 12.191,
- `"time_to_full"` - 57.3,
- `"percentage"` - 42.5469,
- `"capacity"` - 84.6964,
- `"technology"` - "lithium-ion",
- `"energy_unit"` - "Wh",
- `"energy_empty_unit"` - "Wh",
- `"energy_full_unit"` - "Wh",
- `"energy_full_design_unit"` - "Wh",
- `"energy_rate_unit"` - "W",
- `"voltage_unit"` - "V",
- `"time_to_full_unit"` - "minutes"
},
"history_charge": [
- `"history_charge"` - [
{
"time": 1328809335,
"percent_charged": 42.547,
"status": "charging"
- `"time"` - 1328809335,
- `"percent_charged"` - 42.547,
- `"status"` - "charging"
},
{
"time": 1328809305,
"percent_charged": 42.02,
"status": "charging"
- `"time"` - 1328809305,
- `"percent_charged"` - 42.02,
- `"status"` - "charging"
}
],
"history_rate": [
- `"history_rate"` - [
{
"time": 1328809335,
"percent_charged": 31.691,
"status": "charging"
- `"time"` - 1328809335,
- `"percent_charged"` - 31.691,
- `"status"` - "charging"
}
],
"updated_seconds_ago": 441975,
"updated_epoch": 1615516088,
"updated_epoch_utc": 1615487288
- `"updated_seconds_ago"` - 441975,
- `"updated_epoch"` - 1615516088,
- `"updated_epoch_utc"` - 1615487288
}
]
$ upower -i /org/freedesktop/UPower/devices/battery | jc --upower -p -r
[
{
"native_path": "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
"vendor": "NOTEBOOK",
"model": "BAT",
"serial": "0001",
"power_supply": "yes",
"updated": "Thu 11 Mar 2021 06:28:08 PM UTC (441975 seconds ago)",
"has_history": "yes",
"has_statistics": "yes",
"detail": {
"type": "battery",
"present": "yes",
"rechargeable": "yes",
"state": "charging",
"energy": "22.3998 Wh",
"energy_empty": "0 Wh",
"energy_full": "52.6473 Wh",
"energy_full_design": "62.16 Wh",
"energy_rate": "31.6905 W",
"voltage": "12.191 V",
"time_to_full": "57.3 minutes",
"percentage": "42.5469%",
"capacity": "84.6964%",
"technology": "lithium-ion"
- `"native_path"` - "/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/p...",
- `"vendor"` - "NOTEBOOK",
- `"model"` - "BAT",
- `"serial"` - "0001",
- `"power_supply"` - "yes",
- `"updated"` - "Thu 11 Mar 2021 06:28:08 PM UTC (441975 seconds ago)",
- `"has_history"` - "yes",
- `"has_statistics"` - "yes",
- `"detail"` - {
- `"type"` - "battery",
- `"present"` - "yes",
- `"rechargeable"` - "yes",
- `"state"` - "charging",
- `"energy"` - "22.3998 Wh",
- `"energy_empty"` - "0 Wh",
- `"energy_full"` - "52.6473 Wh",
- `"energy_full_design"` - "62.16 Wh",
- `"energy_rate"` - "31.6905 W",
- `"voltage"` - "12.191 V",
- `"time_to_full"` - "57.3 minutes",
- `"percentage"` - "42.5469%",
- `"capacity"` - "84.6964%",
- `"technology"` - "lithium-ion"
},
"history_charge": [
- `"history_charge"` - [
{
"time": "1328809335",
"percent_charged": "42.547",
"status": "charging"
- `"time"` - "1328809335",
- `"percent_charged"` - "42.547",
- `"status"` - "charging"
},
{
"time": "1328809305",
"percent_charged": "42.020",
"status": "charging"
- `"time"` - "1328809305",
- `"percent_charged"` - "42.020",
- `"status"` - "charging"
}
],
"history_rate": [
- `"history_rate"` - [
{
"time": "1328809335",
"percent_charged": "31.691",
"status": "charging"
- `"time"` - "1328809335",
- `"percent_charged"` - "31.691",
- `"status"` - "charging"
}
]
}
]
<a id="jc.parsers.upower.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.upower.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.uptime"></a>
# jc.parsers.uptime
jc - JSON CLI output utility `uptime` command output parser
Usage (cli):
@ -39,56 +41,66 @@ Schema:
"load_15m": float
}
Example:
**Example**:
$ uptime | jc --uptime -p
{
"time": "11:35",
"uptime": "3 days, 4:03",
"users": 5,
"load_1m": 1.88,
"load_5m": 2.0,
"load_15m": 1.94,
"time_hour": 11,
"time_minute": 35,
"time_second": null,
"uptime_days": 3,
"uptime_hours": 4,
"uptime_minutes": 3,
"uptime_total_seconds": 273780
- `"time"` - "11:35",
- `"uptime"` - "3 days, 4:03",
- `"users"` - 5,
- `"load_1m"` - 1.88,
- `"load_5m"` - 2.0,
- `"load_15m"` - 1.94,
- `"time_hour"` - 11,
- `"time_minute"` - 35,
- `"time_second"` - null,
- `"uptime_days"` - 3,
- `"uptime_hours"` - 4,
- `"uptime_minutes"` - 3,
- `"uptime_total_seconds"` - 273780
}
$ uptime | jc --uptime -p -r
{
"time": "11:36",
"uptime": "3 days, 4:04",
"users": "5",
"load_1m": "1.88",
"load_5m": "1.99",
"load_15m": "1.94"
- `"time"` - "11:36",
- `"uptime"` - "3 days, 4:04",
- `"users"` - "5",
- `"load_1m"` - "1.88",
- `"load_5m"` - "1.99",
- `"load_15m"` - "1.94"
}
<a id="jc.parsers.uptime.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.uptime.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.vmstat"></a>
# jc.parsers.vmstat
jc - JSON CLI output utility `vmstat` command output parser
Options supported: `-a`, `-w`, `-d`, `-t`
@ -73,83 +75,93 @@ Schema:
[0] naive timestamp if -t flag is used
[1] aware timestamp if -t flag is used and UTC TZ
Examples:
**Examples**:
$ vmstat | jc --vmstat -p
[
{
"runnable_procs": 2,
"uninterruptible_sleeping_procs": 0,
"virtual_mem_used": 0,
"free_mem": 2794468,
"buffer_mem": 2108,
"cache_mem": 741208,
"inactive_mem": null,
"active_mem": null,
"swap_in": 0,
"swap_out": 0,
"blocks_in": 1,
"blocks_out": 3,
"interrupts": 29,
"context_switches": 57,
"user_time": 0,
"system_time": 0,
"idle_time": 99,
"io_wait_time": 0,
"stolen_time": 0,
"timestamp": null,
"timezone": null
- `"runnable_procs"` - 2,
- `"uninterruptible_sleeping_procs"` - 0,
- `"virtual_mem_used"` - 0,
- `"free_mem"` - 2794468,
- `"buffer_mem"` - 2108,
- `"cache_mem"` - 741208,
- `"inactive_mem"` - null,
- `"active_mem"` - null,
- `"swap_in"` - 0,
- `"swap_out"` - 0,
- `"blocks_in"` - 1,
- `"blocks_out"` - 3,
- `"interrupts"` - 29,
- `"context_switches"` - 57,
- `"user_time"` - 0,
- `"system_time"` - 0,
- `"idle_time"` - 99,
- `"io_wait_time"` - 0,
- `"stolen_time"` - 0,
- `"timestamp"` - null,
- `"timezone"` - null
}
]
$ vmstat | jc --vmstat -p -r
[
{
"runnable_procs": "2",
"uninterruptible_sleeping_procs": "0",
"virtual_mem_used": "0",
"free_mem": "2794468",
"buffer_mem": "2108",
"cache_mem": "741208",
"inactive_mem": null,
"active_mem": null,
"swap_in": "0",
"swap_out": "0",
"blocks_in": "1",
"blocks_out": "3",
"interrupts": "29",
"context_switches": "57",
"user_time": "0",
"system_time": "0",
"idle_time": "99",
"io_wait_time": "0",
"stolen_time": "0",
"timestamp": null,
"timezone": null
- `"runnable_procs"` - "2",
- `"uninterruptible_sleeping_procs"` - "0",
- `"virtual_mem_used"` - "0",
- `"free_mem"` - "2794468",
- `"buffer_mem"` - "2108",
- `"cache_mem"` - "741208",
- `"inactive_mem"` - null,
- `"active_mem"` - null,
- `"swap_in"` - "0",
- `"swap_out"` - "0",
- `"blocks_in"` - "1",
- `"blocks_out"` - "3",
- `"interrupts"` - "29",
- `"context_switches"` - "57",
- `"user_time"` - "0",
- `"system_time"` - "0",
- `"idle_time"` - "99",
- `"io_wait_time"` - "0",
- `"stolen_time"` - "0",
- `"timestamp"` - null,
- `"timezone"` - null
}
]
<a id="jc.parsers.vmstat.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.vmstat.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.vmstat_s"></a>
# jc.parsers.vmstat\_s
# jc.parsers.vmstat_s
jc - JSON CLI output utility `vmstat` command output streaming parser
> This streaming parser outputs JSON Lines
@ -93,7 +95,8 @@ Schema:
[2] false if error parsing
[3] exists if "success" is false
Examples:
**Examples**:
$ vmstat | jc --vmstat-s
{"runnable_procs":2,"uninterruptible_sleeping_procs":0,"virtual_mem...}
@ -103,34 +106,45 @@ Examples:
{"runnable_procs":"2","uninterruptible_sleeping_procs":"0","virtua...}
...
<a id="jc.parsers.vmstat_s.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.vmstat_s.parse"></a>
#### 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.
Parameters:
**Arguments**:
data: (iterable) line-based text data to parse
- `data` - (iterable) line-based text data to parse
(e.g. sys.stdin or str.splitlines())
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
ignore_exceptions: (boolean) ignore parsing exceptions if True
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
- `ignore_exceptions` - (boolean) ignore parsing exceptions if True
**Yields**:
Yields:
Dictionary. Raw or processed structured data.
Returns:
**Returns**:
Iterator object

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.w"></a>
# jc.parsers.w
jc - JSON CLI output utility `w` command output parser
Usage (cli):
@ -36,97 +38,107 @@ Schema:
}
]
Examples:
**Examples**:
$ w | jc --w -p
[
{
"user": "root",
"tty": "tty1",
"from": null,
"login_at": "07:49",
"idle": "1:15m",
"jcpu": "0.00s",
"pcpu": "0.00s",
"what": "-bash"
- `"user"` - "root",
- `"tty"` - "tty1",
- `"from"` - null,
- `"login_at"` - "07:49",
- `"idle"` - "1:15m",
- `"jcpu"` - "0.00s",
- `"pcpu"` - "0.00s",
- `"what"` - "-bash"
},
{
"user": "root",
"tty": "ttyS0",
"from": null,
"login_at": "06:24",
"idle": "0.00s",
"jcpu": "0.43s",
"pcpu": "0.00s",
"what": "w"
- `"user"` - "root",
- `"tty"` - "ttyS0",
- `"from"` - null,
- `"login_at"` - "06:24",
- `"idle"` - "0.00s",
- `"jcpu"` - "0.43s",
- `"pcpu"` - "0.00s",
- `"what"` - "w"
},
{
"user": "root",
"tty": "pts/0",
"from": "192.168.71.1",
"login_at": "06:29",
"idle": "2:35m",
"jcpu": "0.00s",
"pcpu": "0.00s",
"what": "-bash"
- `"user"` - "root",
- `"tty"` - "pts/0",
- `"from"` - "192.168.71.1",
- `"login_at"` - "06:29",
- `"idle"` - "2:35m",
- `"jcpu"` - "0.00s",
- `"pcpu"` - "0.00s",
- `"what"` - "-bash"
}
]
$ w | jc --w -p -r
[
{
"user": "kbrazil",
"tty": "tty1",
"from": "-",
"login_at": "07:49",
"idle": "1:16m",
"jcpu": "0.00s",
"pcpu": "0.00s",
"what": "-bash"
- `"user"` - "kbrazil",
- `"tty"` - "tty1",
- `"from"` - "-",
- `"login_at"` - "07:49",
- `"idle"` - "1:16m",
- `"jcpu"` - "0.00s",
- `"pcpu"` - "0.00s",
- `"what"` - "-bash"
},
{
"user": "kbrazil",
"tty": "ttyS0",
"from": "-",
"login_at": "06:24",
"idle": "2.00s",
"jcpu": "0.46s",
"pcpu": "0.00s",
"what": "w"
- `"user"` - "kbrazil",
- `"tty"` - "ttyS0",
- `"from"` - "-",
- `"login_at"` - "06:24",
- `"idle"` - "2.00s",
- `"jcpu"` - "0.46s",
- `"pcpu"` - "0.00s",
- `"what"` - "w"
},
{
"user": "kbrazil",
"tty": "pts/0",
"from": "192.168.71.1",
"login_at": "06:29",
"idle": "2:36m",
"jcpu": "0.00s",
"pcpu": "0.00s",
"what": "-bash"
- `"user"` - "kbrazil",
- `"tty"` - "pts/0",
- `"from"` - "192.168.71.1",
- `"login_at"` - "06:29",
- `"idle"` - "2:36m",
- `"jcpu"` - "0.00s",
- `"pcpu"` - "0.00s",
- `"what"` - "-bash"
}
]
<a id="jc.parsers.w.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.w.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.wc"></a>
# jc.parsers.wc
jc - JSON CLI output utility `wc` command output parser
Usage (cli):
@ -32,52 +34,62 @@ Schema:
}
]
Examples:
**Examples**:
$ wc * | jc --wc -p
[
{
"filename": "airport-I.json",
"lines": 1,
"words": 30,
"characters": 307
- `"filename"` - "airport-I.json",
- `"lines"` - 1,
- `"words"` - 30,
- `"characters"` - 307
},
{
"filename": "airport-I.out",
"lines": 15,
"words": 33,
"characters": 348
- `"filename"` - "airport-I.out",
- `"lines"` - 15,
- `"words"` - 33,
- `"characters"` - 348
},
{
"filename": "airport-s.json",
"lines": 1,
"words": 202,
"characters": 2152
- `"filename"` - "airport-s.json",
- `"lines"` - 1,
- `"words"` - 202,
- `"characters"` - 2152
},
...
]
<a id="jc.parsers.wc.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.wc.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.who"></a>
# jc.parsers.who
jc - JSON CLI output utility `who` command output parser
Accepts any of the following who options (or no options): `-aTH`
@ -45,120 +47,130 @@ Schema:
[0] naive timestamp. null if time cannot be converted
Examples:
**Examples**:
$ who -a | jc --who -p
[
{
"event": "reboot",
"time": "Feb 7 23:31",
"pid": 1,
"epoch": null
- `"event"` - "reboot",
- `"time"` - "Feb 7 23:31",
- `"pid"` - 1,
- `"epoch"` - null
},
{
"user": "joeuser",
"writeable_tty": "-",
"tty": "console",
"time": "Feb 7 23:32",
"idle": "old",
"pid": 105,
"epoch": null
- `"user"` - "joeuser",
- `"writeable_tty"` - "-",
- `"tty"` - "console",
- `"time"` - "Feb 7 23:32",
- `"idle"` - "old",
- `"pid"` - 105,
- `"epoch"` - null
},
{
"user": "joeuser",
"writeable_tty": "+",
"tty": "ttys000",
"time": "Feb 13 16:44",
"idle": ".",
"pid": 51217,
"comment": "term=0 exit=0",
"epoch": null
- `"user"` - "joeuser",
- `"writeable_tty"` - "+",
- `"tty"` - "ttys000",
- `"time"` - "Feb 13 16:44",
- `"idle"` - ".",
- `"pid"` - 51217,
- `"comment"` - "term=0 exit=0",
- `"epoch"` - null
},
{
"user": "joeuser",
"writeable_tty": "?",
"tty": "ttys003",
"time": "Feb 28 08:59",
"idle": "01:36",
"pid": 41402,
"epoch": null
- `"user"` - "joeuser",
- `"writeable_tty"` - "?",
- `"tty"` - "ttys003",
- `"time"` - "Feb 28 08:59",
- `"idle"` - "01:36",
- `"pid"` - 41402,
- `"epoch"` - null
},
{
"user": "joeuser",
"writeable_tty": "+",
"tty": "ttys004",
"time": "Mar 1 16:35",
"idle": ".",
"pid": 15679,
"from": "192.168.1.5",
"epoch": null
- `"user"` - "joeuser",
- `"writeable_tty"` - "+",
- `"tty"` - "ttys004",
- `"time"` - "Mar 1 16:35",
- `"idle"` - ".",
- `"pid"` - 15679,
- `"from"` - "192.168.1.5",
- `"epoch"` - null
}
]
$ who -a | jc --who -p -r
[
{
"event": "reboot",
"time": "Feb 7 23:31",
"pid": "1"
- `"event"` - "reboot",
- `"time"` - "Feb 7 23:31",
- `"pid"` - "1"
},
{
"user": "joeuser",
"writeable_tty": "-",
"tty": "console",
"time": "Feb 7 23:32",
"idle": "old",
"pid": "105"
- `"user"` - "joeuser",
- `"writeable_tty"` - "-",
- `"tty"` - "console",
- `"time"` - "Feb 7 23:32",
- `"idle"` - "old",
- `"pid"` - "105"
},
{
"user": "joeuser",
"writeable_tty": "+",
"tty": "ttys000",
"time": "Feb 13 16:44",
"idle": ".",
"pid": "51217",
"comment": "term=0 exit=0"
- `"user"` - "joeuser",
- `"writeable_tty"` - "+",
- `"tty"` - "ttys000",
- `"time"` - "Feb 13 16:44",
- `"idle"` - ".",
- `"pid"` - "51217",
- `"comment"` - "term=0 exit=0"
},
{
"user": "joeuser",
"writeable_tty": "?",
"tty": "ttys003",
"time": "Feb 28 08:59",
"idle": "01:36",
"pid": "41402"
- `"user"` - "joeuser",
- `"writeable_tty"` - "?",
- `"tty"` - "ttys003",
- `"time"` - "Feb 28 08:59",
- `"idle"` - "01:36",
- `"pid"` - "41402"
},
{
"user": "joeuser",
"writeable_tty": "+",
"tty": "ttys004",
"time": "Mar 1 16:35",
"idle": ".",
"pid": "15679",
"from": "192.168.1.5"
- `"user"` - "joeuser",
- `"writeable_tty"` - "+",
- `"tty"` - "ttys004",
- `"time"` - "Mar 1 16:35",
- `"idle"` - ".",
- `"pid"` - "15679",
- `"from"` - "192.168.1.5"
}
]
<a id="jc.parsers.who.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.who.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.xml"></a>
# jc.parsers.xml
jc - JSON CLI output utility `XML` file parser
Usage (cli):
@ -27,7 +29,8 @@ Schema:
"key2": string/object
}
Examples:
**Examples**:
$ cat cd_catalog.xml
<?xml version="1.0" encoding="UTF-8"?>
@ -52,48 +55,57 @@ Examples:
$ cat cd_catalog.xml | jc --xml -p
{
"CATALOG": {
"CD": [
- `"CATALOG"` - {
- `"CD"` - [
{
"TITLE": "Empire Burlesque",
"ARTIST": "Bob Dylan",
"COUNTRY": "USA",
"COMPANY": "Columbia",
"PRICE": "10.90",
"YEAR": "1985"
- `"TITLE"` - "Empire Burlesque",
- `"ARTIST"` - "Bob Dylan",
- `"COUNTRY"` - "USA",
- `"COMPANY"` - "Columbia",
- `"PRICE"` - "10.90",
- `"YEAR"` - "1985"
},
{
"TITLE": "Hide your heart",
"ARTIST": "Bonnie Tyler",
"COUNTRY": "UK",
"COMPANY": "CBS Records",
"PRICE": "9.90",
"YEAR": "1988"
- `"TITLE"` - "Hide your heart",
- `"ARTIST"` - "Bonnie Tyler",
- `"COUNTRY"` - "UK",
- `"COMPANY"` - "CBS Records",
- `"PRICE"` - "9.90",
- `"YEAR"` - "1988"
},
...
}
<a id="jc.parsers.xml.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.xml.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
Dictionary. Raw or processed structured data.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.yaml"></a>
# jc.parsers.yaml
jc - JSON CLI output utility `YAML` file parser
Usage (cli):
@ -29,85 +31,95 @@ Schema:
}
]
Examples:
**Examples**:
$ cat istio-mtls-permissive.yaml
apiVersion: "authentication.istio.io/v1alpha1"
kind: "Policy"
- `apiVersion` - "authentication.istio.io/v1alpha1"
- `kind` - "Policy"
metadata:
name: "default"
namespace: "default"
- `name` - "default"
- `namespace` - "default"
spec:
peers:
- mtls: {}
---
apiVersion: "networking.istio.io/v1alpha3"
kind: "DestinationRule"
- `apiVersion` - "networking.istio.io/v1alpha3"
- `kind` - "DestinationRule"
metadata:
name: "default"
namespace: "default"
- `name` - "default"
- `namespace` - "default"
spec:
host: "*.default.svc.cluster.local"
- `host` - "*.default.svc.cluster.local"
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
- `mode` - ISTIO_MUTUAL
$ cat istio-mtls-permissive.yaml | jc --yaml -p
[
{
"apiVersion": "authentication.istio.io/v1alpha1",
"kind": "Policy",
"metadata": {
"name": "default",
"namespace": "default"
- `"apiVersion"` - "authentication.istio.io/v1alpha1",
- `"kind"` - "Policy",
- `"metadata"` - {
- `"name"` - "default",
- `"namespace"` - "default"
},
"spec": {
"peers": [
- `"spec"` - {
- `"peers"` - [
{
"mtls": {}
- `"mtls"` - {}
}
]
}
},
{
"apiVersion": "networking.istio.io/v1alpha3",
"kind": "DestinationRule",
"metadata": {
"name": "default",
"namespace": "default"
- `"apiVersion"` - "networking.istio.io/v1alpha3",
- `"kind"` - "DestinationRule",
- `"metadata"` - {
- `"name"` - "default",
- `"namespace"` - "default"
},
"spec": {
"host": "*.default.svc.cluster.local",
"trafficPolicy": {
"tls": {
"mode": "ISTIO_MUTUAL"
- `"spec"` - {
- `"host"` - "*.default.svc.cluster.local",
- `"trafficPolicy"` - {
- `"tls"` - {
- `"mode"` - "ISTIO_MUTUAL"
}
}
}
}
]
<a id="jc.parsers.yaml.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.yaml.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries representing the YAML documents.

View File

@ -1,6 +1,8 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.zipinfo"></a>
# jc.parsers.zipinfo
jc - JSON CLI output utility `zipinfo` command output parser
Options supported:
@ -54,55 +56,65 @@ Schema:
}
]
Examples:
**Examples**:
$ zipinfo log4j-core-2.16.0.jar | jc --zipinfo -p
[
{
"archive": "log4j-core-2.16.0.jar",
"size": 1789565,
"size_unit": "bytes",
"number_entries": 1218,
"number_files": 1218,
"bytes_uncompressed": 3974141,
"bytes_compressed": 1515455,
"percent_compressed": 61.9,
"files": [
- `"archive"` - "log4j-core-2.16.0.jar",
- `"size"` - 1789565,
- `"size_unit"` - "bytes",
- `"number_entries"` - 1218,
- `"number_files"` - 1218,
- `"bytes_uncompressed"` - 3974141,
- `"bytes_compressed"` - 1515455,
- `"percent_compressed"` - 61.9,
- `"files"` - [
{
"flags": "-rw-r--r--",
"zipversion": "2.0",
"zipunder": "unx",
"filesize": 19810,
"type": "bl",
"method": "defN",
"date": "21-Dec-12",
"time": "23:35",
"filename": "META-INF/MANIFEST.MF"
- `"flags"` - "-rw-r--r--",
- `"zipversion"` - "2.0",
- `"zipunder"` - "unx",
- `"filesize"` - 19810,
- `"type"` - "bl",
- `"method"` - "defN",
- `"date"` - "21-Dec-12",
- `"time"` - "23:35",
- `"filename"` - "META-INF/MANIFEST.MF"
},
...
<a id="jc.parsers.zipinfo.info"></a>
## info Objects
## info
```python
info()
class info()
```
Provides parser metadata (version, author, etc.)
## parse
<a id="jc.parsers.zipinfo.parse"></a>
#### parse
```python
parse(data, raw=False, quiet=False)
def parse(data, raw=False, quiet=False)
```
Main text parsing function
Parameters:
**Arguments**:
data: (string) text data to parse
raw: (boolean) unprocessed output if True
quiet: (boolean) suppress warning messages if True
Returns:
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
**Returns**:
List of Dictionaries. Raw or processed structured data.

View File

@ -1,5 +1,7 @@
<a id="jc"></a>
# jc
JC - JSON CLI output utility
* kellyjonbrazil@gmail.com

View File

@ -1,183 +1,244 @@
<a id="jc.utils"></a>
# jc.utils
# utils
jc - JSON CLI output utility utils
## warning_message
<a id="jc.utils.warning_message"></a>
#### warning\_message
```python
warning_message(message_lines)
def warning_message(message_lines)
```
Prints warning message for non-fatal issues. The first line is
prepended with 'jc: Warning - ' and subsequent lines are indented.
Wraps text as needed based on the terminal width.
Parameters:
**Arguments**:
message: (list) list of string lines
Returns:
- `message` - (list) list of string lines
**Returns**:
None - just prints output to STDERR
<a id="jc.utils.error_message"></a>
#### error\_message
## error_message
```python
error_message(message_lines)
def error_message(message_lines)
```
Prints an error message for fatal issues. The first line is
prepended with 'jc: Error - ' and subsequent lines are indented.
Wraps text as needed based on the terminal width.
Parameters:
**Arguments**:
message: (list) list of string lines
Returns:
- `message` - (list) list of string lines
**Returns**:
None - just prints output to STDERR
<a id="jc.utils.compatibility"></a>
#### compatibility
## compatibility
```python
compatibility(mod_name, compatible, quiet=False)
def compatibility(mod_name, compatible, quiet=False)
```
Checks for the parser's compatibility with the running OS
platform.
Parameters:
**Arguments**:
mod_name: (string) __name__ of the calling module
compatible: (list) sys.platform name(s) compatible with
- `mod_name` - (string) __name__ of the calling module
- `compatible` - (list) sys.platform name(s) compatible with
the parser. compatible options:
linux, darwin, cygwin, win32, aix, freebsd
quiet: (bool) supress compatibility message if True
- `quiet` - (bool) supress compatibility message if True
**Returns**:
Returns:
None - just prints output to STDERR
<a id="jc.utils.has_data"></a>
#### has\_data
## has_data
```python
has_data(data)
def has_data(data)
```
Checks if the input contains data. If there are any non-whitespace
characters then return True, else return False.
Parameters:
**Arguments**:
data: (string) input to check whether it contains data
Returns:
- `data` - (string) input to check whether it contains data
**Returns**:
Boolean True if input string (data) contains non-whitespace
characters, otherwise False
<a id="jc.utils.convert_to_int"></a>
#### convert\_to\_int
## convert_to_int
```python
convert_to_int(value)
def convert_to_int(value)
```
Converts string and float input to int. Strips all non-numeric
characters from strings.
Parameters:
**Arguments**:
value: (string/integer/float) Input value
Returns:
- `value` - (string/integer/float) Input value
**Returns**:
integer/None Integer if successful conversion, otherwise None
<a id="jc.utils.convert_to_float"></a>
#### convert\_to\_float
## convert_to_float
```python
convert_to_float(value)
def convert_to_float(value)
```
Converts string and int input to float. Strips all non-numeric
characters from strings.
Parameters:
**Arguments**:
value: (string) Input value
Returns:
- `value` - (string) Input value
**Returns**:
float/None Float if successful conversion, otherwise None
<a id="jc.utils.convert_to_bool"></a>
#### convert\_to\_bool
## convert_to_bool
```python
convert_to_bool(value)
def convert_to_bool(value)
```
Converts string, integer, or float input to boolean by checking
for 'truthy' values.
Parameters:
**Arguments**:
value: (string/integer/float) Input value
Returns:
- `value` - (string/integer/float) Input value
**Returns**:
True/False False unless a 'truthy' number or string is found
('y', 'yes', 'true', '1', 1, -1, etc.)
<a id="jc.utils.stream_success"></a>
#### stream\_success
## stream_success
```python
stream_success(output_line, ignore_exceptions)
def stream_success(output_line, ignore_exceptions)
```
Add `_jc_meta` object to output line if `ignore_exceptions=True`
## stream_error
<a id="jc.utils.stream_error"></a>
#### stream\_error
```python
stream_error(e, ignore_exceptions, line)
def stream_error(e, ignore_exceptions, line)
```
Reraise the stream exception with annotation or print an error
`_jc_meta` field if `ignore_exceptions=True`.
<a id="jc.utils.input_type_check"></a>
#### input\_type\_check
## input_type_check
```python
input_type_check(data)
def input_type_check(data)
```
Ensure input data is a string
## streaming_input_type_check
<a id="jc.utils.streaming_input_type_check"></a>
#### streaming\_input\_type\_check
```python
streaming_input_type_check(data)
def streaming_input_type_check(data)
```
Ensure input data is an iterable, but not a string or bytes
## streaming_line_input_type_check
<a id="jc.utils.streaming_line_input_type_check"></a>
#### streaming\_line\_input\_type\_check
```python
streaming_line_input_type_check(line)
def streaming_line_input_type_check(line)
```
Ensure each line is a string
## timestamp
<a id="jc.utils.timestamp"></a>
## timestamp Objects
```python
timestamp(datetime_string)
class timestamp()
```
Input a date-time text string of several formats and convert to a
naive or timezone-aware epoch timestamp in UTC.
Parameters:
**Arguments**:
datetime_string: (str) a string representation of a
- `datetime_string` - (str) a string representation of a
date-time in several supported formats
Attributes:
**Attributes**:
string (str) the input datetime string

View File

@ -521,6 +521,7 @@ def main():
utils.error_message([f'Parser issue with {parser_name}:',
f'{e.__class__.__name__}: {e}',
'Please ensure the locale is set to C (LANG=C) and you used the correct parser.',
'For details use the -d or -dd option. Use "jc -h" for help.'])
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))
@ -541,8 +542,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}',
'Please ensure the locale is set to C (LANG=C) and you used the correct parser.',
'For details use the -d or -dd option. Use "jc -h" for help.'
])
sys.exit(combined_exit_code(magic_exit_code, JC_ERROR_EXIT))

View File

@ -1,4 +1,4 @@
.TH jc 1 2022-01-23 1.18.1 "JSON CLI output utility"
.TH jc 1 2022-01-25 1.18.2 "JSON CLI output utility"
.SH NAME
jc \- JSONifies the output of many CLI tools and file-types
.SH SYNOPSIS
@ -442,6 +442,16 @@ YAML file parser
\fB--zipinfo\fP
`zipinfo` command parser
.TP
.B
\fB--testing-two\fP
test parser 2
.TP
.B
\fB--testing\fP
test parser
.RE
.PP