diff --git a/docgen.sh b/docgen.sh index dce03c0f..8ea5a4f1 100755 --- a/docgen.sh +++ b/docgen.sh @@ -4,16 +4,16 @@ cd jc echo Building docs for: package -pydoc-markdown -m jc > ../docs/readme.md +pydoc-markdown -m jc '{"processors": [{"type":"filter"},{"type":"pydocmd"}]}' > ../docs/readme.md echo Building docs for: lib -pydoc-markdown -m jc.lib > ../docs/lib.md +pydoc-markdown -m jc.lib '{"processors": [{"type":"filter"},{"type":"pydocmd"}]}' > ../docs/lib.md echo Building docs for: utils -pydoc-markdown -m jc.utils > ../docs/utils.md +pydoc-markdown -m jc.utils '{"processors": [{"type":"filter"},{"type":"pydocmd"}]}' > ../docs/utils.md echo Building docs for: universal parser -pydoc-markdown -m jc.parsers.universal > ../docs/parsers/universal.md +pydoc-markdown -m jc.parsers.universal '{"processors": [{"type":"filter"},{"type":"pydocmd"}]}' > ../docs/parsers/universal.md # a bit of inception here... jc is being used to help # automate the generation of its own documentation. :) @@ -36,7 +36,7 @@ do echo "Building docs for: ${parser_name}" echo "[Home](https://kellyjonbrazil.github.io/jc/)" > ../docs/parsers/"${parser_name}".md - pydoc-markdown -m jc.parsers."${parser_name}" >> ../docs/parsers/"${parser_name}".md + pydoc-markdown -m jc.parsers."${parser_name}" '{"processors": [{"type":"filter"},{"type":"pydocmd"}]}' >> ../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 diff --git a/docs/lib.md b/docs/lib.md index 24bd4376..ef1d9dcb 100644 --- a/docs/lib.md +++ b/docs/lib.md @@ -20,61 +20,56 @@ 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'...} - - 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 - of `parser_mod_list()`. - - You can also use the lower-level parser modules directly: - - >>> import jc.parsers.date - >>> jc.parsers.date.parse('Tue Jan 18 10:23:07 PST 2022') - - Though, accessing plugin parsers directly is a bit more cumbersome, so - this higher-level API is recommended. Here is how you can access plugin - parsers without this API: - - >>> import os - >>> import sys - >>> import jc.appdirs - >>> data_dir = jc.appdirs.user_data_dir('jc', 'jc') - >>> local_parsers_dir = os.path.join(data_dir, 'jcparsers') - >>> sys.path.append(local_parsers_dir) - >>> import my_custom_parser - >>> my_custom_parser.parse('command_data') - + >>> import jc + >>> jc.parse('date', 'Tue Jan 18 10:23:07 PST 2022') + {'year': 2022, 'month': 'Jan', 'month_num': 1, 'day'...} -**Arguments**: +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 +of `parser_mod_list()`. - -- `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 - -- `quiet` - (boolean) suppress warning messages if True - -- `ignore_exceptions` - (boolean) ignore parsing exceptions if True - (streaming parsers only) - +You can also use the lower-level parser modules directly: -**Returns**: + >>> import jc.parsers.date + >>> jc.parsers.date.parse('Tue Jan 18 10:23:07 PST 2022') - - Standard Parsers: Dictionary or List of Dictionaries - Streaming Parsers: Generator Object containing Dictionaries +Though, accessing plugin parsers directly is a bit more cumbersome, so +this higher-level API is recommended. Here is how you can access plugin +parsers without this API: + + >>> import os + >>> import sys + >>> import jc.appdirs + >>> data_dir = jc.appdirs.user_data_dir('jc', 'jc') + >>> local_parsers_dir = os.path.join(data_dir, 'jcparsers') + >>> sys.path.append(local_parsers_dir) + >>> import my_custom_parser + >>> my_custom_parser.parse('command_data') + +Parameters: + + 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 + + quiet: (boolean) suppress warning messages if True + + ignore_exceptions: (boolean) ignore parsing exceptions if True + (streaming parsers only) + +Returns: + + Standard Parsers: Dictionary or List of Dictionaries + Streaming Parsers: Generator Object containing Dictionaries diff --git a/docs/parsers/acpi.md b/docs/parsers/acpi.md index fdc780e9..bd3fe853 100644 --- a/docs/parsers/acpi.md +++ b/docs/parsers/acpi.md @@ -7,231 +7,230 @@ jc - JSON CLI output utility `acpi` command output parser Usage (cli): -$ acpi -V | jc --acpi + $ acpi -V | jc --acpi -or + or -$ jc acpi -V + $ jc acpi -V Usage (module): -import jc -result = jc.parse('acpi', acpi_command_output) + import jc + result = jc.parse('acpi', acpi_command_output) -or + or -import jc.parsers.acpi -result = jc.parsers.acpi.parse(acpi_command_output) + import jc.parsers.acpi + result = jc.parsers.acpi.parse(acpi_command_output) Schema: -[ -{ -"type": string, -"id": integer, -"state": string, -"charge_percent": integer, -"until_charged": string, -"until_charged_hours": integer, -"until_charged_minuts": integer, -"until_charged_seconds": integer, -"until_charged_total_seconds": integer, -"charge_remaining": string, -"charge_remaining_hours": integer, -"charge_remaining_minutes": integer, -"charge_remaining_seconds": integer, -"charge_remaining_total_seconds": integer, -"design_capacity_mah": integer, -"last_full_capacity": integer, -"last_full_capacity_percent": integer, -"on-line": boolean, -"mode": string, -"temperature": float, -"temperature_unit": string, -"trip_points": [ -{ -"id": integer, -"switches_to_mode": string, -"temperature": float, -"temperature_unit": string -} -], -"messages": [ -string -] -} -] + [ + { + "type": string, + "id": integer, + "state": string, + "charge_percent": integer, + "until_charged": string, + "until_charged_hours": integer, + "until_charged_minuts": integer, + "until_charged_seconds": integer, + "until_charged_total_seconds": integer, + "charge_remaining": string, + "charge_remaining_hours": integer, + "charge_remaining_minutes": integer, + "charge_remaining_seconds": integer, + "charge_remaining_total_seconds": integer, + "design_capacity_mah": integer, + "last_full_capacity": integer, + "last_full_capacity_percent": integer, + "on-line": boolean, + "mode": string, + "temperature": float, + "temperature_unit": string, + "trip_points": [ + { + "id": integer, + "switches_to_mode": string, + "temperature": float, + "temperature_unit": string + } + ], + "messages": [ + string + ] + } + ] -**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"` - "Adapter", -- `"id"` - 0, -- `"on-line"` - true - }, - { -- `"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"` - 1, -- `"switches_to_mode"` - "hot", -- `"temperature"` - 127.0, -- `"temperature_unit"` - "C" - } - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - 0, -- `"messages"` - [ - "Processor 0 of 10" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - 1, -- `"messages"` - [ - "Processor 0 of 10" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - 2, -- `"messages"` - [ - "x86_pkg_temp no state information available" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - 3, -- `"messages"` - [ - "Processor 0 of 10" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - 4, -- `"messages"` - [ - "intel_powerclamp no state information available" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - 5, -- `"messages"` - [ - "Processor 0 of 10" - ] - } - ] - - $ 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"` - "Adapter", -- `"id"` - "0", -- `"on-line"` - true - }, - { -- `"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"` - "1", -- `"switches_to_mode"` - "hot", -- `"temperature"` - "127.0", -- `"temperature_unit"` - "C" - } - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - "0", -- `"messages"` - [ - "Processor 0 of 10" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - "1", -- `"messages"` - [ - "Processor 0 of 10" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - "2", -- `"messages"` - [ - "x86_pkg_temp no state information available" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - "3", -- `"messages"` - [ - "Processor 0 of 10" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - "4", -- `"messages"` - [ - "intel_powerclamp no state information available" - ] - }, - { -- `"type"` - "Cooling", -- `"id"` - "5", -- `"messages"` - [ - "Processor 0 of 10" - ] - } - ] + $ 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": "Adapter", + "id": 0, + "on-line": true + }, + { + "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": 1, + "switches_to_mode": "hot", + "temperature": 127.0, + "temperature_unit": "C" + } + ] + }, + { + "type": "Cooling", + "id": 0, + "messages": [ + "Processor 0 of 10" + ] + }, + { + "type": "Cooling", + "id": 1, + "messages": [ + "Processor 0 of 10" + ] + }, + { + "type": "Cooling", + "id": 2, + "messages": [ + "x86_pkg_temp no state information available" + ] + }, + { + "type": "Cooling", + "id": 3, + "messages": [ + "Processor 0 of 10" + ] + }, + { + "type": "Cooling", + "id": 4, + "messages": [ + "intel_powerclamp no state information available" + ] + }, + { + "type": "Cooling", + "id": 5, + "messages": [ + "Processor 0 of 10" + ] + } + ] + + $ 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": "Adapter", + "id": "0", + "on-line": true + }, + { + "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": "1", + "switches_to_mode": "hot", + "temperature": "127.0", + "temperature_unit": "C" + } + ] + }, + { + "type": "Cooling", + "id": "0", + "messages": [ + "Processor 0 of 10" + ] + }, + { + "type": "Cooling", + "id": "1", + "messages": [ + "Processor 0 of 10" + ] + }, + { + "type": "Cooling", + "id": "2", + "messages": [ + "x86_pkg_temp no state information available" + ] + }, + { + "type": "Cooling", + "id": "3", + "messages": [ + "Processor 0 of 10" + ] + }, + { + "type": "Cooling", + "id": "4", + "messages": [ + "intel_powerclamp no state information available" + ] + }, + { + "type": "Cooling", + "id": "5", + "messages": [ + "Processor 0 of 10" + ] + } + ] @@ -253,18 +252,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/airport.md b/docs/parsers/airport.md index 8eceb431..32d805d7 100644 --- a/docs/parsers/airport.md +++ b/docs/parsers/airport.md @@ -9,82 +9,81 @@ The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80 Usage (cli): -$ airport -I | jc --airport + $ airport -I | jc --airport -or + or -$ jc airport -I + $ jc airport -I Usage (module): -import jc -result = jc.parse('airport', airport_command_output) + import jc + result = jc.parse('airport', airport_command_output) -or + or -import jc.parsers.airport -result = jc.parsers.airport.parse(airport_command_output) + import jc.parsers.airport + result = jc.parsers.airport.parse(airport_command_output) Schema: -{ -"agrctlrssi": integer, -"agrextrssi": integer, -"agrctlnoise": integer, -"agrextnoise": integer, -"state": string, -"op_mode": string, -"lasttxrate": integer, -"maxrate": integer, -"lastassocstatus": integer, -"802_11_auth": string, -"link_auth": string, -"bssid": string, -"ssid": string, -"mcs": integer, -"channel": string -} + { + "agrctlrssi": integer, + "agrextrssi": integer, + "agrctlnoise": integer, + "agrextnoise": integer, + "state": string, + "op_mode": string, + "lasttxrate": integer, + "maxrate": integer, + "lastassocstatus": integer, + "802_11_auth": string, + "link_auth": string, + "bssid": string, + "ssid": string, + "mcs": integer, + "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" - } - - $ 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" - } + $ 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" + } + + $ 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" + } @@ -106,18 +105,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: darwin diff --git a/docs/parsers/airport_s.md b/docs/parsers/airport_s.md index 63bf0caf..4dddeeb5 100644 --- a/docs/parsers/airport_s.md +++ b/docs/parsers/airport_s.md @@ -9,110 +9,109 @@ The `airport` program can be found at `/System/Library/PrivateFrameworks/Apple80 Usage (cli): -$ airport -s | jc --airport-s + $ airport -s | jc --airport-s -or + or -$ jc airport -s + $ jc airport -s Usage (module): -import jc -result = jc.parse('airport_s', airport_s_command_output) + import jc + result = jc.parse('airport_s', airport_s_command_output) -or + or -import jc.parsers.airport_s -result = jc.parsers.airport_s.parse(airport_s_command_output) + import jc.parsers.airport_s + result = jc.parsers.airport_s.parse(airport_s_command_output) Schema: -[ -{ -"ssid": string, -"bssid": string, -"rssi": integer, -"channel": string, -"ht": boolean, -"cc": string, -"security": [ -string, -] -} -] + [ + { + "ssid": string, + "bssid": string, + "rssi": integer, + "channel": string, + "ht": boolean, + "cc": string, + "security": [ + string, + ] + } + ] -**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"` - [ - "WPA2(PSK/AES/AES)" - ] - }, - { -- `"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"` - [ - "NONE" - ] - }, - ... - ] - - $ 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"` - "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)" - }, - ... - ] + $ 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": [ + "WPA2(PSK/AES/AES)" + ] + }, + { + "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": [ + "NONE" + ] + }, + ... + ] + + $ 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": "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)" + }, + ... + ] @@ -134,18 +133,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: darwin diff --git a/docs/parsers/arp.md b/docs/parsers/arp.md index 50f0f653..10c968dc 100644 --- a/docs/parsers/arp.md +++ b/docs/parsers/arp.md @@ -9,119 +9,118 @@ Supports `arp` and `arp -a` output. Usage (cli): -$ arp | jc --arp + $ arp | jc --arp -or + or -$ jc arp + $ jc arp Usage (module): -import jc -result = jc.parse('arp', arp_command_output) + import jc + result = jc.parse('arp', arp_command_output) -or + or -import jc.parsers.arp -result = jc.parsers.arp.parse(arp_command_output) + import jc.parsers.arp + result = jc.parsers.arp.parse(arp_command_output) Schema: -[ -{ -"name": string, -"address": string, -"hwtype": string, -"hwaddress": string, -"flags_mask": string, -"iface": string, -"permanent": boolean, -"expires": integer -} -] + [ + { + "name": string, + "address": string, + "hwtype": string, + "hwaddress": string, + "flags_mask": string, + "iface": string, + "permanent": boolean, + "expires": integer + } + ] -**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"` - "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"` - "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"` - "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"` - "_gateway", -- `"address"` - "192.168.71.2", -- `"hwtype"` - "ether", -- `"hwaddress"` - "00:50:56:f7:4a:fc", -- `"iface"` - "ens33" -- `"permanent"` - false, -- `"expires"` - "110" - } - ] + $ arp | jc --arp -p + [ + { + "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" + } + ] + + $ arp | jc --arp -p -r + [ + { + "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" + } + ] + + $ 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": "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": "_gateway", + "address": "192.168.71.2", + "hwtype": "ether", + "hwaddress": "00:50:56:f7:4a:fc", + "iface": "ens33" + "permanent": false, + "expires": "110" + } + ] @@ -143,18 +142,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, aix, freebsd, darwin diff --git a/docs/parsers/blkid.md b/docs/parsers/blkid.md index 8b51c8c9..b2147331 100644 --- a/docs/parsers/blkid.md +++ b/docs/parsers/blkid.md @@ -7,124 +7,123 @@ jc - JSON CLI output utility `blkid` command output parser Usage (cli): -$ blkid | jc --blkid + $ blkid | jc --blkid -or + or -$ jc blkid + $ jc blkid Usage (module): -import jc -result = jc.parse('blkid', blkid_command_output) + import jc + result = jc.parse('blkid', blkid_command_output) -or + or -import jc.parsers.blkid -result = jc.parsers.blkid.parse(blkid_command_output) + import jc.parsers.blkid + result = jc.parsers.blkid.parse(blkid_command_output) Schema: -[ -{ -"device": string, -"uuid": string, -"type": string, -"usage": string, -"part_entry_scheme": string, -"part_entry_type": string, -"part_entry_flags": string, -"part_entry_number": integer, -"part_entry_offset": integer, -"part_entry_size": integer, -"part_entry_disk": string, -"id_fs_uuid": string, -"id_fs_uuid_enc": string, -"id_fs_version": string, -"id_fs_type": string, -"id_fs_usage": string, -"id_part_entry_scheme": string, -"id_part_entry_type": string, -"id_part_entry_flags": string, -"id_part_entry_number": integer, -"id_part_entry_offset": integer, -"id_part_entry_size": integer, -"id_iolimit_minimum_io_size": integer, -"id_iolimit_physical_sector_size": integer, -"id_iolimit_logical_sector_size": integer, -"id_part_entry_disk": string, -"minimum_io_size": integer, -"physical_sector_size": integer, -"logical_sector_size": integer -} -] + [ + { + "device": string, + "uuid": string, + "type": string, + "usage": string, + "part_entry_scheme": string, + "part_entry_type": string, + "part_entry_flags": string, + "part_entry_number": integer, + "part_entry_offset": integer, + "part_entry_size": integer, + "part_entry_disk": string, + "id_fs_uuid": string, + "id_fs_uuid_enc": string, + "id_fs_version": string, + "id_fs_type": string, + "id_fs_usage": string, + "id_part_entry_scheme": string, + "id_part_entry_type": string, + "id_part_entry_flags": string, + "id_part_entry_number": integer, + "id_part_entry_offset": integer, + "id_part_entry_size": integer, + "id_iolimit_minimum_io_size": integer, + "id_iolimit_physical_sector_size": integer, + "id_iolimit_logical_sector_size": integer, + "id_part_entry_disk": string, + "minimum_io_size": integer, + "physical_sector_size": integer, + "logical_sector_size": integer + } + ] -**Examples**: +Examples: - - $ blkid | jc --blkid -p - [ - { -- `"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/mapper/centos-root", -- `"uuid"` - "07d718ff-950c-4e5b-98f0-42a1147c77d9", -- `"type"` - "xfs" - }, - { -- `"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" - } - ] - - $ 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" - } - ] + $ blkid | jc --blkid -p + [ + { + "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/mapper/centos-root", + "uuid": "07d718ff-950c-4e5b-98f0-42a1147c77d9", + "type": "xfs" + }, + { + "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" + } + ] + + $ 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" + } + ] @@ -146,18 +145,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/cksum.md b/docs/parsers/cksum.md index 1ecfb406..180d5b6c 100644 --- a/docs/parsers/cksum.md +++ b/docs/parsers/cksum.md @@ -11,54 +11,53 @@ This parser works with the following checksum calculation utilities: Usage (cli): -$ cksum file.txt | jc --cksum + $ cksum file.txt | jc --cksum -or + or -$ jc cksum file.txt + $ jc cksum file.txt Usage (module): -import jc -result = jc.parse('cksum', cksum_command_output) + import jc + result = jc.parse('cksum', cksum_command_output) -or + or -import jc.parsers.cksum -result = jc.parsers.cksum.parse(cksum_command_output) + import jc.parsers.cksum + result = jc.parsers.cksum.parse(cksum_command_output) Schema: -[ -{ -"filename": string, -"checksum": integer, -"blocks": integer -} -] + [ + { + "filename": string, + "checksum": integer, + "blocks": integer + } + ] -**Examples**: +Examples: - - $ cksum * | jc --cksum -p - [ - { -- `"filename"` - "__init__.py", -- `"checksum"` - 4294967295, -- `"blocks"` - 0 - }, - { -- `"filename"` - "airport.py", -- `"checksum"` - 2208551092, -- `"blocks"` - 3745 - }, - { -- `"filename"` - "airport_s.py", -- `"checksum"` - 1113817598, -- `"blocks"` - 4572 - }, - ... - ] + $ cksum * | jc --cksum -p + [ + { + "filename": "__init__.py", + "checksum": 4294967295, + "blocks": 0 + }, + { + "filename": "airport.py", + "checksum": 2208551092, + "blocks": 3745 + }, + { + "filename": "airport_s.py", + "checksum": 1113817598, + "blocks": 4572 + }, + ... + ] @@ -80,18 +79,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/crontab.md b/docs/parsers/crontab.md index 61ef64ad..0b24a2ec 100644 --- a/docs/parsers/crontab.md +++ b/docs/parsers/crontab.md @@ -10,174 +10,173 @@ Supports `crontab -l` command output and crontab files. Usage (cli): -$ crontab -l | jc --crontab + $ crontab -l | jc --crontab -or + or -$ jc crontab -l + $ jc crontab -l Usage (module): -import jc -result = jc.parse('crontab', crontab_output) + import jc + result = jc.parse('crontab', crontab_output) -or + or -import jc.parsers.crontab -result = jc.parsers.crontab.parse(crontab_output) + import jc.parsers.crontab + result = jc.parsers.crontab.parse(crontab_output) Schema: -{ -"variables": [ -{ -"name": string, -"value": string -} -], -"schedule": [ -{ -"occurrence" string, -"minute": [ -string -], -"hour": [ -string -], -"day_of_month": [ -string -], -"month": [ -string -], -"day_of_week": [ -string -], -"occurrence": string, -"command": string -} -] -} + { + "variables": [ + { + "name": string, + "value": string + } + ], + "schedule": [ + { + "occurrence" string, + "minute": [ + string + ], + "hour": [ + string + ], + "day_of_month": [ + string + ], + "month": [ + string + ], + "day_of_week": [ + string + ], + "occurrence": string, + "command": string + } + ] + } -**Examples**: +Examples: - - $ crontab -l | jc --crontab -p - { -- `"variables"` - [ - { -- `"name"` - "MAILTO", -- `"value"` - "root" - }, - { -- `"name"` - "PATH", -- `"value"` - "/sbin:/bin:/usr/sbin:/usr/bin" - }, - { -- `"name"` - "SHELL", -- `"value"` - "/bin/bash" - } - ], -- `"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"` - [ - "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"` - "reboot", -- `"command"` - "/home/cleanup" - }, - { -- `"occurrence"` - "monthly", -- `"command"` - "/home/maverick/bin/tape-backup" - } - ] - } - - $ cat /etc/crontab | jc --crontab -p -r - { -- `"variables"` - [ - { -- `"name"` - "MAILTO", -- `"value"` - "root" - }, - { -- `"name"` - "PATH", -- `"value"` - "/sbin:/bin:/usr/sbin:/usr/bin" - }, - { -- `"name"` - "SHELL", -- `"value"` - "/bin/bash" - } - ], -- `"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"` - "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"` - "reboot", -- `"command"` - "/home/cleanup" - }, - { -- `"occurrence"` - "monthly", -- `"command"` - "/home/maverick/bin/tape-backup" - } - ] - } + $ crontab -l | jc --crontab -p + { + "variables": [ + { + "name": "MAILTO", + "value": "root" + }, + { + "name": "PATH", + "value": "/sbin:/bin:/usr/sbin:/usr/bin" + }, + { + "name": "SHELL", + "value": "/bin/bash" + } + ], + "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": [ + "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": "reboot", + "command": "/home/cleanup" + }, + { + "occurrence": "monthly", + "command": "/home/maverick/bin/tape-backup" + } + ] + } + + $ cat /etc/crontab | jc --crontab -p -r + { + "variables": [ + { + "name": "MAILTO", + "value": "root" + }, + { + "name": "PATH", + "value": "/sbin:/bin:/usr/sbin:/usr/bin" + }, + { + "name": "SHELL", + "value": "/bin/bash" + } + ], + "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": "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": "reboot", + "command": "/home/cleanup" + }, + { + "occurrence": "monthly", + "command": "/home/maverick/bin/tape-backup" + } + ] + } @@ -199,18 +198,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, aix, freebsd diff --git a/docs/parsers/crontab_u.md b/docs/parsers/crontab_u.md index 28d78c5d..ec286249 100644 --- a/docs/parsers/crontab_u.md +++ b/docs/parsers/crontab_u.md @@ -11,170 +11,169 @@ information for processes. Usage (cli): -$ crontab -l | jc --crontab-u + $ crontab -l | jc --crontab-u Usage (module): -import jc -result = jc.parse('crontab_u', crontab_u_output) + import jc + result = jc.parse('crontab_u', crontab_u_output) -or + or -import jc.parsers.crontab_u -result = jc.parsers.crontab_u.parse(crontab_u_output) + import jc.parsers.crontab_u + result = jc.parsers.crontab_u.parse(crontab_u_output) Schema: -{ -"variables": [ -{ -"name": string, -"value": string -} -], -"schedule": [ -{ -"occurrence" string, -"minute": [ -string -], -"hour": [ -string -], -"day_of_month": [ -string -], -"month": [ -string -], -"day_of_week": [ -string -], -"occurrence": string, -"user": string, -"command": string -} -] -} + { + "variables": [ + { + "name": string, + "value": string + } + ], + "schedule": [ + { + "occurrence" string, + "minute": [ + string + ], + "hour": [ + string + ], + "day_of_month": [ + string + ], + "month": [ + string + ], + "day_of_week": [ + string + ], + "occurrence": string, + "user": string, + "command": string + } + ] + } -**Examples**: +Examples: - - $ cat /etc/crontab | jc --crontab-u -p - { -- `"variables"` - [ - { -- `"name"` - "PATH", -- `"value"` - "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sb..." - }, - { -- `"name"` - "SHELL", -- `"value"` - "/bin/sh" - } - ], -- `"schedule"` - [ - { -- `"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"` - [ - "52" - ], -- `"hour"` - [ - "6" - ], -- `"day_of_month"` - [ - "1" - ], -- `"month"` - [ - "*" - ], -- `"day_of_week"` - [ - "*" - ], -- `"user"` - "root", -- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..." - } - ] - } - - $ cat /etc/crontab | jc --crontab-u -p -r - { -- `"variables"` - [ - { -- `"name"` - "PATH", -- `"value"` - "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/..." - }, - { -- `"name"` - "SHELL", -- `"value"` - "/bin/sh" - } - ], -- `"schedule"` - [ - { -- `"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"` - "52", -- `"hour"` - "6", -- `"day_of_month"` - "1", -- `"month"` - "*", -- `"day_of_week"` - "*", -- `"user"` - "root", -- `"command"` - "test -x /usr/sbin/anacron || ( cd / && run-parts ..." - } - ] - } + $ cat /etc/crontab | jc --crontab-u -p + { + "variables": [ + { + "name": "PATH", + "value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sb..." + }, + { + "name": "SHELL", + "value": "/bin/sh" + } + ], + "schedule": [ + { + "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": [ + "52" + ], + "hour": [ + "6" + ], + "day_of_month": [ + "1" + ], + "month": [ + "*" + ], + "day_of_week": [ + "*" + ], + "user": "root", + "command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..." + } + ] + } + + $ cat /etc/crontab | jc --crontab-u -p -r + { + "variables": [ + { + "name": "PATH", + "value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/..." + }, + { + "name": "SHELL", + "value": "/bin/sh" + } + ], + "schedule": [ + { + "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": "52", + "hour": "6", + "day_of_month": "1", + "month": "*", + "day_of_week": "*", + "user": "root", + "command": "test -x /usr/sbin/anacron || ( cd / && run-parts ..." + } + ] + } @@ -196,18 +195,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, aix, freebsd diff --git a/docs/parsers/csv.md b/docs/parsers/csv.md index 67f8ed75..a7e44b0d 100644 --- a/docs/parsers/csv.md +++ b/docs/parsers/csv.md @@ -11,77 +11,76 @@ The first row of the file must be a header row. Usage (cli): -$ cat file.csv | jc --csv + $ cat file.csv | jc --csv Usage (module): -import jc -result = jc.parse('csv', csv_output) + import jc + result = jc.parse('csv', csv_output) -or + or -import jc.parsers.csv -result = jc.parsers.csv.parse(csv_output) + import jc.parsers.csv + result = jc.parsers.csv.parse(csv_output) Schema: -csv file converted to a Dictionary: -https://docs.python.org/3/library/csv.html + csv file converted to a Dictionary: + https://docs.python.org/3/library/csv.html -[ -{ -"column_name1": string, -"column_name2": string -} -] + [ + { + "column_name1": string, + "column_name2": string + } + ] -**Examples**: +Examples: - - $ cat homes.csv - "Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"... - 142, 160, 28, 10, 5, 3, 60, 0.28, 3167 - 175, 180, 18, 8, 4, 1, 12, 0.43, 4033 - 129, 132, 13, 6, 3, 1, 41, 0.33, 1471 - ... - - $ 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"` - "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" - }, - ... - ] + $ cat homes.csv + "Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"... + 142, 160, 28, 10, 5, 3, 60, 0.28, 3167 + 175, 180, 18, 8, 4, 1, 12, 0.43, 4033 + 129, 132, 13, 6, 3, 1, 41, 0.33, 1471 + ... + + $ 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": "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" + }, + ... + ] @@ -103,18 +102,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/csv_s.md b/docs/parsers/csv_s.md index 334d574b..c6d89c19 100644 --- a/docs/parsers/csv_s.md +++ b/docs/parsers/csv_s.md @@ -16,58 +16,57 @@ then the rest of the rows are loaded lazily. Usage (cli): -$ cat file.csv | jc --csv-s + $ cat file.csv | jc --csv-s Usage (module): -import jc -# result is an iterable object (generator) -result = jc.parse('csv_s', csv_output.splitlines()) -for item in result: -# do something + import jc + # result is an iterable object (generator) + result = jc.parse('csv_s', csv_output.splitlines()) + for item in result: + # do something -or + or -import jc.parsers.csv_s -# result is an iterable object (generator) -result = jc.parsers.csv_s.parse(csv_output.splitlines()) -for item in result: -# do something + import jc.parsers.csv_s + # result is an iterable object (generator) + result = jc.parsers.csv_s.parse(csv_output.splitlines()) + for item in result: + # do something Schema: -csv file converted to a Dictionary: -https://docs.python.org/3/library/csv.html + csv file converted to a Dictionary: + https://docs.python.org/3/library/csv.html -{ -"column_name1": string, -"column_name2": string, + { + "column_name1": string, + "column_name2": string, -# below object only exists if using -qq or ignore_exceptions=True + # below object only exists if using -qq or ignore_exceptions=True -"_jc_meta": -{ -"success": boolean, # false if error parsing -"error": string, # exists if "success" is false -"line": string # exists if "success" is false -} -} + "_jc_meta": + { + "success": boolean, # false if error parsing + "error": string, # exists if "success" is false + "line": string # exists if "success" is false + } + } -**Examples**: +Examples: - - $ cat homes.csv - "Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"... - 142, 160, 28, 10, 5, 3, 60, 0.28, 3167 - 175, 180, 18, 8, 4, 1, 12, 0.43, 4033 - 129, 132, 13, 6, 3, 1, 41, 0.33, 1471 - ... - - $ cat homes.csv | jc --csv-s - {"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5"...} - {"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4"...} - {"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3"...} - ... + $ cat homes.csv + "Sell", "List", "Living", "Rooms", "Beds", "Baths", "Age", "Acres"... + 142, 160, 28, 10, 5, 3, 60, 0.28, 3167 + 175, 180, 18, 8, 4, 1, 12, 0.43, 4033 + 129, 132, 13, 6, 3, 1, 41, 0.33, 1471 + ... + + $ cat homes.csv | jc --csv-s + {"Sell":"142","List":"160","Living":"28","Rooms":"10","Beds":"5"...} + {"Sell":"175","List":"180","Living":"18","Rooms":"8","Beds":"4"...} + {"Sell":"129","List":"132","Living":"13","Rooms":"6","Beds":"3"...} + ... @@ -89,27 +88,22 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False) Main text parsing generator function. Returns an iterator object. -**Arguments**: +Parameters: - -- `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 - + data: (iterable) line-based text data to parse + (e.g. sys.stdin or str.splitlines()) -**Yields**: + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + ignore_exceptions: (boolean) ignore parsing exceptions if True - - Dictionary. Raw or processed structured data. - +Yields: -**Returns**: + Dictionary. Raw or processed structured data. - - Iterator object +Returns: + + Iterator object ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/date.md b/docs/parsers/date.md index 91b5c5dd..1d73d649 100644 --- a/docs/parsers/date.md +++ b/docs/parsers/date.md @@ -13,75 +13,74 @@ available if the timezone field is UTC. Usage (cli): -$ date | jc --date + $ date | jc --date -or + or -$ jc date + $ jc date Usage (module): -import jc -result = jc.parse('date', date_command_output) + import jc + result = jc.parse('date', date_command_output) -or + or -import jc.parsers.date -result = jc.parsers.date.parse(date_command_output) + import jc.parsers.date + result = jc.parsers.date.parse(date_command_output) Schema: -{ -"year": integer, -"month": string, -"month_num": integer, -"day": integer, -"weekday": string, -"weekday_num": integer, -"hour": integer, -"hour_24": integer, -"minute": integer, -"second": integer, -"period": string, -"timezone": string, -"utc_offset": string, # null if timezone field is not UTC -"day_of_year": integer, -"week_of_year": integer, -"iso": string, -"epoch": integer, # [0] -"epoch_utc": integer, # [1] -"timezone_aware": boolean # [2] -} + { + "year": integer, + "month": string, + "month_num": integer, + "day": integer, + "weekday": string, + "weekday_num": integer, + "hour": integer, + "hour_24": integer, + "minute": integer, + "second": integer, + "period": string, + "timezone": string, + "utc_offset": string, # null if timezone field is not UTC + "day_of_year": integer, + "week_of_year": integer, + "iso": string, + "epoch": integer, # [0] + "epoch_utc": integer, # [1] + "timezone_aware": boolean # [2] + } -[0] naive timestamp -[1] timezone-aware timestamp. Only available if timezone field is UTC -[2] if true, all fields are correctly based on UTC + [0] naive timestamp + [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 - } + $ 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 + } @@ -103,18 +102,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/df.md b/docs/parsers/df.md index 22fd7c35..af25753e 100644 --- a/docs/parsers/df.md +++ b/docs/parsers/df.md @@ -7,101 +7,100 @@ jc - JSON CLI output utility `df` command output parser Usage (cli): -$ df | jc --df + $ df | jc --df -or + or -$ jc df + $ jc df Usage (module): -import jc -result = jc.parse('df', df_command_output) + import jc + result = jc.parse('df', df_command_output) -or + or -import jc.parsers.df -result = jc.parsers.df.parse(df_command_output) + import jc.parsers.df + result = jc.parsers.df.parse(df_command_output) Schema: -[ -{ -"filesystem": string, -"size": string, -"1k_blocks": integer, -"512_blocks": integer, -"used": integer, -"available": integer, -"capacity_percent": integer, -"ifree": integer, -"iused": integer, -"use_percent": integer, -"iused_percent": integer, -"mounted_on": string -} -] + [ + { + "filesystem": string, + "size": string, + "1k_blocks": integer, + "512_blocks": integer, + "used": integer, + "available": integer, + "capacity_percent": integer, + "ifree": integer, + "iused": integer, + "use_percent": integer, + "iused_percent": integer, + "mounted_on": string + } + ] -**Examples**: +Examples: - - $ df | jc --df -p - [ - { -- `"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"` - 11800, -- `"available"` - 1918868, -- `"use_percent"` - 1, -- `"mounted_on"` - "/run" - }, - ... - ] - - $ df | jc --df -p -r - [ - { -- `"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"` - "11800", -- `"available"` - "1918868", -- `"use_percent"` - "1%", -- `"mounted_on"` - "/run" - }, - ... - ] + $ df | jc --df -p + [ + { + "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": 11800, + "available": 1918868, + "use_percent": 1, + "mounted_on": "/run" + }, + ... + ] + + $ df | jc --df -p -r + [ + { + "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": "11800", + "available": "1918868", + "use_percent": "1%", + "mounted_on": "/run" + }, + ... + ] @@ -123,18 +122,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/dig.md b/docs/parsers/dig.md index d56a573b..b0e47027 100644 --- a/docs/parsers/dig.md +++ b/docs/parsers/dig.md @@ -7,7 +7,7 @@ jc - JSON CLI output utility `dig` command output parser Options supported: - `+noall +answer` options are supported in cases where only the answer -information is desired. + information is desired. - `+axfr` option is supported on its own The `when_epoch` calculated timestamp field is naive. (i.e. based on the @@ -18,315 +18,314 @@ only available if the timezone field is UTC. Usage (cli): -$ dig example.com | jc --dig + $ dig example.com | jc --dig -or + or -$ jc dig example.com + $ jc dig example.com Usage (module): -import jc -result = jc.parse('dig', dig_command_output) + import jc + result = jc.parse('dig', dig_command_output) -or + or -import jc.parsers.dig -result = jc.parsers.dig.parse(dig_command_output) + import jc.parsers.dig + result = jc.parsers.dig.parse(dig_command_output) Schema: -[ -{ -"id": integer, -"opcode": string, -"status": string, -"flags": [ -string -], -"query_num": integer, -"answer_num": integer, -"authority_num": integer, -"additional_num": integer, -"axfr": [ -{ -"name": string, -"class": string, -"type": string, -"ttl": integer, -"data": string -} -], -"opt_pseudosection": { -"edns": { -"version": integer, -"flags": [ -string -], -"udp": integer -}, -"cookie": string -}, -"question": { -"name": string, -"class": string, -"type": string -}, -"answer": [ -{ -"name": string, -"class": string, -"type": string, -"ttl": integer, -"data": string -} -], -"additional": [ -{ -"name": string, -"class": string, -"type": string, -"ttl": integer, -"data": string -} -], -"authority": [ -{ -"name": string, -"class": string, -"type": string, -"ttl": integer, -"data": string -} -], -"query_size": integer, -"query_time": integer, # in msec -"server": string, -"when": string, -"when_epoch": integer, # [0] -"when_epoch_utc": integer, # [1] -"rcvd": integer -"size": string -} -] + [ + { + "id": integer, + "opcode": string, + "status": string, + "flags": [ + string + ], + "query_num": integer, + "answer_num": integer, + "authority_num": integer, + "additional_num": integer, + "axfr": [ + { + "name": string, + "class": string, + "type": string, + "ttl": integer, + "data": string + } + ], + "opt_pseudosection": { + "edns": { + "version": integer, + "flags": [ + string + ], + "udp": integer + }, + "cookie": string + }, + "question": { + "name": string, + "class": string, + "type": string + }, + "answer": [ + { + "name": string, + "class": string, + "type": string, + "ttl": integer, + "data": string + } + ], + "additional": [ + { + "name": string, + "class": string, + "type": string, + "ttl": integer, + "data": string + } + ], + "authority": [ + { + "name": string, + "class": string, + "type": string, + "ttl": integer, + "data": string + } + ], + "query_size": integer, + "query_time": integer, # in msec + "server": string, + "when": string, + "when_epoch": integer, # [0] + "when_epoch_utc": integer, # [1] + "rcvd": integer + "size": string + } + ] -[0] naive timestamp if "when" field is parsable, else null -[1] timezone aware timestamp availabe for UTC, else null + [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"` - [ - "qr", - "rd", - "ra" - ], -- `"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" - }, -- `"answer"` - [ - { -- `"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 - } - ] - - $ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p -r - [ - { -- `"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" - } - }, -- `"question"` - { -- `"name"` - "example.com.", -- `"class"` - "IN", -- `"type"` - "A" - }, -- `"answer"` - [ - { -- `"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" - } - ] - - $ dig -x 1.1.1.1 | jc --dig -p - [ - { -- `"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 - } - }, -- `"question"` - { -- `"name"` - "1.1.1.1.in-addr.arpa.", -- `"class"` - "IN", -- `"type"` - "PTR" - }, -- `"answer"` - [ - { -- `"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 - } - ] - - $ dig -x 1.1.1.1 | jc --dig -p -r - [ - { -- `"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" - } - }, -- `"question"` - { -- `"name"` - "1.1.1.1.in-addr.arpa.", -- `"class"` - "IN", -- `"type"` - "PTR" - }, -- `"answer"` - [ - { -- `"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" - } - ] - - $ dig +noall +answer cnn.com | jc --dig -p - [ - { -- `"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.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.129.67" - } - ] - } - ] + $ dig example.com | jc --dig -p + [ + { + "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 + } + }, + "question": { + "name": "example.com.", + "class": "IN", + "type": "A" + }, + "answer": [ + { + "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 + } + ] + + $ dig cnn.com www.cnn.com @205.251.194.64 | jc --dig -p -r + [ + { + "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" + } + }, + "question": { + "name": "example.com.", + "class": "IN", + "type": "A" + }, + "answer": [ + { + "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" + } + ] + + $ dig -x 1.1.1.1 | jc --dig -p + [ + { + "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 + } + }, + "question": { + "name": "1.1.1.1.in-addr.arpa.", + "class": "IN", + "type": "PTR" + }, + "answer": [ + { + "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 + } + ] + + $ dig -x 1.1.1.1 | jc --dig -p -r + [ + { + "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" + } + }, + "question": { + "name": "1.1.1.1.in-addr.arpa.", + "class": "IN", + "type": "PTR" + }, + "answer": [ + { + "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" + } + ] + + $ dig +noall +answer cnn.com | jc --dig -p + [ + { + "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.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.129.67" + } + ] + } + ] @@ -348,18 +347,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, aix, freebsd, darwin, win32, cygwin diff --git a/docs/parsers/dir.md b/docs/parsers/dir.md index 21e30db4..254c2854 100644 --- a/docs/parsers/dir.md +++ b/docs/parsers/dir.md @@ -19,112 +19,111 @@ time of the system the parser is run on) Usage (cli): -C:> dir | jc --dir + C:> dir | jc --dir Usage (module): -import jc -result = jc.parse('dir', dir_command_output) + import jc + result = jc.parse('dir', dir_command_output) -or + or -import jc.parsers.dir -result = jc.parsers.dir.parse(dir_command_output) + import jc.parsers.dir + result = jc.parsers.dir.parse(dir_command_output) Schema: -[ -{ -"date": string, -"time": string, -"epoch": integer, # naive timestamp -"dir": boolean, -"size": integer, -"filename: string, -"parent": string -} -] + [ + { + "date": string, + "time": string, + "epoch": integer, # naive timestamp + "dir": boolean, + "size": integer, + "filename: string, + "parent": string + } + ] -**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"` - "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 - }, - ... - ] - - 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"` - "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" - }, - ... - ] + 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": "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 + }, + ... + ] + + 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": "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" + }, + ... + ] @@ -146,18 +145,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: win32 diff --git a/docs/parsers/dmidecode.md b/docs/parsers/dmidecode.md index 69e84403..3396b660 100644 --- a/docs/parsers/dmidecode.md +++ b/docs/parsers/dmidecode.md @@ -7,129 +7,128 @@ jc - JSON CLI output utility `dmidecode` command output parser Usage (cli): -$ dmidecode | jc --dmidecode + $ dmidecode | jc --dmidecode -or + or -$ jc dmidecode + $ jc dmidecode Usage (module): -import jc -result = jc.parse('dmidecode', dmidecode_command_output) + import jc + result = jc.parse('dmidecode', dmidecode_command_output) -or + or -import jc.parsers.dmidecode -result = jc.parsers.dmidecode.parse(dmidecode_command_output) + import jc.parsers.dmidecode + result = jc.parsers.dmidecode.parse(dmidecode_command_output) Schema: -[ -{ -"handle": string, -"type": integer, -"bytes": integer, -"description": string, -"values": { # null if empty -"lowercase_no_spaces_keys": string, -"multiline_key_values": [ -string, -] -} -} -] + [ + { + "handle": string, + "type": integer, + "bytes": integer, + "description": string, + "values": { # null if empty + "lowercase_no_spaces_keys": string, + "multiline_key_values": [ + string, + ] + } + } + ] -**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"` - [ - "ISA is supported", - "PCI is supported", - "PC Card (PCMCIA) is supported", - "PNP is supported", - "APM is supported", - "BIOS is upgradeable", - "BIOS shadowing is allowed", - "ESCD support is available", - "Boot from CD is supported", - "Selectable boot is supported", - "EDD is supported", - "Print screen service is supported (int 5h)", - "8042 keyboard services are supported (int 9h)", - "Serial services are supported (int 14h)", - "Printer services are supported (int 17h)", - "CGA/mono video services are supported (int 10h)", - "ACPI is supported", - "Smart battery is supported", - "BIOS boot specification is supported", - "Function key-initiated network boot is supported", - "Targeted content distribution is supported" - ], -- `"bios_revision"` - "4.6", -- `"firmware_revision"` - "0.0" - } - }, - ... - ] - - # 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"` - [ - "ISA is supported", - "PCI is supported", - "PC Card (PCMCIA) is supported", - "PNP is supported", - "APM is supported", - "BIOS is upgradeable", - "BIOS shadowing is allowed", - "ESCD support is available", - "Boot from CD is supported", - "Selectable boot is supported", - "EDD is supported", - "Print screen service is supported (int 5h)", - "8042 keyboard services are supported (int 9h)", - "Serial services are supported (int 14h)", - "Printer services are supported (int 17h)", - "CGA/mono video services are supported (int 10h)", - "ACPI is supported", - "Smart battery is supported", - "BIOS boot specification is supported", - "Function key-initiated network boot is supported", - "Targeted content distribution is supported" - ], -- `"bios_revision"` - "4.6", -- `"firmware_revision"` - "0.0" - } - }, - ... - ] + # 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": [ + "ISA is supported", + "PCI is supported", + "PC Card (PCMCIA) is supported", + "PNP is supported", + "APM is supported", + "BIOS is upgradeable", + "BIOS shadowing is allowed", + "ESCD support is available", + "Boot from CD is supported", + "Selectable boot is supported", + "EDD is supported", + "Print screen service is supported (int 5h)", + "8042 keyboard services are supported (int 9h)", + "Serial services are supported (int 14h)", + "Printer services are supported (int 17h)", + "CGA/mono video services are supported (int 10h)", + "ACPI is supported", + "Smart battery is supported", + "BIOS boot specification is supported", + "Function key-initiated network boot is supported", + "Targeted content distribution is supported" + ], + "bios_revision": "4.6", + "firmware_revision": "0.0" + } + }, + ... + ] + + # 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": [ + "ISA is supported", + "PCI is supported", + "PC Card (PCMCIA) is supported", + "PNP is supported", + "APM is supported", + "BIOS is upgradeable", + "BIOS shadowing is allowed", + "ESCD support is available", + "Boot from CD is supported", + "Selectable boot is supported", + "EDD is supported", + "Print screen service is supported (int 5h)", + "8042 keyboard services are supported (int 9h)", + "Serial services are supported (int 14h)", + "Printer services are supported (int 17h)", + "CGA/mono video services are supported (int 10h)", + "ACPI is supported", + "Smart battery is supported", + "BIOS boot specification is supported", + "Function key-initiated network boot is supported", + "Targeted content distribution is supported" + ], + "bios_revision": "4.6", + "firmware_revision": "0.0" + } + }, + ... + ] @@ -151,18 +150,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/dpkg_l.md b/docs/parsers/dpkg_l.md index 6addc439..b465ec45 100644 --- a/docs/parsers/dpkg_l.md +++ b/docs/parsers/dpkg_l.md @@ -8,134 +8,133 @@ jc - JSON CLI output utility `dpkg -l` command output parser Set the `COLUMNS` environment variable to a large value to avoid field truncation. For example: -$ COLUMNS=500 dpkg -l | jc --dpkg-l + $ COLUMNS=500 dpkg -l | jc --dpkg-l Usage (cli): -$ dpkg -l | jc --dpkg-l + $ dpkg -l | jc --dpkg-l -or + or -$ jc dpkg -l + $ jc dpkg -l Usage (module): -import jc -result = jc.parse('dpkg_l', dpkg_command_output) + import jc + result = jc.parse('dpkg_l', dpkg_command_output) -or + or -import jc.parsers.dpkg_l -result = jc.parsers.dpkg_l.parse(dpkg_command_output) + import jc.parsers.dpkg_l + result = jc.parsers.dpkg_l.parse(dpkg_command_output) Schema: -[ -{ -"codes": string, -"name": string, -"version": string, -"architecture": string, -"description": string, -"desired": string, -"status": string, -"error": string -} -] + [ + { + "codes": string, + "name": string, + "version": string, + "architecture": string, + "description": string, + "desired": string, + "status": string, + "error": string + } + ] -**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"` - "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"` - "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" - }, - ... - ] - - $ 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"` - "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"` - "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" - }, - ... - ] + $ 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": "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": "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" + }, + ... + ] + + $ 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": "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": "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" + }, + ... + ] @@ -157,18 +156,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/du.md b/docs/parsers/du.md index 2d2c7a8a..1dc282fd 100644 --- a/docs/parsers/du.md +++ b/docs/parsers/du.md @@ -7,91 +7,90 @@ jc - JSON CLI output utility `du` command output parser Usage (cli): -$ du | jc --du + $ du | jc --du -or + or -$ jc du + $ jc du Usage (module): -import jc -result = jc.parse('du', du_command_output) + import jc + result = jc.parse('du', du_command_output) -or + or -import jc.parsers.du -result = jc.parsers.du.parse(du_command_output) + import jc.parsers.du + result = jc.parsers.du.parse(du_command_output) Schema: -[ -{ -"size": integer, -"name": string -} -] + [ + { + "size": integer, + "name": string + } + ] -**Examples**: +Examples: - - $ du /usr | jc --du -p - [ - { -- `"size"` - 104608, -- `"name"` - "/usr/bin" - }, - { -- `"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"` - 1008, -- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..." - }, - ... - ] - - $ du /usr | jc --du -p -r - [ - { -- `"size"` - "104608", -- `"name"` - "/usr/bin" - }, - { -- `"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"` - "1008", -- `"name"` - "/usr/standalone/firmware/iBridge1_1Customer.bundle/..." - }, - ... - ] + $ du /usr | jc --du -p + [ + { + "size": 104608, + "name": "/usr/bin" + }, + { + "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": 1008, + "name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..." + }, + ... + ] + + $ du /usr | jc --du -p -r + [ + { + "size": "104608", + "name": "/usr/bin" + }, + { + "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": "1008", + "name": "/usr/standalone/firmware/iBridge1_1Customer.bundle/..." + }, + ... + ] @@ -113,18 +112,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, aix, freebsd diff --git a/docs/parsers/env.md b/docs/parsers/env.md index 0df07cbe..e9d0434e 100644 --- a/docs/parsers/env.md +++ b/docs/parsers/env.md @@ -12,71 +12,70 @@ function. Usage (cli): -$ env | jc --env + $ env | jc --env -or + or -$ jc env + $ jc env Usage (module): -import jc -result = jc.parse('env', env_command_output) + import jc + result = jc.parse('env', env_command_output) -or + or -import jc.parsers.env -result = jc.parsers.env.parse(env_command_output) + import jc.parsers.env + result = jc.parsers.env.parse(env_command_output) Schema: -[ -{ -"name": string, -"value": string -} -] + [ + { + "name": string, + "value": string + } + ] -**Examples**: +Examples: - - $ env | jc --env -p - [ - { -- `"name"` - "XDG_SESSION_ID", -- `"value"` - "1" - }, - { -- `"name"` - "HOSTNAME", -- `"value"` - "localhost.localdomain" - }, - { -- `"name"` - "TERM", -- `"value"` - "vt220" - }, - { -- `"name"` - "SHELL", -- `"value"` - "/bin/bash" - }, - { -- `"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" - } + $ env | jc --env -p + [ + { + "name": "XDG_SESSION_ID", + "value": "1" + }, + { + "name": "HOSTNAME", + "value": "localhost.localdomain" + }, + { + "name": "TERM", + "value": "vt220" + }, + { + "name": "SHELL", + "value": "/bin/bash" + }, + { + "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" + } @@ -98,19 +97,16 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary of raw structured data or - List of Dictionaries of processed structured data + Dictionary of raw structured data or + List of Dictionaries of processed structured data ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/file.md b/docs/parsers/file.md index f493fc4d..5f1c7a44 100644 --- a/docs/parsers/file.md +++ b/docs/parsers/file.md @@ -7,66 +7,65 @@ jc - JSON CLI output utility `file` command output parser Usage (cli): -$ file * | jc --file + $ file * | jc --file -or + or -$ jc file * + $ jc file * Usage (module): -import jc -result = jc.parse('file', file_command_output) + import jc + result = jc.parse('file', file_command_output) -or + or -import jc.parsers.file -result = jc.parsers.file.parse(file_command_output) + import jc.parsers.file + result = jc.parsers.file.parse(file_command_output) Schema: -[ -{ -"filename": string, -"type": string -} -] + [ + { + "filename": string, + "type": string + } + ] -**Examples**: +Examples: - - $ file * | jc --file -p - [ - { -- `"filename"` - "Applications", -- `"type"` - "directory" - }, - { -- `"filename"` - "another file with spaces", -- `"type"` - "empty" - }, - { -- `"filename"` - "argstest.py", -- `"type"` - "Python script text executable, ASCII text" - }, - { -- `"filename"` - "blkid-p.out", -- `"type"` - "ASCII text" - }, - { -- `"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"` - "centosserial.sh", -- `"type"` - "Bourne-Again shell script text executable, UTF-8 ..." - }, - ... - ] + $ file * | jc --file -p + [ + { + "filename": "Applications", + "type": "directory" + }, + { + "filename": "another file with spaces", + "type": "empty" + }, + { + "filename": "argstest.py", + "type": "Python script text executable, ASCII text" + }, + { + "filename": "blkid-p.out", + "type": "ASCII text" + }, + { + "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": "centosserial.sh", + "type": "Bourne-Again shell script text executable, UTF-8 ..." + }, + ... + ] @@ -88,18 +87,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, aix, freebsd, darwin diff --git a/docs/parsers/finger.md b/docs/parsers/finger.md index 93d47855..25c1f0ac 100644 --- a/docs/parsers/finger.md +++ b/docs/parsers/finger.md @@ -9,92 +9,91 @@ Supports `-s` output option. Does not support the `-l` detail option. Usage (cli): -$ finger | jc --finger + $ finger | jc --finger -or + or -$ jc finger + $ jc finger Usage (module): -import jc -result = jc.parse('finger', finger_command_output) + import jc + result = jc.parse('finger', finger_command_output) -or + or -import jc.parsers.finger -result = jc.parsers.finger.parse(finger_command_output) + import jc.parsers.finger + result = jc.parsers.finger.parse(finger_command_output) Schema: -[ -{ -"login": string, -"name": string, -"tty": string, -"idle": string, # null if empty -"login_time": string, -"details": string, -"tty_writeable": boolean, -"idle_minutes": integer, -"idle_hours": integer, -"idle_days": integer, -"total_idle_minutes": integer -} -] + [ + { + "login": string, + "name": string, + "tty": string, + "idle": string, # null if empty + "login_time": string, + "details": string, + "tty_writeable": boolean, + "idle_minutes": integer, + "idle_hours": integer, + "idle_days": integer, + "total_idle_minutes": integer + } + ] -**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"` - "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 - }, - ... - ] - - $ 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"` - "pts/0", -- `"idle"` - null, -- `"login_time"` - "Apr 5 15:33", -- `"details"` - "(192.168.1.22)" - }, - ... - ] + $ 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": "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 + }, + ... + ] + + $ 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": "pts/0", + "idle": null, + "login_time": "Apr 5 15:33", + "details": "(192.168.1.22)" + }, + ... + ] @@ -116,18 +115,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, freebsd diff --git a/docs/parsers/free.md b/docs/parsers/free.md index 210fc273..6fd877e0 100644 --- a/docs/parsers/free.md +++ b/docs/parsers/free.md @@ -7,76 +7,75 @@ jc - JSON CLI output utility `free` command output parser Usage (cli): -$ free | jc --free + $ free | jc --free -or + or -$ jc free + $ jc free Usage (module): -import jc -result = jc.parse('free', free_command_output) + import jc + result = jc.parse('free', free_command_output) -or + or -import jc.parsers.free -result = jc.parsers.free.parse(free_command_output) + import jc.parsers.free + result = jc.parsers.free.parse(free_command_output) Schema: -[ -{ -"type": string, -"total": integer, -"used": integer, -"free": integer, -"shared": integer, -"buff_cache": integer, -"available": integer -} -] + [ + { + "type": string, + "total": integer, + "used": integer, + "free": integer, + "shared": integer, + "buff_cache": integer, + "available": integer + } + ] -**Examples**: +Examples: - - $ free | jc --free -p - [ - { -- `"type"` - "Mem", -- `"total"` - 3861340, -- `"used"` - 220508, -- `"free"` - 3381972, -- `"shared"` - 11800, -- `"buff_cache"` - 258860, -- `"available"` - 3397784 - }, - { -- `"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"` - "Swap", -- `"total"` - "2097148", -- `"used"` - "0", -- `"free"` - "2097148" - } - ] + $ free | jc --free -p + [ + { + "type": "Mem", + "total": 3861340, + "used": 220508, + "free": 3381972, + "shared": 11800, + "buff_cache": 258860, + "available": 3397784 + }, + { + "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": "Swap", + "total": "2097148", + "used": "0", + "free": "2097148" + } + ] @@ -98,18 +97,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/fstab.md b/docs/parsers/fstab.md index cb3d67f5..4900e758 100644 --- a/docs/parsers/fstab.md +++ b/docs/parsers/fstab.md @@ -7,89 +7,88 @@ jc - JSON CLI output utility `fstab` file parser Usage (cli): -$ cat /etc/fstab | jc --fstab + $ cat /etc/fstab | jc --fstab Usage (module): -import jc -result = jc.parse('fstab', fstab_command_output) + import jc + result = jc.parse('fstab', fstab_command_output) -or + or -import jc.parsers.fstab -result = jc.parsers.fstab.parse(fstab_command_output) + import jc.parsers.fstab + result = jc.parsers.fstab.parse(fstab_command_output) Schema: -[ -{ -"fs_spec": string, -"fs_file": string, -"fs_vfstype": string, -"fs_mntops": string, -"fs_freq": integer, -"fs_passno": integer -} -] + [ + { + "fs_spec": string, + "fs_file": string, + "fs_vfstype": string, + "fs_mntops": string, + "fs_freq": integer, + "fs_passno": integer + } + ] -**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"` - "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 - } - ] - - $ 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"` - "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" - } - ] + $ 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": "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 + } + ] + + $ 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": "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" + } + ] @@ -111,18 +110,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, freebsd diff --git a/docs/parsers/group.md b/docs/parsers/group.md index 86cf33cf..afbdd357 100644 --- a/docs/parsers/group.md +++ b/docs/parsers/group.md @@ -7,113 +7,112 @@ jc - JSON CLI output utility `/etc/group` file parser Usage (cli): -$ cat /etc/group | jc --group + $ cat /etc/group | jc --group Usage (module): -import jc -result = jc.parse('group', group_file_output) + import jc + result = jc.parse('group', group_file_output) -or + or -import jc.parsers.group -result = jc.parsers.group.parse(group_file_output) + import jc.parsers.group + result = jc.parsers.group.parse(group_file_output) Schema: -[ -{ -"group_name": string, -"password": string, -"gid": integer, -"members": [ -string -] -} -] + [ + { + "group_name": string, + "password": string, + "gid": integer, + "members": [ + string + ] + } + ] -**Examples**: +Examples: - - $ cat /etc/group | jc --group -p - [ - { -- `"group_name"` - "nobody", -- `"password"` - "*", -- `"gid"` - -2, -- `"members"` - [] - }, - { -- `"group_name"` - "nogroup", -- `"password"` - "*", -- `"gid"` - -1, -- `"members"` - [] - }, - { -- `"group_name"` - "wheel", -- `"password"` - "*", -- `"gid"` - 0, -- `"members"` - [ - "root" - ] - }, - { -- `"group_name"` - "certusers", -- `"password"` - "*", -- `"gid"` - 29, -- `"members"` - [ - "root", - "_jabber", - "_postfix", - "_cyrus", - "_calendar", - "_dovecot" - ] - }, - ... - ] - - $ cat /etc/group | jc --group -p -r - [ - { -- `"group_name"` - "nobody", -- `"password"` - "*", -- `"gid"` - "-2", -- `"members"` - [ - "" - ] - }, - { -- `"group_name"` - "nogroup", -- `"password"` - "*", -- `"gid"` - "-1", -- `"members"` - [ - "" - ] - }, - { -- `"group_name"` - "wheel", -- `"password"` - "*", -- `"gid"` - "0", -- `"members"` - [ - "root" - ] - }, - { -- `"group_name"` - "certusers", -- `"password"` - "*", -- `"gid"` - "29", -- `"members"` - [ - "root", - "_jabber", - "_postfix", - "_cyrus", - "_calendar", - "_dovecot" - ] - }, - ... - ] + $ cat /etc/group | jc --group -p + [ + { + "group_name": "nobody", + "password": "*", + "gid": -2, + "members": [] + }, + { + "group_name": "nogroup", + "password": "*", + "gid": -1, + "members": [] + }, + { + "group_name": "wheel", + "password": "*", + "gid": 0, + "members": [ + "root" + ] + }, + { + "group_name": "certusers", + "password": "*", + "gid": 29, + "members": [ + "root", + "_jabber", + "_postfix", + "_cyrus", + "_calendar", + "_dovecot" + ] + }, + ... + ] + + $ cat /etc/group | jc --group -p -r + [ + { + "group_name": "nobody", + "password": "*", + "gid": "-2", + "members": [ + "" + ] + }, + { + "group_name": "nogroup", + "password": "*", + "gid": "-1", + "members": [ + "" + ] + }, + { + "group_name": "wheel", + "password": "*", + "gid": "0", + "members": [ + "root" + ] + }, + { + "group_name": "certusers", + "password": "*", + "gid": "29", + "members": [ + "root", + "_jabber", + "_postfix", + "_cyrus", + "_calendar", + "_dovecot" + ] + }, + ... + ] @@ -135,18 +134,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, aix, freebsd diff --git a/docs/parsers/gshadow.md b/docs/parsers/gshadow.md index 5768a486..77dadde3 100644 --- a/docs/parsers/gshadow.md +++ b/docs/parsers/gshadow.md @@ -7,81 +7,80 @@ jc - JSON CLI output utility `/etc/gshadow` file parser Usage (cli): -$ cat /etc/gshadow | jc --gshadow + $ cat /etc/gshadow | jc --gshadow Usage (module): -import jc -result = jc.parse('gshadow', gshadow_file_output) + import jc + result = jc.parse('gshadow', gshadow_file_output) -or + or -import jc.parsers.gshadow -result = jc.parsers.gshadow.parse(gshadow_file_output) + import jc.parsers.gshadow + result = jc.parsers.gshadow.parse(gshadow_file_output) Schema: -[ -{ -"group_name": string, -"password": string, -"administrators": [ -string -], -"members": [ -string -] -} -] + [ + { + "group_name": string, + "password": string, + "administrators": [ + string + ], + "members": [ + string + ] + } + ] -**Examples**: +Examples: - - $ cat /etc/gshadow | jc --gshadow -p - [ - { -- `"group_name"` - "root", -- `"password"` - "*", -- `"administrators"` - [], -- `"members"` - [] - }, - { -- `"group_name"` - "adm", -- `"password"` - "*", -- `"administrators"` - [], -- `"members"` - [ - "syslog", - "joeuser" - ] - }, - ... - ] - - $ cat /etc/gshadow | jc --gshadow -p -r - [ - { -- `"group_name"` - "root", -- `"password"` - "*", -- `"administrators"` - [ - "" - ], -- `"members"` - [ - "" - ] - }, - { -- `"group_name"` - "adm", -- `"password"` - "*", -- `"administrators"` - [ - "" - ], -- `"members"` - [ - "syslog", - "joeuser" - ] - }, - ... - ] + $ cat /etc/gshadow | jc --gshadow -p + [ + { + "group_name": "root", + "password": "*", + "administrators": [], + "members": [] + }, + { + "group_name": "adm", + "password": "*", + "administrators": [], + "members": [ + "syslog", + "joeuser" + ] + }, + ... + ] + + $ cat /etc/gshadow | jc --gshadow -p -r + [ + { + "group_name": "root", + "password": "*", + "administrators": [ + "" + ], + "members": [ + "" + ] + }, + { + "group_name": "adm", + "password": "*", + "administrators": [ + "" + ], + "members": [ + "syslog", + "joeuser" + ] + }, + ... + ] @@ -103,18 +102,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, aix, freebsd diff --git a/docs/parsers/hash.md b/docs/parsers/hash.md index 44d0e02c..bba97fa5 100644 --- a/docs/parsers/hash.md +++ b/docs/parsers/hash.md @@ -7,41 +7,40 @@ jc - JSON CLI output utility `hash` command output parser Usage (cli): -$ hash | jc --hash + $ hash | jc --hash Usage (module): -import jc -result = jc.parse('hash', hash_command_output) + import jc + result = jc.parse('hash', hash_command_output) -or + or -import jc.parsers.hash -result = jc.parsers.hash.parse(hash_command_output) + import jc.parsers.hash + result = jc.parsers.hash.parse(hash_command_output) Schema: -[ -{ -"command": string, -"hits": integer -} -] + [ + { + "command": string, + "hits": integer + } + ] -**Examples**: +Examples: - - $ hash | jc --hash -p - [ - { -- `"hits"` - 2, -- `"command"` - "/bin/cat" - }, - { -- `"hits"` - 1, -- `"command"` - "/bin/ls" - } - ] + $ hash | jc --hash -p + [ + { + "hits": 2, + "command": "/bin/cat" + }, + { + "hits": 1, + "command": "/bin/ls" + } + ] @@ -63,18 +62,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/hashsum.md b/docs/parsers/hashsum.md index eb1603fd..dcd2dc21 100644 --- a/docs/parsers/hashsum.md +++ b/docs/parsers/hashsum.md @@ -17,62 +17,61 @@ This parser works with the following hash calculation utilities: Usage (cli): -$ md5sum file.txt | jc --hashsum + $ md5sum file.txt | jc --hashsum -or + or -$ jc md5sum file.txt + $ jc md5sum file.txt Usage (module): -import jc -result = jc.parse('hashsum', md5sum_command_output) + import jc + result = jc.parse('hashsum', md5sum_command_output) -or + or -import jc.parsers.hashsum -result = jc.parsers.hashsum.parse(md5sum_command_output) + import jc.parsers.hashsum + result = jc.parsers.hashsum.parse(md5sum_command_output) Schema: -[ -{ -"filename": string, -"hash": string, -} -] + [ + { + "filename": string, + "hash": string, + } + ] -**Examples**: +Examples: - - $ md5sum * | jc --hashsum -p - [ - { -- `"filename"` - "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", -- `"hash"` - "65fc958c1add637ec23c4b137aecf3d3" - }, - { -- `"filename"` - "digout", -- `"hash"` - "5b9312ee5aff080927753c63a347707d" - }, - { -- `"filename"` - "dmidecode.out", -- `"hash"` - "716fd11c2ac00db109281f7110b8fb9d" - }, - { -- `"filename"` - "file with spaces in the name", -- `"hash"` - "d41d8cd98f00b204e9800998ecf8427e" - }, - { -- `"filename"` - "id-centos.out", -- `"hash"` - "4295be239a14ad77ef3253103de976d2" - }, - { -- `"filename"` - "ifcfg.json", -- `"hash"` - "01fda0d9ba9a75618b072e64ff512b43" - }, - ... - ] + $ md5sum * | jc --hashsum -p + [ + { + "filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm", + "hash": "65fc958c1add637ec23c4b137aecf3d3" + }, + { + "filename": "digout", + "hash": "5b9312ee5aff080927753c63a347707d" + }, + { + "filename": "dmidecode.out", + "hash": "716fd11c2ac00db109281f7110b8fb9d" + }, + { + "filename": "file with spaces in the name", + "hash": "d41d8cd98f00b204e9800998ecf8427e" + }, + { + "filename": "id-centos.out", + "hash": "4295be239a14ad77ef3253103de976d2" + }, + { + "filename": "ifcfg.json", + "hash": "01fda0d9ba9a75618b072e64ff512b43" + }, + ... + ] @@ -94,18 +93,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/hciconfig.md b/docs/parsers/hciconfig.md index 4fbb5c33..f68ed05e 100644 --- a/docs/parsers/hciconfig.md +++ b/docs/parsers/hciconfig.md @@ -7,321 +7,320 @@ jc - JSON CLI output utility `hciconfig` command output parser Usage (cli): -$ hciconfig | jc --hciconfig + $ hciconfig | jc --hciconfig -or + or -$ jc hciconfig + $ jc hciconfig Usage (module): -import jc -result = jc.parse('hciconfig', hciconfig_command_output) + import jc + result = jc.parse('hciconfig', hciconfig_command_output) -or + or -import jc.parsers.hciconfig -result = jc.parsers.hciconfig.parse(hciconfig_command_output) + import jc.parsers.hciconfig + result = jc.parsers.hciconfig.parse(hciconfig_command_output) Schema: -[ -{ -"device": string, -"type": string, -"bus": string, -"bd_address": string, -"acl_mtu": integer, -"acl_mtu_packets": integer, -"sco_mtu": integer, -"sco_mtu_packets": integer, -"state": [ -string -], -"rx_bytes": integer, -"rx_acl": integer, -"rx_sco": integer, -"rx_events": integer, -"rx_errors": integer, -"tx_bytes": integer, -"tx_acl": integer, -"tx_sco": integer, -"tx_commands": integer, -"tx_errors": integer, -"features": [ -string -], -"packet_type": [ -string -], -"link_policy": [ -string -], -"link_mode": [ -string -], -"name": string, -"class": string, -"service_classes": [ -string # 'Unspecified' is null -], -"device_class": string, -"hci_version": string, -"hci_revision": string, -"lmp_version": string, -"lmp_subversion": string, -"manufacturer": string -} -] + [ + { + "device": string, + "type": string, + "bus": string, + "bd_address": string, + "acl_mtu": integer, + "acl_mtu_packets": integer, + "sco_mtu": integer, + "sco_mtu_packets": integer, + "state": [ + string + ], + "rx_bytes": integer, + "rx_acl": integer, + "rx_sco": integer, + "rx_events": integer, + "rx_errors": integer, + "tx_bytes": integer, + "tx_acl": integer, + "tx_sco": integer, + "tx_commands": integer, + "tx_errors": integer, + "features": [ + string + ], + "packet_type": [ + string + ], + "link_policy": [ + string + ], + "link_mode": [ + string + ], + "name": string, + "class": string, + "service_classes": [ + string # 'Unspecified' is null + ], + "device_class": string, + "hci_version": string, + "hci_revision": string, + "lmp_version": string, + "lmp_subversion": string, + "manufacturer": string + } + ] -**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"` - [ - "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"` - [ - "0xff", - "0xff", - "0x8f", - "0xfe", - "0xdb", - "0xff", - "0x5b", - "0x87" - ], -- `"packet_type"` - [ - "DM1", - "DM3", - "DM5", - "DH1", - "DH3", - "DH5", - "HV1", - "HV2", - "HV3" - ], -- `"link_policy"` - [ - "RSWITCH", - "HOLD", - "SNIFF", - "PARK" - ], -- `"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)" - }, - { -- `"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"` - [ - "0xff", - "0xff", - "0x8f", - "0xfe", - "0xdb", - "0xff", - "0x5b", - "0x87" - ], -- `"packet_type"` - [ - "DM1", - "DM3", - "DM5", - "DH1", - "DH3", - "DH5", - "HV1", - "HV2", - "HV3" - ], -- `"link_policy"` - [ - "RSWITCH", - "HOLD", - "SNIFF", - "PARK" - ], -- `"link_mode"` - [ - "SLAVE", - "ACCEPT" - ] - } - ] - - $ 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"` - [ - "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"` - [ - "0xff", - "0xff", - "0x8f", - "0xfe", - "0xdb", - "0xff", - "0x5b", - "0x87" - ], -- `"packet_type"` - [ - "DM1", - "DM3", - "DM5", - "DH1", - "DH3", - "DH5", - "HV1", - "HV2", - "HV3" - ], -- `"link_policy"` - [ - "RSWITCH", - "HOLD", - "SNIFF", - "PARK" - ], -- `"link_mode"` - [ - "SLAVE", - "ACCEPT" - ], -- `"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"` - "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"` - [ - "0xff", - "0xff", - "0x8f", - "0xfe", - "0xdb", - "0xff", - "0x5b", - "0x87" - ], -- `"packet_type"` - [ - "DM1", - "DM3", - "DM5", - "DH1", - "DH3", - "DH5", - "HV1", - "HV2", - "HV3" - ], -- `"link_policy"` - [ - "RSWITCH", - "HOLD", - "SNIFF", - "PARK" - ], -- `"link_mode"` - [ - "SLAVE", - "ACCEPT" - ] - } - ] + $ 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": [ + "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": [ + "0xff", + "0xff", + "0x8f", + "0xfe", + "0xdb", + "0xff", + "0x5b", + "0x87" + ], + "packet_type": [ + "DM1", + "DM3", + "DM5", + "DH1", + "DH3", + "DH5", + "HV1", + "HV2", + "HV3" + ], + "link_policy": [ + "RSWITCH", + "HOLD", + "SNIFF", + "PARK" + ], + "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)" + }, + { + "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": [ + "0xff", + "0xff", + "0x8f", + "0xfe", + "0xdb", + "0xff", + "0x5b", + "0x87" + ], + "packet_type": [ + "DM1", + "DM3", + "DM5", + "DH1", + "DH3", + "DH5", + "HV1", + "HV2", + "HV3" + ], + "link_policy": [ + "RSWITCH", + "HOLD", + "SNIFF", + "PARK" + ], + "link_mode": [ + "SLAVE", + "ACCEPT" + ] + } + ] + + $ 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": [ + "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": [ + "0xff", + "0xff", + "0x8f", + "0xfe", + "0xdb", + "0xff", + "0x5b", + "0x87" + ], + "packet_type": [ + "DM1", + "DM3", + "DM5", + "DH1", + "DH3", + "DH5", + "HV1", + "HV2", + "HV3" + ], + "link_policy": [ + "RSWITCH", + "HOLD", + "SNIFF", + "PARK" + ], + "link_mode": [ + "SLAVE", + "ACCEPT" + ], + "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": "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": [ + "0xff", + "0xff", + "0x8f", + "0xfe", + "0xdb", + "0xff", + "0x5b", + "0x87" + ], + "packet_type": [ + "DM1", + "DM3", + "DM5", + "DH1", + "DH3", + "DH5", + "HV1", + "HV2", + "HV3" + ], + "link_policy": [ + "RSWITCH", + "HOLD", + "SNIFF", + "PARK" + ], + "link_mode": [ + "SLAVE", + "ACCEPT" + ] + } + ] @@ -343,18 +342,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/history.md b/docs/parsers/history.md index f50dea3f..b6ce7c27 100644 --- a/docs/parsers/history.md +++ b/docs/parsers/history.md @@ -15,59 +15,58 @@ builtin. Usage (cli): -$ history | jc --history + $ history | jc --history Usage (module): -import jc -result = jc.parse('history', history_command_output) + import jc + result = jc.parse('history', history_command_output) -or + or -import jc.parsers.history -result = jc.parsers.history.parse(history_command_output) + import jc.parsers.history + result = jc.parsers.history.parse(history_command_output) Schema: -[ -{ -"line": integer, -"command": string -} -] + [ + { + "line": integer, + "command": string + } + ] -**Examples**: +Examples: - - $ history | jc --history -p - [ - { -- `"line"` - 118, -- `"command"` - "sleep 100" - }, - { -- `"line"` - 119, -- `"command"` - "ls /bin" - }, - { -- `"line"` - 120, -- `"command"` - "echo \"hello\"" - }, - { -- `"line"` - 121, -- `"command"` - "docker images" - }, - ... - ] - - $ history | jc --history -p -r - { -- `"118"` - "sleep 100", -- `"119"` - "ls /bin", -- `"120"` - "echo \"hello\"", -- `"121"` - "docker images", - ... - } + $ history | jc --history -p + [ + { + "line": 118, + "command": "sleep 100" + }, + { + "line": 119, + "command": "ls /bin" + }, + { + "line": 120, + "command": "echo \"hello\"" + }, + { + "line": 121, + "command": "docker images" + }, + ... + ] + + $ history | jc --history -p -r + { + "118": "sleep 100", + "119": "ls /bin", + "120": "echo \"hello\"", + "121": "docker images", + ... + } @@ -89,19 +88,16 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary of raw structured data or - List of Dictionaries of processed structured data + Dictionary of raw structured data or + List of Dictionaries of processed structured data ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/hosts.md b/docs/parsers/hosts.md index a873ebad..8d4bb20f 100644 --- a/docs/parsers/hosts.md +++ b/docs/parsers/hosts.md @@ -7,78 +7,77 @@ jc - JSON CLI output utility `/etc/hosts` file parser Usage (cli): -$ cat /etc/hosts | jc --hosts + $ cat /etc/hosts | jc --hosts Usage (module): -import jc -result = jc.parse('hosts', hosts_file_output) + import jc + result = jc.parse('hosts', hosts_file_output) -or + or -import jc.parsers.hosts -result = jc.parsers.hosts.parse(hosts_file_output) + import jc.parsers.hosts + result = jc.parsers.hosts.parse(hosts_file_output) Schema: -[ -{ -"ip": string, -"hostname": [ -string -] -} -] + [ + { + "ip": string, + "hostname": [ + string + ] + } + ] -**Examples**: +Examples: - - $ cat /etc/hosts | jc --hosts -p - [ - { -- `"ip"` - "127.0.0.1", -- `"hostname"` - [ - "localhost" - ] - }, - { -- `"ip"` - "127.0.1.1", -- `"hostname"` - [ - "root-ubuntu" - ] - }, - { -- `"ip"` - "::1", -- `"hostname"` - [ - "ip6-localhost", - "ip6-loopback" - ] - }, - { -- `"ip"` - "fe00::0", -- `"hostname"` - [ - "ip6-localnet" - ] - }, - { -- `"ip"` - "ff00::0", -- `"hostname"` - [ - "ip6-mcastprefix" - ] - }, - { -- `"ip"` - "ff02::1", -- `"hostname"` - [ - "ip6-allnodes" - ] - }, - { -- `"ip"` - "ff02::2", -- `"hostname"` - [ - "ip6-allrouters" - ] - } - ] + $ cat /etc/hosts | jc --hosts -p + [ + { + "ip": "127.0.0.1", + "hostname": [ + "localhost" + ] + }, + { + "ip": "127.0.1.1", + "hostname": [ + "root-ubuntu" + ] + }, + { + "ip": "::1", + "hostname": [ + "ip6-localhost", + "ip6-loopback" + ] + }, + { + "ip": "fe00::0", + "hostname": [ + "ip6-localnet" + ] + }, + { + "ip": "ff00::0", + "hostname": [ + "ip6-mcastprefix" + ] + }, + { + "ip": "ff02::1", + "hostname": [ + "ip6-allnodes" + ] + }, + { + "ip": "ff02::2", + "hostname": [ + "ip6-allrouters" + ] + } + ] @@ -100,18 +99,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/id.md b/docs/parsers/id.md index 75a95179..303f4c32 100644 --- a/docs/parsers/id.md +++ b/docs/parsers/id.md @@ -7,109 +7,108 @@ jc - JSON CLI output utility `id` command output parser Usage (cli): -$ id | jc --id + $ id | jc --id -or + or -$ jc id + $ jc id Usage (module): -import jc -result = jc.parse('id', id_command_output) + import jc + result = jc.parse('id', id_command_output) -or + or -import jc.parsers.id -result = jc.parsers.id.parse(id_command_output) + import jc.parsers.id + result = jc.parsers.id.parse(id_command_output) Schema: -{ -"uid": { -"id": integer, -"name": string -}, -"gid": { -"id": integer, -"name": string -}, -"groups": [ -{ -"id": integer, -"name": string -}, -{ -"id": integer, -"name": string -} -], -"context": { -"user": string, -"role": string, -"type": string, -"level": string -} -} + { + "uid": { + "id": integer, + "name": string + }, + "gid": { + "id": integer, + "name": string + }, + "groups": [ + { + "id": integer, + "name": string + }, + { + "id": integer, + "name": string + } + ], + "context": { + "user": string, + "role": string, + "type": string, + "level": string + } + } -**Examples**: +Examples: - - $ id | jc --id -p - { -- `"uid"` - { -- `"id"` - 1000, -- `"name"` - "joeuser" - }, -- `"gid"` - { -- `"id"` - 1000, -- `"name"` - "joeuser" - }, -- `"groups"` - [ - { -- `"id"` - 1000, -- `"name"` - "joeuser" - }, - { -- `"id"` - 10, -- `"name"` - "wheel" - } - ], -- `"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" - }, -- `"gid"` - { -- `"id"` - "1000", -- `"name"` - "joeuser" - }, -- `"groups"` - [ - { -- `"id"` - "1000", -- `"name"` - "joeuser" - }, - { -- `"id"` - "10", -- `"name"` - "wheel" - } - ], -- `"context"` - { -- `"user"` - "unconfined_u", -- `"role"` - "unconfined_r", -- `"type"` - "unconfined_t", -- `"level"` - "s0-s0:c0.c1023" - } - } + $ id | jc --id -p + { + "uid": { + "id": 1000, + "name": "joeuser" + }, + "gid": { + "id": 1000, + "name": "joeuser" + }, + "groups": [ + { + "id": 1000, + "name": "joeuser" + }, + { + "id": 10, + "name": "wheel" + } + ], + "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" + }, + "gid": { + "id": "1000", + "name": "joeuser" + }, + "groups": [ + { + "id": "1000", + "name": "joeuser" + }, + { + "id": "10", + "name": "wheel" + } + ], + "context": { + "user": "unconfined_u", + "role": "unconfined_r", + "type": "unconfined_t", + "level": "s0-s0:c0.c1023" + } + } @@ -131,18 +130,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, aix, freebsd diff --git a/docs/parsers/ifconfig.md b/docs/parsers/ifconfig.md index 933e6492..c5ac5e03 100644 --- a/docs/parsers/ifconfig.md +++ b/docs/parsers/ifconfig.md @@ -9,188 +9,187 @@ Note: No `ifconfig` options are supported. Usage (cli): -$ ifconfig | jc --ifconfig + $ ifconfig | jc --ifconfig -or + or -$ jc ifconfig + $ jc ifconfig Usage (module): -import jc -result = jc.parse('ifconfig', ifconfig_command_output) + import jc + result = jc.parse('ifconfig', ifconfig_command_output) -or + or -import jc.parsers.ifconfig -result = jc.parsers.ifconfig.parse(ifconfig_command_output) + import jc.parsers.ifconfig + result = jc.parsers.ifconfig.parse(ifconfig_command_output) Schema: -[ -{ -"name": string, -"flags": integer, -"state": [ -string -], -"mtu": integer, -"ipv4_addr": string, -"ipv4_mask": string, -"ipv4_bcast": string, -"ipv6_addr": string, -"ipv6_mask": integer, -"ipv6_scope": string, -"mac_addr": string, -"type": string, -"rx_packets": integer, -"rx_bytes": integer, -"rx_errors": integer, -"rx_dropped": integer, -"rx_overruns": integer, -"rx_frame": integer, -"tx_packets": integer, -"tx_bytes": integer, -"tx_errors": integer, -"tx_dropped": integer, -"tx_overruns": integer, -"tx_carrier": integer, -"tx_collisions": integer, -"metric": integer -} -] + [ + { + "name": string, + "flags": integer, + "state": [ + string + ], + "mtu": integer, + "ipv4_addr": string, + "ipv4_mask": string, + "ipv4_bcast": string, + "ipv6_addr": string, + "ipv6_mask": integer, + "ipv6_scope": string, + "mac_addr": string, + "type": string, + "rx_packets": integer, + "rx_bytes": integer, + "rx_errors": integer, + "rx_dropped": integer, + "rx_overruns": integer, + "rx_frame": integer, + "tx_packets": integer, + "tx_bytes": integer, + "tx_errors": integer, + "tx_dropped": integer, + "tx_overruns": integer, + "tx_carrier": integer, + "tx_collisions": integer, + "metric": integer + } + ] -**Examples**: +Examples: - - $ ifconfig | jc --ifconfig -p - [ - { -- `"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 - } - ] - - $ 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"` - "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 - } - ] + $ ifconfig | jc --ifconfig -p + [ + { + "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 + } + ] + + $ 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": "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 + } + ] @@ -220,9 +219,7 @@ ifconfig parser module written by threeheadedknight@protonmail.com def __init__(console_output) ``` -**Arguments**: - -- `console_output`: +:param console_output: @@ -232,6 +229,8 @@ def __init__(console_output) def list_interfaces() ``` +:return: + #### count\_interfaces @@ -240,6 +239,8 @@ def list_interfaces() def count_interfaces() ``` +:return: + #### filter\_interfaces @@ -248,9 +249,8 @@ def count_interfaces() def filter_interfaces(**kwargs) ``` -**Arguments**: - -- `kwargs`: +:param kwargs: +:return: @@ -260,9 +260,8 @@ def filter_interfaces(**kwargs) def get_interface(name) ``` -**Arguments**: - -- `name`: +:param name: +:return: @@ -272,6 +271,8 @@ def get_interface(name) def get_interfaces() ``` +:return: + #### is\_available @@ -280,9 +281,8 @@ def get_interfaces() def is_available(name) ``` -**Arguments**: - -- `name`: +:param name: +:return: @@ -292,9 +292,8 @@ def is_available(name) def parser(source_data) ``` -**Arguments**: - -- `source_data`: +:param source_data: +:return: @@ -306,18 +305,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, aix, freebsd, darwin diff --git a/docs/parsers/ini.md b/docs/parsers/ini.md index 5e8d1bde..0132f96e 100644 --- a/docs/parsers/ini.md +++ b/docs/parsers/ini.md @@ -15,62 +15,61 @@ command-line argument or the `raw=True` argument in `parse()`. Usage (cli): -$ cat foo.ini | jc --ini + $ cat foo.ini | jc --ini Usage (module): -import jc -result = jc.parse('ini', ini_file_output) + import jc + result = jc.parse('ini', ini_file_output) -or + or -import jc.parsers.ini -result = jc.parsers.ini.parse(ini_file_output) + import jc.parsers.ini + result = jc.parsers.ini.parse(ini_file_output) Schema: -ini or key/value document converted to a dictionary - see the -configparser standard library documentation for more details. + ini or key/value document converted to a dictionary - see the + configparser standard library documentation for more details. -{ -"key1": string, -"key2": string -} + { + "key1": string, + "key2": string + } -**Examples**: +Examples: - - $ cat example.ini - [DEFAULT] - ServerAliveInterval = 45 - Compression = yes - CompressionLevel = 9 - ForwardX11 = yes - - [bitbucket.org] - User = hg - - [topsecret.server.com] - Port = 50022 - ForwardX11 = no - - $ cat example.ini | jc --ini -p - { -- `"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" - } - } + $ cat example.ini + [DEFAULT] + ServerAliveInterval = 45 + Compression = yes + CompressionLevel = 9 + ForwardX11 = yes + + [bitbucket.org] + User = hg + + [topsecret.server.com] + Port = 50022 + ForwardX11 = no + + $ cat example.ini | jc --ini -p + { + "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" + } + } @@ -92,18 +91,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary representing the ini file + Dictionary representing the ini file ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/iostat.md b/docs/parsers/iostat.md index 27a34b9a..44da5bb0 100644 --- a/docs/parsers/iostat.md +++ b/docs/parsers/iostat.md @@ -9,161 +9,160 @@ Note: `iostat` version 11 and higher include a JSON output option Usage (cli): -$ iostat | jc --iostat + $ iostat | jc --iostat -or + or -$ jc iostat + $ jc iostat Usage (module): -import jc -result = jc.parse('iostat', iostat_command_output) + import jc + result = jc.parse('iostat', iostat_command_output) -or + or -import jc.parsers.iostat -result = jc.parsers.iostat.parse(iostat_command_output) + import jc.parsers.iostat + result = jc.parsers.iostat.parse(iostat_command_output) Schema: -[ -{ -"type": string, -"percent_user": float, -"percent_nice": float, -"percent_system": float, -"percent_iowait": float, -"percent_steal": float, -"percent_idle": float, -"device": string, -"tps": float, -"kb_read_s": float, -"mb_read_s": float, -"kb_wrtn_s": float, -"mb_wrtn_s": float, -"kb_read": integer, -"mb_read": integer, -"kb_wrtn": integer, -"mb_wrtn": integer, -'kb_dscd': integer, -'mb_dscd': integer, -"rrqm_s": float, -"wrqm_s": float, -"r_s": float, -"w_s": float, -"rmb_s": float, -"rkb_s": float, -"wmb_s": float, -"wkb_s": float, -"avgrq_sz": float, -"avgqu_sz": float, -"await": float, -"r_await": float, -"w_await": float, -"svctm": float, -"aqu_sz": float, -"rareq_sz": float, -"wareq_sz": float, -"d_s": float, -"dkb_s": float, -"dmb_s": float, -"drqm_s": float, -"percent_drqm": float, -"d_await": float, -"dareq_sz": float, -"f_s": float, -"f_await": float, -"kb_dscd_s": float, -"mb_dscd_s": float, -"percent_util": float, -"percent_rrqm": float, -"percent_wrqm": float -} -] + [ + { + "type": string, + "percent_user": float, + "percent_nice": float, + "percent_system": float, + "percent_iowait": float, + "percent_steal": float, + "percent_idle": float, + "device": string, + "tps": float, + "kb_read_s": float, + "mb_read_s": float, + "kb_wrtn_s": float, + "mb_wrtn_s": float, + "kb_read": integer, + "mb_read": integer, + "kb_wrtn": integer, + "mb_wrtn": integer, + 'kb_dscd': integer, + 'mb_dscd': integer, + "rrqm_s": float, + "wrqm_s": float, + "r_s": float, + "w_s": float, + "rmb_s": float, + "rkb_s": float, + "wmb_s": float, + "wkb_s": float, + "avgrq_sz": float, + "avgqu_sz": float, + "await": float, + "r_await": float, + "w_await": float, + "svctm": float, + "aqu_sz": float, + "rareq_sz": float, + "wareq_sz": float, + "d_s": float, + "dkb_s": float, + "dmb_s": float, + "drqm_s": float, + "percent_drqm": float, + "d_await": float, + "dareq_sz": float, + "f_s": float, + "f_await": float, + "kb_dscd_s": float, + "mb_dscd_s": float, + "percent_util": float, + "percent_rrqm": float, + "percent_wrqm": float + } + ] -**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" - }, - { -- `"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-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" - }, - { -- `"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-1", -- `"tps"` - "0.00", -- `"kb_read_s"` - "0.08", -- `"kb_wrtn_s"` - "0.00", -- `"kb_read"` - "2204", -- `"kb_wrtn"` - "0", -- `"type"` - "device" - } - ] + $ 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" + }, + { + "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-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" + }, + { + "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-1", + "tps": "0.00", + "kb_read_s": "0.08", + "kb_wrtn_s": "0.00", + "kb_read": "2204", + "kb_wrtn": "0", + "type": "device" + } + ] @@ -185,18 +184,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/iostat_s.md b/docs/parsers/iostat_s.md index 730801bd..7f786bc5 100644 --- a/docs/parsers/iostat_s.md +++ b/docs/parsers/iostat_s.md @@ -11,100 +11,99 @@ Note: `iostat` version 11 and higher include a JSON output option Usage (cli): -$ iostat | jc --iostat-s + $ iostat | jc --iostat-s Usage (module): -import jc -# result is an iterable object (generator) -result = jc.parse('iostat_s', iostat_command_output.splitlines()) -for item in result: -# do something + import jc + # result is an iterable object (generator) + result = jc.parse('iostat_s', iostat_command_output.splitlines()) + for item in result: + # do something -or + or -import jc.parsers.iostat_s -# result is an iterable object (generator) -result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines()) -for item in result: -# do something + import jc.parsers.iostat_s + # result is an iterable object (generator) + result = jc.parsers.iostat_s.parse(iostat_command_output.splitlines()) + for item in result: + # do something Schema: -{ -"type": string, -"percent_user": float, -"percent_nice": float, -"percent_system": float, -"percent_iowait": float, -"percent_steal": float, -"percent_idle": float, -"device": string, -"tps": float, -"kb_read_s": float, -"mb_read_s": float, -"kb_wrtn_s": float, -"mb_wrtn_s": float, -"kb_read": integer, -"mb_read": integer, -"kb_wrtn": integer, -"mb_wrtn": integer, -'kb_dscd': integer, -'mb_dscd': integer, -"rrqm_s": float, -"wrqm_s": float, -"r_s": float, -"w_s": float, -"rmb_s": float, -"rkb_s": float, -"wmb_s": float, -"wkb_s": float, -"avgrq_sz": float, -"avgqu_sz": float, -"await": float, -"r_await": float, -"w_await": float, -"svctm": float, -"aqu_sz": float, -"rareq_sz": float, -"wareq_sz": float, -"d_s": float, -"dkb_s": float, -"dmb_s": float, -"drqm_s": float, -"percent_drqm": float, -"d_await": float, -"dareq_sz": float, -"f_s": float, -"f_await": float, -"kb_dscd_s": float, -"mb_dscd_s": float, -"percent_util": float, -"percent_rrqm": float, -"percent_wrqm": float, + { + "type": string, + "percent_user": float, + "percent_nice": float, + "percent_system": float, + "percent_iowait": float, + "percent_steal": float, + "percent_idle": float, + "device": string, + "tps": float, + "kb_read_s": float, + "mb_read_s": float, + "kb_wrtn_s": float, + "mb_wrtn_s": float, + "kb_read": integer, + "mb_read": integer, + "kb_wrtn": integer, + "mb_wrtn": integer, + 'kb_dscd': integer, + 'mb_dscd': integer, + "rrqm_s": float, + "wrqm_s": float, + "r_s": float, + "w_s": float, + "rmb_s": float, + "rkb_s": float, + "wmb_s": float, + "wkb_s": float, + "avgrq_sz": float, + "avgqu_sz": float, + "await": float, + "r_await": float, + "w_await": float, + "svctm": float, + "aqu_sz": float, + "rareq_sz": float, + "wareq_sz": float, + "d_s": float, + "dkb_s": float, + "dmb_s": float, + "drqm_s": float, + "percent_drqm": float, + "d_await": float, + "dareq_sz": float, + "f_s": float, + "f_await": float, + "kb_dscd_s": float, + "mb_dscd_s": float, + "percent_util": float, + "percent_rrqm": float, + "percent_wrqm": float, -# Below object only exists if using -qq or ignore_exceptions=True + # Below object only exists if using -qq or ignore_exceptions=True -"_jc_meta": -{ -"success": boolean, # false if error parsing -"error": string, # exists if "success" is false -"line": string # exists if "success" is false -} -} + "_jc_meta": + { + "success": boolean, # false if error parsing + "error": string, # exists if "success" is false + "line": string # exists if "success" is false + } + } -**Examples**: +Examples: - - $ iostat | jc --iostat-s - {"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,...} - {"device":"sda","tps":0.24,"kb_read_s":5.28,"kb_wrtn_s":1.1...} - ... - - $ iostat | jc --iostat-s -r - {"percent_user":"0.14","percent_nice":"0.00","percent_system":"0.16"...} - {"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10"...} - ... + $ iostat | jc --iostat-s + {"percent_user":0.14,"percent_nice":0.0,"percent_system":0.16,...} + {"device":"sda","tps":0.24,"kb_read_s":5.28,"kb_wrtn_s":1.1...} + ... + + $ iostat | jc --iostat-s -r + {"percent_user":"0.14","percent_nice":"0.00","percent_system":"0.16"...} + {"device":"sda","tps":"0.24","kb_read_s":"5.28","kb_wrtn_s":"1.10"...} + ... @@ -126,27 +125,22 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False) Main text parsing generator function. Returns an iterator object. -**Arguments**: +Parameters: - -- `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 - + data: (iterable) line-based text data to parse + (e.g. sys.stdin or str.splitlines()) -**Yields**: + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + ignore_exceptions: (boolean) ignore parsing exceptions if True - - Dictionary. Raw or processed structured data. - +Yields: -**Returns**: + Dictionary. Raw or processed structured data. - - Iterator object +Returns: + + Iterator object ## Parser Information Compatibility: linux diff --git a/docs/parsers/iptables.md b/docs/parsers/iptables.md index ee64a39e..67c06de3 100644 --- a/docs/parsers/iptables.md +++ b/docs/parsers/iptables.md @@ -9,165 +9,164 @@ Supports `-vLn` and `--line-numbers` for all tables. Usage (cli): -$ sudo iptables -L -t nat | jc --iptables + $ sudo iptables -L -t nat | jc --iptables -or + or -$ jc iptables -L -t nat + $ jc iptables -L -t nat Usage (module): -import jc -result = jc.parse('iptables', iptables_command_output) + import jc + result = jc.parse('iptables', iptables_command_output) -or + or -import jc.parsers.iptables -result = jc.parsers.iptables.parse(iptables_command_output) + import jc.parsers.iptables + result = jc.parsers.iptables.parse(iptables_command_output) Schema: -[ -{ -"chain": string, -"rules": [ -{ -"num" integer, -"pkts": integer, -"bytes": integer, # converted based on suffix -"target": string, -"prot": string, -"opt": string, # "--" = Null -"in": string, -"out": string, -"source": string, -"destination": string, -"options": string -} -] -} -] + [ + { + "chain": string, + "rules": [ + { + "num" integer, + "pkts": integer, + "bytes": integer, # converted based on suffix + "target": string, + "prot": string, + "opt": string, # "--" = Null + "in": string, + "out": string, + "source": string, + "destination": string, + "options": string + } + ] + } + ] -**Examples**: +Examples: - - $ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p - [ - { -- `"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"` - 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"` - 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" - } - ] - }, - ... - ] - - $ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r - [ - { -- `"chain"` - "PREROUTING", -- `"rules"` - [ - { -- `"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"` - "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" - } - ] - }, - ... - ] + $ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p + [ + { + "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": 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": 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" + } + ] + }, + ... + ] + + $ sudo iptables --line-numbers -v -L -t nat | jc --iptables -p -r + [ + { + "chain": "PREROUTING", + "rules": [ + { + "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": "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" + } + ] + }, + ... + ] @@ -189,18 +188,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/iw_scan.md b/docs/parsers/iw_scan.md index bb2be345..4e33c240 100644 --- a/docs/parsers/iw_scan.md +++ b/docs/parsers/iw_scan.md @@ -10,122 +10,121 @@ are not enough samples to test. Usage (cli): -$ iw dev wlan0 scan | jc --iw-scan + $ iw dev wlan0 scan | jc --iw-scan -or + or -$ jc iw dev wlan0 scan + $ jc iw dev wlan0 scan Usage (module): -import jc -result = jc.parse('iw_scan', iw_scan_command_output) + import jc + result = jc.parse('iw_scan', iw_scan_command_output) -or + or -import jc.parsers.iw_scan -result = jc.parsers.iw_scan.parse(iw_scan_command_output) + import jc.parsers.iw_scan + result = jc.parsers.iw_scan.parse(iw_scan_command_output) Schema: -[ -{ -"foo": string/integer/float, # best guess based on value -"bar": string/integer/float, -"baz": string/integer/float -} -] + [ + { + "foo": string/integer/float, # best guess based on value + "bar": string/integer/float, + "baz": string/integer/float + } + ] -**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"` - [ - 1.0, - 2.0, - 5.5, - 11.0, - 18.0, - 24.0, - 36.0, - 54.0 - ], -- `"erp"` - "", -- `"erp_d4.0"` - "", -- `"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"` - [ - 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 - }, - ... - ] + $ 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": [ + 1.0, + 2.0, + 5.5, + 11.0, + 18.0, + 24.0, + 36.0, + 54.0 + ], + "erp": "", + "erp_d4.0": "", + "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": [ + 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 + }, + ... + ] @@ -147,18 +146,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/jar_manifest.md b/docs/parsers/jar_manifest.md index 08efaacd..11158d88 100644 --- a/docs/parsers/jar_manifest.md +++ b/docs/parsers/jar_manifest.md @@ -7,81 +7,80 @@ jc - JSON CLI output utility `MANIFEST.MF` file parser Usage (cli): -$ cat MANIFEST.MF | jc --jar-manifest + $ cat MANIFEST.MF | jc --jar-manifest Usage (module): -import jc -result = jc.parse('jar_manifest', jar_manifest_file_output) + import jc + result = jc.parse('jar_manifest', jar_manifest_file_output) -or + or -import jc.parsers.jar_manifest -result = jc.parsers.jar_manifest.parse(jar_manifest_file_output) + import jc.parsers.jar_manifest + result = jc.parsers.jar_manifest.parse(jar_manifest_file_output) Schema: -[ -{ -"key1": string, -"key2": string -} -] + [ + { + "key1": string, + "key2": string + } + ] -**Examples**: +Examples: - - $ cat MANIFEST.MF | jc --jar-manifest -p - $ 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 | \\ - 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", - ... - } - ] - - $ 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-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", - ... - } - ... - ] + $ cat MANIFEST.MF | jc --jar-manifest -p + $ 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 | \\ + 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", + ... + } + ] + + $ 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-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", + ... + } + ... + ] @@ -103,18 +102,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/jobs.md b/docs/parsers/jobs.md index 088fb678..2218f6ed 100644 --- a/docs/parsers/jobs.md +++ b/docs/parsers/jobs.md @@ -12,92 +12,91 @@ builtin. Usage (cli): -$ jobs | jc --jobs + $ jobs | jc --jobs Usage (module): -import jc -result = jc.parse('jobs', jobs_command_output) + import jc + result = jc.parse('jobs', jobs_command_output) -or + or -import jc.parsers.jobs -result = jc.parsers.jobs.parse(jobs_command_output) + import jc.parsers.jobs + result = jc.parsers.jobs.parse(jobs_command_output) Schema: -[ -{ -"job_number": integer, -"pid": integer, -"history": string, -"status": string, -"command": string -} -] + [ + { + "job_number": integer, + "pid": integer, + "history": string, + "status": string, + "command": string + } + ] -**Example**: +Example: - - $ jobs -l | jc --jobs -p - [ - { -- `"job_number"` - 1, -- `"pid"` - 5283, -- `"status"` - "Running", -- `"command"` - "sleep 10000 &" - }, - { -- `"job_number"` - 2, -- `"pid"` - 5284, -- `"status"` - "Running", -- `"command"` - "sleep 10100 &" - }, - { -- `"job_number"` - 3, -- `"pid"` - 5285, -- `"history"` - "previous", -- `"status"` - "Running", -- `"command"` - "sleep 10001 &" - }, - { -- `"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"` - "2", -- `"pid"` - "19511", -- `"status"` - "Running", -- `"command"` - "sleep 1001 &" - }, - { -- `"job_number"` - "3", -- `"pid"` - "19512", -- `"history"` - "previous", -- `"status"` - "Running", -- `"command"` - "sleep 1002 &" - }, - { -- `"job_number"` - "4", -- `"pid"` - "19513", -- `"history"` - "current", -- `"status"` - "Running", -- `"command"` - "sleep 1003 &" - } - ] + $ jobs -l | jc --jobs -p + [ + { + "job_number": 1, + "pid": 5283, + "status": "Running", + "command": "sleep 10000 &" + }, + { + "job_number": 2, + "pid": 5284, + "status": "Running", + "command": "sleep 10100 &" + }, + { + "job_number": 3, + "pid": 5285, + "history": "previous", + "status": "Running", + "command": "sleep 10001 &" + }, + { + "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": "2", + "pid": "19511", + "status": "Running", + "command": "sleep 1001 &" + }, + { + "job_number": "3", + "pid": "19512", + "history": "previous", + "status": "Running", + "command": "sleep 1002 &" + }, + { + "job_number": "4", + "pid": "19513", + "history": "current", + "status": "Running", + "command": "sleep 1003 &" + } + ] @@ -119,18 +118,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/kv.md b/docs/parsers/kv.md index 82d53ad5..103cd555 100644 --- a/docs/parsers/kv.md +++ b/docs/parsers/kv.md @@ -15,49 +15,48 @@ command-line argument or the `raw=True` argument in `parse()`. Usage (cli): -$ cat foo.txt | jc --kv + $ cat foo.txt | jc --kv Usage (module): -import jc -result = jc.parse('kv', kv_file_output) + import jc + result = jc.parse('kv', kv_file_output) -or + or -import jc.parsers.kv -result = jc.parsers.kv.parse(kv_file_output) + import jc.parsers.kv + result = jc.parsers.kv.parse(kv_file_output) Schema: -key/value document converted to a dictionary - see the -configparser standard library documentation for more details. + key/value document converted to a dictionary - see the + configparser standard library documentation for more details. -{ -"key1": string, -"key2": string -} + { + "key1": string, + "key2": string + } -**Examples**: +Examples: - - $ cat keyvalue.txt - # this file contains key/value pairs - name = John Doe - address=555 California Drive -- `age` - 34 - ; comments can include # or ; - # delimiter can be = or : - # quoted values have quotation marks stripped by default - # but can be preserved with the -r argument - occupation:"Engineer" - - $ cat keyvalue.txt | jc --kv -p - { -- `"name"` - "John Doe", -- `"address"` - "555 California Drive", -- `"age"` - "34", -- `"occupation"` - "Engineer" - } + $ cat keyvalue.txt + # this file contains key/value pairs + name = John Doe + address=555 California Drive + age: 34 + ; comments can include # or ; + # delimiter can be = or : + # quoted values have quotation marks stripped by default + # but can be preserved with the -r argument + occupation:"Engineer" + + $ cat keyvalue.txt | jc --kv -p + { + "name": "John Doe", + "address": "555 California Drive", + "age": "34", + "occupation": "Engineer" + } @@ -79,20 +78,17 @@ def parse(data, raw=False, quiet=False) Main text parsing function -Note: this is just a wrapper for jc.parsers.ini + Note: this is just a wrapper for jc.parsers.ini -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary representing the key/value file + Dictionary representing the key/value file ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/last.md b/docs/parsers/last.md index 9163bc94..9ef52d1a 100644 --- a/docs/parsers/last.md +++ b/docs/parsers/last.md @@ -13,102 +13,101 @@ system the parser is run on) since there is no timezone information in the Usage (cli): -$ last | jc --last + $ last | jc --last -or + or -$ jc last + $ jc last Usage (module): -import jc -result = jc.parse('last', last_command_output) + import jc + result = jc.parse('last', last_command_output) -or + or -import jc.parsers.last -result = jc.parsers.last.parse(last_command_output) + import jc.parsers.last + result = jc.parsers.last.parse(last_command_output) Schema: -[ -{ -"user": string, -"tty": string, -"hostname": string, -"login": string, -"logout": string, -"duration": string, -"login_epoch": integer, # (naive) available w/last -F option -"logout_epoch": integer, # (naive) available w/last -F option -"duration_seconds": integer # available w/last -F option -} -] + [ + { + "user": string, + "tty": string, + "hostname": string, + "login": string, + "logout": string, + "duration": string, + "login_epoch": integer, # (naive) available w/last -F option + "logout_epoch": integer, # (naive) available w/last -F option + "duration_seconds": integer # available w/last -F option + } + ] -**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"` - "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 - }, - ... - ] - - $ last | jc --last -p -r - [ - { -- `"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:18", -- `"logout"` - "10:18", -- `"duration"` - "00:00" - }, - ... - ] + $ 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": "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 + }, + ... + ] + + $ last | jc --last -p -r + [ + { + "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:18", + "logout": "10:18", + "duration": "00:00" + }, + ... + ] @@ -130,18 +129,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, aix, freebsd diff --git a/docs/parsers/ls.md b/docs/parsers/ls.md index 519e4d6e..c4d5372c 100644 --- a/docs/parsers/ls.md +++ b/docs/parsers/ls.md @@ -23,104 +23,103 @@ available if the timezone field is UTC. Usage (cli): -$ ls | jc --ls + $ ls | jc --ls -or + or -$ jc ls + $ jc ls Usage (module): -import jc -result = jc.parse('ls', ls_command_output) + import jc + result = jc.parse('ls', ls_command_output) -or + or -import jc.parsers.ls -result = jc.parsers.ls.parse(ls_command_output) + import jc.parsers.ls + result = jc.parsers.ls.parse(ls_command_output) Schema: -[ -{ -"filename": string, -"flags": string, -"links": integer, -"parent": string, -"owner": string, -"group": string, -"size": integer, -"date": string, -"epoch": integer, # [0] -"epoch_utc": integer # [1] -} -] + [ + { + "filename": string, + "flags": string, + "links": integer, + "parent": string, + "owner": string, + "group": string, + "size": integer, + "date": string, + "epoch": integer, # [0] + "epoch_utc": integer # [1] + } + ] -[0] naive timestamp if date field exists and can be converted. -[1] timezone aware timestamp if date field is in UTC and can -be converted. + [0] naive timestamp if date field exists and can be converted. + [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"` - "arch" - }, - ... - ] - - $ 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"` - "ar", -- `"flags"` - "-rwxr-xr-x.", -- `"links"` - 1, -- `"owner"` - "root", -- `"group"` - "root", -- `"size"` - 62744, -- `"date"` - "Aug 8 16:14" - }, - ... - ] - - $ 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"` - "arch", -- `"flags"` - "-rwxr-xr-x.", -- `"links"` - "1", -- `"owner"` - "root", -- `"group"` - "root", -- `"size"` - "33080", -- `"date"` - "Aug 19 23:25" - }, - ... - ] + $ ls /usr/bin | jc --ls -p + [ + { + "filename": "apropos" + }, + { + "filename": "arch" + }, + ... + ] + + $ 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": "ar", + "flags": "-rwxr-xr-x.", + "links": 1, + "owner": "root", + "group": "root", + "size": 62744, + "date": "Aug 8 16:14" + }, + ... + ] + + $ 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": "arch", + "flags": "-rwxr-xr-x.", + "links": "1", + "owner": "root", + "group": "root", + "size": "33080", + "date": "Aug 19 23:25" + }, + ... + ] @@ -142,18 +141,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/ls_s.md b/docs/parsers/ls_s.md index 38cdd127..55f4b7d8 100644 --- a/docs/parsers/ls_s.md +++ b/docs/parsers/ls_s.md @@ -22,66 +22,65 @@ available if the timezone field is UTC. Usage (cli): -$ ls | jc --ls-s + $ ls | jc --ls-s Usage (module): -import jc -# result is an iterable object (generator) -result = jc.parse('ls_s', ls_command_output.splitlines()) -for item in result: -# do something + import jc + # result is an iterable object (generator) + result = jc.parse('ls_s', ls_command_output.splitlines()) + for item in result: + # do something -or + or -import jc.parsers.ls_s -# result is an iterable object (generator) -result = jc.parsers.ls_s.parse(ls_command_output.splitlines()) -for item in result: -# do something + import jc.parsers.ls_s + # result is an iterable object (generator) + result = jc.parsers.ls_s.parse(ls_command_output.splitlines()) + for item in result: + # do something Schema: -{ -"filename": string, -"flags": string, -"links": integer, -"parent": string, -"owner": string, -"group": string, -"size": integer, -"date": string, -"epoch": integer, # [0] -"epoch_utc": integer, # [1] + { + "filename": string, + "flags": string, + "links": integer, + "parent": string, + "owner": string, + "group": string, + "size": integer, + "date": string, + "epoch": integer, # [0] + "epoch_utc": integer, # [1] -# Below object only exists if using -qq or ignore_exceptions=True + # Below object only exists if using -qq or ignore_exceptions=True -"_jc_meta": -{ -"success": boolean, # false if error parsing -"error": string, # exists if "success" is false -"line": string # exists if "success" is false -} -} + "_jc_meta": + { + "success": boolean, # false if error parsing + "error": string, # exists if "success" is false + "line": string # exists if "success" is false + } + } -[0] naive timestamp if date field exists and can be converted. -[1] timezone aware timestamp if date field is in UTC and can -be converted + [0] naive timestamp if date field exists and can be converted. + [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","...} - {"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...} - {"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":1,...} - ... - - $ ls -l /usr/bin | jc --ls-s -r - {"filename":"2to3-","flags":"-rwxr-xr-x","links":"4","owner":"roo"..."} - {"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...} - {"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1...} - ... + $ ls -l /usr/bin | jc --ls-s + {"filename":"2to3-","flags":"-rwxr-xr-x","links":4,"owner":"root","...} + {"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...} + {"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":1,...} + ... + + $ ls -l /usr/bin | jc --ls-s -r + {"filename":"2to3-","flags":"-rwxr-xr-x","links":"4","owner":"roo"..."} + {"filename":"2to3-2.7","link_to":"../../System/Library/Frameworks/P...} + {"filename":"AssetCacheLocatorUtil","flags":"-rwxr-xr-x","links":"1...} + ... @@ -103,27 +102,22 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False) Main text parsing generator function. Returns an iterator object. -**Arguments**: +Parameters: - -- `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 - + data: (iterable) line-based text data to parse + (e.g. sys.stdin or str.splitlines()) -**Yields**: + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + ignore_exceptions: (boolean) ignore parsing exceptions if True - - Dictionary. Raw or processed structured data. - +Yields: -**Returns**: + Dictionary. Raw or processed structured data. - - Iterator object +Returns: + + Iterator object ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/lsblk.md b/docs/parsers/lsblk.md index bad00f88..79e255fa 100644 --- a/docs/parsers/lsblk.md +++ b/docs/parsers/lsblk.md @@ -7,278 +7,277 @@ jc - JSON CLI output utility `lsblk` command output parser Usage (cli): -$ lsblk | jc --lsblk + $ lsblk | jc --lsblk -or + or -$ jc lsblk + $ jc lsblk Usage (module): -import jc -result = jc.parse('lsblk', lsblk_command_output) + import jc + result = jc.parse('lsblk', lsblk_command_output) -or + or -import jc.parsers.lsblk -result = jc.parsers.lsblk.parse(lsblk_command_output) + import jc.parsers.lsblk + result = jc.parsers.lsblk.parse(lsblk_command_output) Schema: -[ -{ -"name": string, -"maj_min": string, -"rm": boolean, -"size": string, -"ro": boolean, -"type": string, -"mountpoint": string, -"kname": string, -"fstype": string, -"label": string, -"uuid": string, -"partlabel": string, -"partuuid": string, -"ra": integer, -"model": string, -"serial": string, -"state": string, -"owner": string, -"group": string, -"mode": string, -"alignment": integer, -"min_io": integer, -"opt_io": integer, -"phy_sec": integer, -"log_sec": integer, -"rota": boolean, -"sched": string, -"rq_size": integer, -"disc_aln": integer, -"disc_gran": string, -"disc_max": string, -"disc_zero": boolean, -"wsame": string, -"wwn": string, -"rand": boolean, -"pkname": string, -"hctl": string, -"tran": string, -"rev": string, -"vendor": string -} -] + [ + { + "name": string, + "maj_min": string, + "rm": boolean, + "size": string, + "ro": boolean, + "type": string, + "mountpoint": string, + "kname": string, + "fstype": string, + "label": string, + "uuid": string, + "partlabel": string, + "partuuid": string, + "ra": integer, + "model": string, + "serial": string, + "state": string, + "owner": string, + "group": string, + "mode": string, + "alignment": integer, + "min_io": integer, + "opt_io": integer, + "phy_sec": integer, + "log_sec": integer, + "rota": boolean, + "sched": string, + "rq_size": integer, + "disc_aln": integer, + "disc_gran": string, + "disc_max": string, + "disc_zero": boolean, + "wsame": string, + "wwn": string, + "rand": boolean, + "pkname": string, + "hctl": string, + "tran": string, + "rev": string, + "vendor": string + } + ] -**Examples**: +Examples: - - $ lsblk | jc --lsblk -p - [ - { -- `"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" - }, - ... - ] - - $ 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"` - "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,\\ - 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"` - "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 - }, - ... - ] + $ lsblk | jc --lsblk -p + [ + { + "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" + }, + ... + ] + + $ 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": "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,\\ + 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": "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 + }, + ... + ] @@ -300,18 +299,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/lsmod.md b/docs/parsers/lsmod.md index fa1523b1..68c7347c 100644 --- a/docs/parsers/lsmod.md +++ b/docs/parsers/lsmod.md @@ -7,129 +7,128 @@ jc - JSON CLI output utility `lsmod` command output parser Usage (cli): -$ lsmod | jc --lsmod + $ lsmod | jc --lsmod -or + or -$ jc lsmod + $ jc lsmod Usage (module): -import jc -result = jc.parse('lsmod', lsmod_command_output) + import jc + result = jc.parse('lsmod', lsmod_command_output) -or + or -import jc.parsers.lsmod -result = jc.parsers.lsmod.parse(lsmod_command_output) + import jc.parsers.lsmod + result = jc.parsers.lsmod.parse(lsmod_command_output) Schema: -[ -{ -"module": string, -"size": integer, -"used": integer, -"by": [ -string -] -} -] + [ + { + "module": string, + "size": integer, + "used": integer, + "by": [ + string + ] + } + ] -**Examples**: +Examples: - - $ lsmod | jc --lsmod -p - [ - ... - { -- `"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_security", -- `"size"` - 12705, -- `"used"` - 1 - }, - { -- `"module"` - "iptable_raw", -- `"size"` - 12678, -- `"used"` - 1 - }, - { -- `"module"` - "nf_conntrack", -- `"size"` - 139224, -- `"used"` - 7, -- `"by"` - [ - "nf_nat", - "nf_nat_ipv4", - "nf_nat_ipv6", - "xt_conntrack", - "nf_nat_masquerade_ipv4", - "nf_conntrack_ipv4", - "nf_conntrack_ipv6" - ] - }, - ... - ] - - $ lsmod | jc --lsmod -p -r - [ - ... - { -- `"module"` - "nf_conntrack", -- `"size"` - "139224", -- `"used"` - "7", -- `"by"` - [ - "nf_nat", - "nf_nat_ipv4", - "nf_nat_ipv6", - "xt_conntrack", - "nf_nat_masquerade_ipv4", - "nf_conntrack_ipv4", - "nf_conntrack_ipv6" - ] - }, - { -- `"module"` - "ip_set", -- `"size"` - "45799", -- `"used"` - "0" - }, - { -- `"module"` - "nfnetlink", -- `"size"` - "14519", -- `"used"` - "1", -- `"by"` - [ - "ip_set" - ] - }, - { -- `"module"` - "ebtable_filter", -- `"size"` - "12827", -- `"used"` - "1" - }, - { -- `"module"` - "ebtables", -- `"size"` - "35009", -- `"used"` - "2", -- `"by"` - [ - "ebtable_nat", - "ebtable_filter" - ] - }, - ... - ] + $ lsmod | jc --lsmod -p + [ + ... + { + "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_security", + "size": 12705, + "used": 1 + }, + { + "module": "iptable_raw", + "size": 12678, + "used": 1 + }, + { + "module": "nf_conntrack", + "size": 139224, + "used": 7, + "by": [ + "nf_nat", + "nf_nat_ipv4", + "nf_nat_ipv6", + "xt_conntrack", + "nf_nat_masquerade_ipv4", + "nf_conntrack_ipv4", + "nf_conntrack_ipv6" + ] + }, + ... + ] + + $ lsmod | jc --lsmod -p -r + [ + ... + { + "module": "nf_conntrack", + "size": "139224", + "used": "7", + "by": [ + "nf_nat", + "nf_nat_ipv4", + "nf_nat_ipv6", + "xt_conntrack", + "nf_nat_masquerade_ipv4", + "nf_conntrack_ipv4", + "nf_conntrack_ipv6" + ] + }, + { + "module": "ip_set", + "size": "45799", + "used": "0" + }, + { + "module": "nfnetlink", + "size": "14519", + "used": "1", + "by": [ + "ip_set" + ] + }, + { + "module": "ebtable_filter", + "size": "12827", + "used": "1" + }, + { + "module": "ebtables", + "size": "35009", + "used": "2", + "by": [ + "ebtable_nat", + "ebtable_filter" + ] + }, + ... + ] @@ -151,18 +150,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/lsof.md b/docs/parsers/lsof.md index af4f31ff..6a91c727 100644 --- a/docs/parsers/lsof.md +++ b/docs/parsers/lsof.md @@ -7,123 +7,122 @@ jc - JSON CLI output utility `lsof` command output parser Usage (cli): -$ lsof | jc --lsof + $ lsof | jc --lsof -or + or -$ jc lsof + $ jc lsof Usage (module): -import jc -result = jc.parse('lsof', lsof_command_output) + import jc + result = jc.parse('lsof', lsof_command_output) -or + or -import jc.parsers.lsof -result = jc.parsers.lsof.parse(lsof_command_output) + import jc.parsers.lsof + result = jc.parsers.lsof.parse(lsof_command_output) Schema: -[ -{ -"command": string, -"pid": integer, -"tid": integer, -"user": string, -"fd": string, -"type": string, -"device": string, -"size_off": integer, -"node": integer, -"name": string -} -] + [ + { + "command": string, + "pid": integer, + "tid": integer, + "user": string, + "fd": string, + "type": string, + "device": string, + "size_off": integer, + "node": integer, + "name": string + } + ] -**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"` - "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" - }, - ... - ] - - $ 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"` - "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" - }, - ... - ] + $ 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": "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" + }, + ... + ] + + $ 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": "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" + }, + ... + ] @@ -145,18 +144,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/lsusb.md b/docs/parsers/lsusb.md index 512376cf..cfdeafb0 100644 --- a/docs/parsers/lsusb.md +++ b/docs/parsers/lsusb.md @@ -9,263 +9,262 @@ Supports the `-v` option or no options. Usage (cli): -$ lsusb -v | jc --lsusb + $ lsusb -v | jc --lsusb -or + or -$ jc lsusb -v + $ jc lsusb -v Usage (module): -import jc -result = jc.parse('lsusb', lsusb_command_output) + import jc + result = jc.parse('lsusb', lsusb_command_output) -or + or -import jc.parsers.lsusb -result = jc.parsers.lsusb.parse(lsusb_command_output) + import jc.parsers.lsusb + result = jc.parsers.lsusb.parse(lsusb_command_output) Schema: -Note: object keynames are assigned directly from the lsusb -output. If there are duplicate names in a section, only the -last one is converted. + Note: object keynames are assigned directly from the lsusb + output. If there are duplicate names in a section, only the + last one is converted. -[ -{ -"bus": string, -"device": string, -"id": string, -"description": string, -"device_descriptor": { -"": { -"value": string, -"description": string, -"attributes": [ -string -] -}, -"configuration_descriptor": { -"": { -"value": string, -"description": string, -"attributes": [ -string -] -}, -"interface_association": { -"": { -"value": string, -"description": string, -"attributes": [ -string -] -} -}, -"interface_descriptors": [ -{ -"": { -"value": string, -"description": string, -"attributes": [ -string -] -}, -"cdc_header": { -"": { -"value": string, -"description": string, -"attributes": [ -string -] -} -}, -"cdc_call_management": { -"": { -"value": string, -"description": string, -"attributes": [ -string -] -} -}, -"cdc_acm": { -"": { -"value": string, -"description": string, -"attributes": [ -string -] -} -}, -"cdc_union": { -"": { -"value": string, -"description": string, -"attributes": [ -string -] -} -}, -"endpoint_descriptors": [ -{ -"": { -"value": string, -"description": string, -"attributes": [ -string -] -} -} -] -} -] -} -}, -"hub_descriptor": { -"": { -"value": string, -"description": string, -"attributes": [ -string, -] -}, -"hub_port_status": { -"": { -"value": string, -"attributes": [ -string -] -} -} -}, -"device_status": { -"value": string, -"description": string -} -} -] + [ + { + "bus": string, + "device": string, + "id": string, + "description": string, + "device_descriptor": { + "": { + "value": string, + "description": string, + "attributes": [ + string + ] + }, + "configuration_descriptor": { + "": { + "value": string, + "description": string, + "attributes": [ + string + ] + }, + "interface_association": { + "": { + "value": string, + "description": string, + "attributes": [ + string + ] + } + }, + "interface_descriptors": [ + { + "": { + "value": string, + "description": string, + "attributes": [ + string + ] + }, + "cdc_header": { + "": { + "value": string, + "description": string, + "attributes": [ + string + ] + } + }, + "cdc_call_management": { + "": { + "value": string, + "description": string, + "attributes": [ + string + ] + } + }, + "cdc_acm": { + "": { + "value": string, + "description": string, + "attributes": [ + string + ] + } + }, + "cdc_union": { + "": { + "value": string, + "description": string, + "attributes": [ + string + ] + } + }, + "endpoint_descriptors": [ + { + "": { + "value": string, + "description": string, + "attributes": [ + string + ] + } + } + ] + } + ] + } + }, + "hub_descriptor": { + "": { + "value": string, + "description": string, + "attributes": [ + string, + ] + }, + "hub_port_status": { + "": { + "value": string, + "attributes": [ + string + ] + } + } + }, + "device_status": { + "value": string, + "description": string + } + } + ] -**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" - }, -- `"bDescriptorType"` - { -- `"value"` - "1" - }, -- `"bcdUSB"` - { -- `"value"` - "1.10" - }, - ... -- `"bNumConfigurations"` - { -- `"value"` - "1" - }, -- `"configuration_descriptor"` - { -- `"bLength"` - { -- `"value"` - "9" - }, - ... -- `"iConfiguration"` - { -- `"value"` - "0" - }, -- `"bmAttributes"` - { -- `"value"` - "0xe0", -- `"attributes"` - [ - "Self Powered", - "Remote Wakeup" - ] - }, -- `"MaxPower"` - { -- `"description"` - "0mA" - }, -- `"interface_descriptors"` - [ - { -- `"bLength"` - { -- `"value"` - "9" - }, - ... -- `"bInterfaceProtocol"` - { -- `"value"` - "0", -- `"description"` - "Full speed (or root) hub" - }, -- `"iInterface"` - { -- `"value"` - "0" - }, -- `"endpoint_descriptors"` - [ - { -- `"bLength"` - { -- `"value"` - "7" - }, - ... -- `"bmAttributes"` - { -- `"value"` - "3", -- `"attributes"` - [ - "Transfer Type Interrupt", - "Synch Type None", - "Usage Type Data" - ] - }, -- `"wMaxPacketSize"` - { -- `"value"` - "0x0002", -- `"description"` - "1x 2 bytes" - }, -- `"bInterval"` - { -- `"value"` - "255" - } - } - ] - } - ] - } - }, -- `"hub_descriptor"` - { -- `"bLength"` - { -- `"value"` - "9" - }, - ... -- `"wHubCharacteristic"` - { -- `"value"` - "0x000a", -- `"attributes"` - [ - "No power switching (usb 1.0)", - "Per-port overcurrent protection" - ] - }, - ... -- `"hub_port_status"` - { - "Port 1": { -- `"value"` - "0000.0103", -- `"attributes"` - [ - "power", - "enable", - "connect" - ] - }, - "Port 2": { -- `"value"` - "0000.0103", -- `"attributes"` - [ - "power", - "enable", - "connect" - ] - } - } - }, -- `"device_status"` - { -- `"value"` - "0x0001", -- `"description"` - "Self Powered" - } - } - ] + $ lsusb -v | jc --lsusb -p + [ + { + "bus": "002", + "device": "001", + "id": "1d6b:0001", + "description": "Linux Foundation 1.1 root hub", + "device_descriptor": { + "bLength": { + "value": "18" + }, + "bDescriptorType": { + "value": "1" + }, + "bcdUSB": { + "value": "1.10" + }, + ... + "bNumConfigurations": { + "value": "1" + }, + "configuration_descriptor": { + "bLength": { + "value": "9" + }, + ... + "iConfiguration": { + "value": "0" + }, + "bmAttributes": { + "value": "0xe0", + "attributes": [ + "Self Powered", + "Remote Wakeup" + ] + }, + "MaxPower": { + "description": "0mA" + }, + "interface_descriptors": [ + { + "bLength": { + "value": "9" + }, + ... + "bInterfaceProtocol": { + "value": "0", + "description": "Full speed (or root) hub" + }, + "iInterface": { + "value": "0" + }, + "endpoint_descriptors": [ + { + "bLength": { + "value": "7" + }, + ... + "bmAttributes": { + "value": "3", + "attributes": [ + "Transfer Type Interrupt", + "Synch Type None", + "Usage Type Data" + ] + }, + "wMaxPacketSize": { + "value": "0x0002", + "description": "1x 2 bytes" + }, + "bInterval": { + "value": "255" + } + } + ] + } + ] + } + }, + "hub_descriptor": { + "bLength": { + "value": "9" + }, + ... + "wHubCharacteristic": { + "value": "0x000a", + "attributes": [ + "No power switching (usb 1.0)", + "Per-port overcurrent protection" + ] + }, + ... + "hub_port_status": { + "Port 1": { + "value": "0000.0103", + "attributes": [ + "power", + "enable", + "connect" + ] + }, + "Port 2": { + "value": "0000.0103", + "attributes": [ + "power", + "enable", + "connect" + ] + } + } + }, + "device_status": { + "value": "0x0001", + "description": "Self Powered" + } + } + ] @@ -287,18 +286,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/mount.md b/docs/parsers/mount.md index 3f69771a..09d6ec7e 100644 --- a/docs/parsers/mount.md +++ b/docs/parsers/mount.md @@ -7,79 +7,78 @@ jc - JSON CLI output utility `mount` command output parser Usage (cli): -$ mount | jc --mount + $ mount | jc --mount -or + or -$ jc mount + $ jc mount Usage (module): -import jc -result = jc.parse('mount', mount_command_output) + import jc + result = jc.parse('mount', mount_command_output) -or + or -import jc.parsers.mount -result = jc.parsers.mount.parse(mount_command_output) + import jc.parsers.mount + result = jc.parsers.mount.parse(mount_command_output) Schema: -[ -{ -"filesystem": string, -"mount_point": string, -"type": string, -"access": [ -string -] -} -] + [ + { + "filesystem": string, + "mount_point": string, + "type": string, + "access": [ + string + ] + } + ] -**Example**: +Example: - - $ mount | jc --mount -p - [ - { -- `"filesystem"` - "sysfs", -- `"mount_point"` - "/sys", -- `"type"` - "sysfs", -- `"access"` - [ - "rw", - "nosuid", - "nodev", - "noexec", - "relatime" - ] - }, - { -- `"filesystem"` - "proc", -- `"mount_point"` - "/proc", -- `"type"` - "proc", -- `"access"` - [ - "rw", - "nosuid", - "nodev", - "noexec", - "relatime" - ] - }, - { -- `"filesystem"` - "udev", -- `"mount_point"` - "/dev", -- `"type"` - "devtmpfs", -- `"access"` - [ - "rw", - "nosuid", - "relatime", - "size=977500k", - "nr_inodes=244375", - "mode=755" - ] - }, - ... - ] + $ mount | jc --mount -p + [ + { + "filesystem": "sysfs", + "mount_point": "/sys", + "type": "sysfs", + "access": [ + "rw", + "nosuid", + "nodev", + "noexec", + "relatime" + ] + }, + { + "filesystem": "proc", + "mount_point": "/proc", + "type": "proc", + "access": [ + "rw", + "nosuid", + "nodev", + "noexec", + "relatime" + ] + }, + { + "filesystem": "udev", + "mount_point": "/dev", + "type": "devtmpfs", + "access": [ + "rw", + "nosuid", + "relatime", + "size=977500k", + "nr_inodes=244375", + "mode=755" + ] + }, + ... + ] @@ -101,18 +100,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/netstat.md b/docs/parsers/netstat.md index 740ecd72..ac6a519f 100644 --- a/docs/parsers/netstat.md +++ b/docs/parsers/netstat.md @@ -8,358 +8,357 @@ jc - JSON CLI output utility `netstat` command output parser Caveats: - Use of multiple `l` options is not supported on OSX (e.g. `netstat -rlll`) - Use of the `A` option is not supported on OSX when using the `r` option -(e.g. `netstat -rA`) + (e.g. `netstat -rA`) Usage (cli): -$ netstat | jc --netstat + $ netstat | jc --netstat -or + or -$ jc netstat + $ jc netstat Usage (module): -import jc -result = jc.parse('netstat', netstat_command_output) + import jc + result = jc.parse('netstat', netstat_command_output) -or + or -import jc.parsers.netstat -result = jc.parsers.netstat.parse(netstat_command_output) + import jc.parsers.netstat + result = jc.parsers.netstat.parse(netstat_command_output) Schema: -[ -{ -"proto": string, -"recv_q": integer, -"send_q": integer, -"transport_protocol" string, -"network_protocol": string, -"local_address": string, -"local_port": string, -"local_port_num": integer, -"foreign_address": string, -"foreign_port": string, -"foreign_port_num": integer, -"state": string, -"program_name": string, -"pid": integer, -"user": string, -"security_context": string, -"refcnt": integer, -"flags": string, -"type": string, -"inode": integer, -"path": string, -"kind": string, -"address": string, -"unix_inode": string, -"conn": string, -"refs": string, -"nextref": string, -"name": string, -"unit": integer, -"vendor": integer, -"class": integer, -"subcla": integer, -"unix_flags": integer, -"pcbcount": integer, -"rcvbuf": integer, -"sndbuf": integer, -"rxbytes": integer, -"txbytes": integer, -"destination": string, -"gateway": string, -"route_flags": string, -"route_flags_pretty": [ -string, -] -"route_refs": integer, -"use": integer, -"mtu": integer, -"expire": string, -"genmask": string, -"mss": integer, -"window": integer, -"irtt": integer, -"iface": string, -"metric": integer, -"network": string, -"address": string, -"ipkts": integer, # - = null -"ierrs": integer, # - = null -"idrop": integer, # - = null -"opkts": integer, # - = null -"oerrs": integer, # - = null -"coll": integer, # - = null -"rx_ok": integer, -"rx_err": integer, -"rx_drp": integer, -"rx_ovr": integer, -"tx_ok": integer, -"tx_err": integer, -"tx_drp": integer, -"tx_ovr": integer, -"flg": string, -"ibytes": integer, -"obytes": integer, -"r_mbuf": integer, -"s_mbuf": integer, -"r_clus": integer, -"s_clus": integer, -"r_hiwa": integer, -"s_hiwa": integer, -"r_lowa": integer, -"s_lowa": integer, -"r_bcnt": integer, -"s_bcnt": integer, -"r_bmax": integer, -"s_bmax": integer, -"rexmit": integer, -"ooorcv": integer, -"0_win": integer, -"rexmt": float, -"persist": float, -"keep": float, -"2msl": float, -"delack": float, -"rcvtime": float, -} -] + [ + { + "proto": string, + "recv_q": integer, + "send_q": integer, + "transport_protocol" string, + "network_protocol": string, + "local_address": string, + "local_port": string, + "local_port_num": integer, + "foreign_address": string, + "foreign_port": string, + "foreign_port_num": integer, + "state": string, + "program_name": string, + "pid": integer, + "user": string, + "security_context": string, + "refcnt": integer, + "flags": string, + "type": string, + "inode": integer, + "path": string, + "kind": string, + "address": string, + "unix_inode": string, + "conn": string, + "refs": string, + "nextref": string, + "name": string, + "unit": integer, + "vendor": integer, + "class": integer, + "subcla": integer, + "unix_flags": integer, + "pcbcount": integer, + "rcvbuf": integer, + "sndbuf": integer, + "rxbytes": integer, + "txbytes": integer, + "destination": string, + "gateway": string, + "route_flags": string, + "route_flags_pretty": [ + string, + ] + "route_refs": integer, + "use": integer, + "mtu": integer, + "expire": string, + "genmask": string, + "mss": integer, + "window": integer, + "irtt": integer, + "iface": string, + "metric": integer, + "network": string, + "address": string, + "ipkts": integer, # - = null + "ierrs": integer, # - = null + "idrop": integer, # - = null + "opkts": integer, # - = null + "oerrs": integer, # - = null + "coll": integer, # - = null + "rx_ok": integer, + "rx_err": integer, + "rx_drp": integer, + "rx_ovr": integer, + "tx_ok": integer, + "tx_err": integer, + "tx_drp": integer, + "tx_ovr": integer, + "flg": string, + "ibytes": integer, + "obytes": integer, + "r_mbuf": integer, + "s_mbuf": integer, + "r_clus": integer, + "s_clus": integer, + "r_hiwa": integer, + "s_hiwa": integer, + "r_lowa": integer, + "s_lowa": integer, + "r_bcnt": integer, + "s_bcnt": integer, + "r_bmax": integer, + "s_bmax": integer, + "rexmit": integer, + "ooorcv": integer, + "0_win": integer, + "rexmt": float, + "persist": float, + "keep": float, + "2msl": float, + "delack": float, + "rcvtime": float, + } + ] -**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"` - "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"` - 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"` - "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"` - "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 - }, - ... - ] - - $ 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"` - [ - "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"` - [ - "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"` - [ - "UP" - ] - } - ] - - $ 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"` - "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" - } - ] + # 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": "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": 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": "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": "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 + }, + ... + ] + + $ 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": [ + "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": [ + "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": [ + "UP" + ] + } + ] + + $ 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": "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" + } + ] @@ -381,18 +380,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/ntpq.md b/docs/parsers/ntpq.md index 47e19b30..87326a49 100644 --- a/docs/parsers/ntpq.md +++ b/docs/parsers/ntpq.md @@ -7,210 +7,209 @@ jc - JSON CLI output utility `ntpq -p` command output parser Usage (cli): -$ ntpq -p | jc --ntpq + $ ntpq -p | jc --ntpq -or + or -$ jc ntpq -p + $ jc ntpq -p Usage (module): -import jc -result = jc.parse('ntpq', ntpq_command_output) + import jc + result = jc.parse('ntpq', ntpq_command_output) -or + or -import jc.parsers.ntpq -result = jc.parsers.ntpq.parse(ntpq_command_output) + import jc.parsers.ntpq + result = jc.parsers.ntpq.parse(ntpq_command_output) Schema: -[ -{ -"state": string, # space/~ converted to null -"remote": string, -"refid": string, -"st": integer, -"t": string, -"when": integer, # - converted to null -"poll": integer, -"reach": integer, -"delay": float, -"offset": float, -"jitter": float -}, -] + [ + { + "state": string, # space/~ converted to null + "remote": string, + "refid": string, + "st": integer, + "t": string, + "when": integer, # - converted to null + "poll": integer, + "reach": integer, + "delay": float, + "offset": float, + "jitter": float + }, + ] -**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"` - "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"` - "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"` - "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"` - "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"` - "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"` - "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" - } - ] + $ 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": "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": "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": "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": "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": "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": "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" + } + ] @@ -232,18 +231,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, freebsd diff --git a/docs/parsers/passwd.md b/docs/parsers/passwd.md index 8b2aab16..83d8bac7 100644 --- a/docs/parsers/passwd.md +++ b/docs/parsers/passwd.md @@ -7,98 +7,97 @@ jc - JSON CLI output utility `/etc/passwd` file Parser Usage (cli): -$ cat /etc/passwd | jc --passwd + $ cat /etc/passwd | jc --passwd Usage (module): -import jc -result = jc.parse('passwd', passwd_file_output) + import jc + result = jc.parse('passwd', passwd_file_output) -or + or -import jc.parsers.passwd -result = jc.parsers.passwd.parse(passwd_file_output) + import jc.parsers.passwd + result = jc.parsers.passwd.parse(passwd_file_output) Schema: -[ -{ -"username": string, -"password": string, -"uid": integer, -"gid": integer, -"comment": string, -"home": string, -"shell": string -} -] + [ + { + "username": string, + "password": string, + "uid": integer, + "gid": integer, + "comment": string, + "home": string, + "shell": string + } + ] -**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"` - "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" - }, - ... - ] - - $ 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"` - "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" - }, - ... - ] + $ cat /etc/passwd | jc --passwd -p + [ + { + "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": "daemon", + "password": "*", + "uid": 1, + "gid": 1, + "comment": "System Services", + "home": "/var/root", + "shell": "/usr/bin/false" + }, + ... + ] + + $ 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": "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" + }, + ... + ] @@ -120,18 +119,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, aix, freebsd diff --git a/docs/parsers/ping.md b/docs/parsers/ping.md index da271570..800c2aa1 100644 --- a/docs/parsers/ping.md +++ b/docs/parsers/ping.md @@ -9,164 +9,163 @@ Supports `ping` and `ping6` output. Usage (cli): -Note: Use the ping `-c` (count) option, otherwise data will not be -piped to `jc`. + Note: Use the ping `-c` (count) option, otherwise data will not be + piped to `jc`. -$ ping -c 3 1.2.3.4 | jc --ping + $ ping -c 3 1.2.3.4 | jc --ping -or + or -$ jc ping -c 3 1.2.3.4 + $ jc ping -c 3 1.2.3.4 Usage (module): -import jc -result = jc.parse('ping', ping_command_output) + import jc + result = jc.parse('ping', ping_command_output) -or + or -import jc.parsers.ping -result = jc.parsers.ping.parse(ping_command_output) + import jc.parsers.ping + result = jc.parsers.ping.parse(ping_command_output) Schema: -{ -"source_ip": string, -"destination_ip": string, -"data_bytes": integer, -"pattern": string, # null if not set -"destination": string, -"packets_transmitted": integer, -"packets_received": integer, -"packet_loss_percent": float, -"duplicates": integer, -"round_trip_ms_min": float, -"round_trip_ms_avg": float, -"round_trip_ms_max": float, -"round_trip_ms_stddev": float, -"responses": [ -{ -"type": string, # [0] -"unparsed_line": string, # [1] -"timestamp": float, -"bytes": integer, -"response_ip": string, -"icmp_seq": integer, -"ttl": integer, -"time_ms": float, -"duplicate": boolean, -"vr": integer, # [2] -"hl": integer, # [2] -"tos": integer, # [2] -"len": integer, # [2] -"id": integer, # [2] -"flg": integer, # [2] -"off": integer, # [2] -"pro": integer, # [2] -"cks": ingeger, # [2] -"src": string, -"dst": string -} -] -} + { + "source_ip": string, + "destination_ip": string, + "data_bytes": integer, + "pattern": string, # null if not set + "destination": string, + "packets_transmitted": integer, + "packets_received": integer, + "packet_loss_percent": float, + "duplicates": integer, + "round_trip_ms_min": float, + "round_trip_ms_avg": float, + "round_trip_ms_max": float, + "round_trip_ms_stddev": float, + "responses": [ + { + "type": string, # [0] + "unparsed_line": string, # [1] + "timestamp": float, + "bytes": integer, + "response_ip": string, + "icmp_seq": integer, + "ttl": integer, + "time_ms": float, + "duplicate": boolean, + "vr": integer, # [2] + "hl": integer, # [2] + "tos": integer, # [2] + "len": integer, # [2] + "id": integer, # [2] + "flg": integer, # [2] + "off": integer, # [2] + "pro": integer, # [2] + "cks": ingeger, # [2] + "src": string, + "dst": string + } + ] + } -[0] 'reply', 'timeout', 'unparsable_line', etc. See -`_error_type.type_map` for all options -[1] only if an 'unparsable_line' type -[2] hex value converted to decimal + [0] 'reply', 'timeout', 'unparsable_line', etc. See + `_error_type.type_map` for all options + [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"` - [ - { -- `"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"` - 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"` - [ - { -- `"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"` - "2", -- `"ttl"` - "59", -- `"time_ms"` - "32.553", -- `"duplicate"` - false - } - ] - } + $ 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": [ + { + "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": 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": [ + { + "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": "2", + "ttl": "59", + "time_ms": "32.553", + "duplicate": false + } + ] + } @@ -188,18 +187,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/ping_s.md b/docs/parsers/ping_s.md index e95b9733..9c23a729 100644 --- a/docs/parsers/ping_s.md +++ b/docs/parsers/ping_s.md @@ -11,83 +11,82 @@ Supports `ping` and `ping6` output. Usage (cli): -$ ping | jc --ping-s + $ ping | jc --ping-s > Note: When piping `jc` converted `ping` output to other processes it may -appear the output is hanging due to the OS pipe buffers. This is because -`ping` output is too small to quickly fill up the buffer. Use the `-u` -option to unbuffer the `jc` output if you would like immediate output. -See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output) -for more information. + appear the output is hanging due to the OS pipe buffers. This is because + `ping` output is too small to quickly fill up the buffer. Use the `-u` + option to unbuffer the `jc` output if you would like immediate output. + See the [readme](https://github.com/kellyjonbrazil/jc/tree/master#unbuffering-output) + for more information. Usage (module): -import jc -# result is an iterable object (generator) -result = jc.parse('ping_s', ping_command_output.splitlines()) -for item in result: -# do something + import jc + # result is an iterable object (generator) + result = jc.parse('ping_s', ping_command_output.splitlines()) + for item in result: + # do something -or + or -import jc.parsers.ping_s -# result is an iterable object (generator) -result = jc.parsers.ping_s.parse(ping_command_output.splitlines()) -for item in result: -# do something + import jc.parsers.ping_s + # result is an iterable object (generator) + result = jc.parsers.ping_s.parse(ping_command_output.splitlines()) + for item in result: + # do something Schema: -{ -"type": string, # [0] -"source_ip": string, -"destination_ip": string, -"sent_bytes": integer, -"pattern": string, # (null if not set) -"destination": string, -"timestamp": float, -"response_bytes": integer, -"response_ip": string, -"icmp_seq": integer, -"ttl": integer, -"time_ms": float, -"duplicate": boolean, -"packets_transmitted": integer, -"packets_received": integer, -"packet_loss_percent": float, -"duplicates": integer, -"round_trip_ms_min": float, -"round_trip_ms_avg": float, -"round_trip_ms_max": float, -"round_trip_ms_stddev": float, + { + "type": string, # [0] + "source_ip": string, + "destination_ip": string, + "sent_bytes": integer, + "pattern": string, # (null if not set) + "destination": string, + "timestamp": float, + "response_bytes": integer, + "response_ip": string, + "icmp_seq": integer, + "ttl": integer, + "time_ms": float, + "duplicate": boolean, + "packets_transmitted": integer, + "packets_received": integer, + "packet_loss_percent": float, + "duplicates": integer, + "round_trip_ms_min": float, + "round_trip_ms_avg": float, + "round_trip_ms_max": float, + "round_trip_ms_stddev": float, -# Below object only exists if using -qq or ignore_exceptions=True + # Below object only exists if using -qq or ignore_exceptions=True -"_jc_meta": -{ -"success": boolean, # false if error parsing -"error": string, # exists if "success" is false -"line": string # exists if "success" is false -} -} + "_jc_meta": + { + "success": boolean, # false if error parsing + "error": string, # exists if "success" is false + "line": string # exists if "success" is false + } + } -[0] 'reply', 'timeout', 'summary', etc. See `_error_type.type_map` -for all options. + [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...} - {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...} - {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...} - ... - - $ ping 1.1.1.1 | jc --ping-s -r - {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...} - {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...} - {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...} - ... + $ ping 1.1.1.1 | jc --ping-s + {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...} + {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...} + {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":56,"patte...} + ... + + $ ping 1.1.1.1 | jc --ping-s -r + {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...} + {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...} + {"type":"reply","destination_ip":"1.1.1.1","sent_bytes":"56","patte...} + ... @@ -109,27 +108,22 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False) Main text parsing generator function. Returns an iterator object. -**Arguments**: +Parameters: - -- `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 - + data: (iterable) line-based text data to parse + (e.g. sys.stdin or str.splitlines()) -**Yields**: + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + ignore_exceptions: (boolean) ignore parsing exceptions if True - - Dictionary. Raw or processed structured data. - +Yields: -**Returns**: + Dictionary. Raw or processed structured data. - - Iterator object +Returns: + + Iterator object ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/pip_list.md b/docs/parsers/pip_list.md index 581ecdd8..c6f68e43 100644 --- a/docs/parsers/pip_list.md +++ b/docs/parsers/pip_list.md @@ -7,51 +7,50 @@ jc - JSON CLI output utility `pip-list` command output parser Usage (cli): -$ pip list | jc --pip-list + $ pip list | jc --pip-list -or + or -$ jc pip list + $ jc pip list Usage (module): -import jc -result = jc.parse('pip_list', pip_list_command_output) + import jc + result = jc.parse('pip_list', pip_list_command_output) -or + or -import jc.parsers.pip_list -result = jc.parsers.pip_list.parse(pip_list_command_output) + import jc.parsers.pip_list + result = jc.parsers.pip_list.parse(pip_list_command_output) Schema: -[ -{ -"package": string, -"version": string, -"location": string -} -] + [ + { + "package": string, + "version": string, + "location": string + } + ] -**Examples**: +Examples: - - $ pip list | jc --pip-list -p - [ - { -- `"package"` - "ansible", -- `"version"` - "2.8.5" - }, - { -- `"package"` - "antlr4-python3-runtime", -- `"version"` - "4.7.2" - }, - { -- `"package"` - "asn1crypto", -- `"version"` - "0.24.0" - }, - ... - ] + $ pip list | jc --pip-list -p + [ + { + "package": "ansible", + "version": "2.8.5" + }, + { + "package": "antlr4-python3-runtime", + "version": "4.7.2" + }, + { + "package": "asn1crypto", + "version": "0.24.0" + }, + ... + ] @@ -73,18 +72,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/pip_show.md b/docs/parsers/pip_show.md index 8b230b91..61269051 100644 --- a/docs/parsers/pip_show.md +++ b/docs/parsers/pip_show.md @@ -7,69 +7,68 @@ jc - JSON CLI output utility `pip-show` command output parser Usage (cli): -$ pip show | jc --pip-show + $ pip show | jc --pip-show -or + or -$ jc pip show + $ jc pip show Usage (module): -import jc -result = jc.parse('pip_show', pip_show_command_output) + import jc + result = jc.parse('pip_show', pip_show_command_output) -or + or -import jc.parsers.pip_show -result = jc.parsers.pip_show.parse(pip_show_command_output) + import jc.parsers.pip_show + result = jc.parsers.pip_show.parse(pip_show_command_output) Schema: -[ -{ -"name": string, -"version": string, -"summary": string, -"home_page": string, -"author": string, -"author_email": string, -"license": string, -"location": string, -"requires": string, -"required_by": string -} -] + [ + { + "name": string, + "version": string, + "summary": string, + "home_page": string, + "author": string, + "author_email": string, + "license": string, + "location": string, + "requires": string, + "required_by": string + } + ] -**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"` - "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 - } - ] + $ 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": "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 + } + ] @@ -91,18 +90,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/ps.md b/docs/parsers/ps.md index 46adf0ee..720af811 100644 --- a/docs/parsers/ps.md +++ b/docs/parsers/ps.md @@ -11,206 +11,205 @@ jc - JSON CLI output utility `ps` command output parser Usage (cli): -$ ps | jc --ps + $ ps | jc --ps -or + or -$ jc ps + $ jc ps Usage (module): -import jc -result = jc.parse('ps', ps_command_output) + import jc + result = jc.parse('ps', ps_command_output) -or + or -import jc.parsers.ps -result = jc.parsers.ps.parse(ps_command_output) + import jc.parsers.ps + result = jc.parsers.ps.parse(ps_command_output) Schema: -[ -{ -"uid": string, -"pid": integer, -"ppid": integer, -"c": integer, -"stime": string, -"tty": string, # ? or ?? = Null -"tt": string, # ?? = Null -"time": string, -"cmd": string, -"user": string, -"cpu_percent": float, -"mem_percent": float, -"vsz": integer, -"rss": integer, -"stat": string, -"start": string, -"command": string -} -] + [ + { + "uid": string, + "pid": integer, + "ppid": integer, + "c": integer, + "stime": string, + "tty": string, # ? or ?? = Null + "tt": string, # ?? = Null + "time": string, + "cmd": string, + "user": string, + "cpu_percent": float, + "mem_percent": float, + "vsz": integer, + "rss": integer, + "stat": string, + "start": string, + "command": string + } + ] -**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"` - 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]" - }, - ... - ] - - $ 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"` - "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]" - }, - ... - ] - - $ 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"` - 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]" - }, - ... - ] - - $ 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"` - "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]" - }, - ... - ] + $ 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": 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]" + }, + ... + ] + + $ 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": "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]" + }, + ... + ] + + $ 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": 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]" + }, + ... + ] + + $ 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": "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]" + }, + ... + ] @@ -232,18 +231,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/route.md b/docs/parsers/route.md index 1ca4eac2..f76084f6 100644 --- a/docs/parsers/route.md +++ b/docs/parsers/route.md @@ -7,112 +7,111 @@ jc - JSON CLI output utility `route` command output parser Usage (cli): -$ route | jc --route + $ route | jc --route -or + or -$ jc route + $ jc route Usage (module): -import jc -result = jc.parse('route', route_command_output) + import jc + result = jc.parse('route', route_command_output) -or + or -import jc.parsers.route -result = jc.parsers.route.parse(route_command_output) + import jc.parsers.route + result = jc.parsers.route.parse(route_command_output) Schema: -[ -{ -"destination": string, -"gateway": string, -"genmask": string, -"flags": string, -"flags_pretty": [ -string -] -"metric": integer, -"ref": integer, -"use": integer, -"mss": integer, -"window": integer, -"irtt": integer, -"iface": string -} -] + [ + { + "destination": string, + "gateway": string, + "genmask": string, + "flags": string, + "flags_pretty": [ + string + ] + "metric": integer, + "ref": integer, + "use": integer, + "mss": integer, + "window": integer, + "irtt": integer, + "iface": string + } + ] -**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"` - [ - "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"` - [ - "UP" - ] - } - ] - - $ 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"` - "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" - } - ] + $ 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": [ + "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": [ + "UP" + ] + } + ] + + $ 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": "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" + } + ] @@ -134,18 +133,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/rpm_qi.md b/docs/parsers/rpm_qi.md index 272b6495..a4f9a034 100644 --- a/docs/parsers/rpm_qi.md +++ b/docs/parsers/rpm_qi.md @@ -15,157 +15,156 @@ only available if the timezone field is UTC. Usage (cli): -$ rpm -qia | jc --rpm-qi + $ rpm -qia | jc --rpm-qi -or + or -$ jc rpm -qia + $ jc rpm -qia Usage (module): -import jc -result = jc.parse('rpm_qi', rpm_qi_command_output) + import jc + result = jc.parse('rpm_qi', rpm_qi_command_output) -or + or -import jc.parsers.rpm_qi -result = jc.parsers.rpm_qi.parse(rpm_qi_command_output) + import jc.parsers.rpm_qi + result = jc.parsers.rpm_qi.parse(rpm_qi_command_output) Schema: -[ -{ -"name": string, -"epoch": integer, -"version": string, -"release": string, -"architecture": string, -"install_date": string, -"install_date_epoch": integer, # [0] -"install_date_epoch_utc": integer, # [1] -"group": string, -"size": integer, -"license": string, -"signature": string, -"source_rpm": string, -"build_date": string, -"build_epoch": integer, # [0] -"build_epoch_utc": integer, # [1] -"build_host": string, -"relocations": string, -"packager": string, -"vendor": string, -"url": string, -"summary": string, -"description": string -} -] + [ + { + "name": string, + "epoch": integer, + "version": string, + "release": string, + "architecture": string, + "install_date": string, + "install_date_epoch": integer, # [0] + "install_date_epoch_utc": integer, # [1] + "group": string, + "size": integer, + "license": string, + "signature": string, + "source_rpm": string, + "build_date": string, + "build_epoch": integer, # [0] + "build_epoch_utc": integer, # [1] + "build_host": string, + "relocations": string, + "packager": string, + "vendor": string, + "url": string, + "summary": string, + "description": string + } + ] -[0] naive timestamp -[1] Aware timestamp if timezone is UTC + [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 ", -- `"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 ", -- `"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 - }, - ... - ] - - $ 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 ", -- `"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 ", -- `"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..." - }, - ... - ] + $ 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 ", + "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 ", + "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 + }, + ... + ] + + $ 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 ", + "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 ", + "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..." + }, + ... + ] @@ -187,18 +186,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/sfdisk.md b/docs/parsers/sfdisk.md index 25d6b609..574abc89 100644 --- a/docs/parsers/sfdisk.md +++ b/docs/parsers/sfdisk.md @@ -16,197 +16,196 @@ Supports the following `sfdisk` options: Usage (cli): -# sfdisk -l | jc --sfdisk + # sfdisk -l | jc --sfdisk -or + or -# jc sfdisk -l + # jc sfdisk -l Usage (module): -import jc -result = jc.parse('sfdisk', sfdisk_command_output) + import jc + result = jc.parse('sfdisk', sfdisk_command_output) -or + or -import jc.parsers.sfdisk -result = jc.parsers.sfdisk.parse(sfdisk_command_output) + import jc.parsers.sfdisk + result = jc.parsers.sfdisk.parse(sfdisk_command_output) Schema: -[ -{ -"disk": string, -"disk_size": string, -"free_disk_size": string, -"bytes": integer, -"free_bytes": integer, -"sectors": integer, -"free_sectors": integer, -"cylinders": integer, -"heads": integer, -"sectors_per_track": integer, -"units": string, -"logical_sector_size": integer, -"physical_sector_size": integer, -"min_io_size": integer, -"optimal_io_size": integer, -"disk_label_type": string, -"disk_identifier": string, -"disk_model": string, -"partitions": [ -{ -"device": string, -"boot": boolean, -"start": integer, -"end": integer, -"size": string, # [0] -"cyls": integer, -"mib": integer, -"blocks": integer, -"sectors": integer, -"id": string, -"system": string, -"type": string -} -] -} -] + [ + { + "disk": string, + "disk_size": string, + "free_disk_size": string, + "bytes": integer, + "free_bytes": integer, + "sectors": integer, + "free_sectors": integer, + "cylinders": integer, + "heads": integer, + "sectors_per_track": integer, + "units": string, + "logical_sector_size": integer, + "physical_sector_size": integer, + "min_io_size": integer, + "optimal_io_size": integer, + "disk_label_type": string, + "disk_identifier": string, + "disk_model": string, + "partitions": [ + { + "device": string, + "boot": boolean, + "start": integer, + "end": integer, + "size": string, # [0] + "cyls": integer, + "mib": integer, + "blocks": integer, + "sectors": integer, + "id": string, + "system": string, + "type": string + } + ] + } + ] -[0] will be integer when using deprecated -d sfdisk option + [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"` - [ - { -- `"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/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" - } - ] - }, - { -- `"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 - } - ] - - # 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"` - [ - { -- `"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/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" - } - ] - }, - { -- `"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" - } - ] + # 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": [ + { + "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/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" + } + ] + }, + { + "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 + } + ] + + # 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": [ + { + "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/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" + } + ] + }, + { + "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" + } + ] @@ -228,18 +227,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/shadow.md b/docs/parsers/shadow.md index 90b98c2a..45e69a18 100644 --- a/docs/parsers/shadow.md +++ b/docs/parsers/shadow.md @@ -7,105 +7,104 @@ jc - JSON CLI output utility `/etc/shadow` file parser Usage (cli): -$ sudo cat /etc/shadow | jc --shadow + $ sudo cat /etc/shadow | jc --shadow Usage (module): -import jc -result = jc.parse('shadow', shadow_file_output) + import jc + result = jc.parse('shadow', shadow_file_output) -or + or -import jc.parsers.shadow -result = jc.parsers.shadow.parse(shadow_file_output) + import jc.parsers.shadow + result = jc.parsers.shadow.parse(shadow_file_output) Schema: -[ -{ -"username": string, -"password": string, -"last_changed": integer, -"minimum": integer, -"maximum": integer, -"warn": integer, -"inactive": integer, -"expire": integer -} -] + [ + { + "username": string, + "password": string, + "last_changed": integer, + "minimum": integer, + "maximum": integer, + "warn": integer, + "inactive": integer, + "expire": integer + } + ] -**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"` - "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 - }, - ... - ] - - $ sudo cat /etc/shadow | jc --shadow -p -r - [ - { -- `"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"` - "bin", -- `"password"` - "*", -- `"last_changed"` - "18113", -- `"minimum"` - "0", -- `"maximum"` - "99999", -- `"warn"` - "7", -- `"inactive"` - "", -- `"expire"` - "" - }, - ... - ] + $ sudo cat /etc/shadow | jc --shadow -p + [ + { + "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": "bin", + "password": "*", + "last_changed": 18113, + "minimum": 0, + "maximum": 99999, + "warn": 7, + "inactive": null, + "expire": null + }, + ... + ] + + $ sudo cat /etc/shadow | jc --shadow -p -r + [ + { + "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": "bin", + "password": "*", + "last_changed": "18113", + "minimum": "0", + "maximum": "99999", + "warn": "7", + "inactive": "", + "expire": "" + }, + ... + ] @@ -127,18 +126,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, aix, freebsd diff --git a/docs/parsers/ss.md b/docs/parsers/ss.md index 47cf4331..1fa90b36 100644 --- a/docs/parsers/ss.md +++ b/docs/parsers/ss.md @@ -10,281 +10,280 @@ parsing irregularities. Usage (cli): -$ ss | jc --ss + $ ss | jc --ss -or + or -$ jc ss + $ jc ss Usage (module): -import jc -result = jc.parse('ss', ss_command_output) + import jc + result = jc.parse('ss', ss_command_output) -or + or -import jc.parsers.ss -result = jc.parsers.ss.parse(ss_command_output) + import jc.parsers.ss + result = jc.parsers.ss.parse(ss_command_output) Schema: -Information from https://www.cyberciti.biz/files/ss.html used to define -field names + Information from https://www.cyberciti.biz/files/ss.html used to define + field names -[ -{ -"netid": string, -"state": string, -"recv_q": integer, -"send_q": integer, -"local_address": string, -"local_port": string, -"local_port_num": integer, -"peer_address": string, -"peer_port": string, -"peer_port_num": integer, -"interface": string, -"link_layer" string, -"channel": string, -"path": string, -"pid": integer -} -] + [ + { + "netid": string, + "state": string, + "recv_q": integer, + "send_q": integer, + "local_address": string, + "local_port": string, + "local_port_num": integer, + "peer_address": string, + "peer_port": string, + "peer_port_num": integer, + "interface": string, + "link_layer" string, + "channel": string, + "path": string, + "pid": integer + } + ] -**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"` - "*", -- `"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"` - "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"` - "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"` - "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"` - "[::]", -- `"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 - } - ] - - $ 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"` - "*", -- `"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"` - "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"` - "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"` - "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"` - "[::]", -- `"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" - } - ] + $ 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": "*", + "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": "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": "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": "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": "[::]", + "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 + } + ] + + $ 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": "*", + "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": "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": "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": "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": "[::]", + "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" + } + ] @@ -306,18 +305,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/stat.md b/docs/parsers/stat.md index bd045022..1d55d43f 100644 --- a/docs/parsers/stat.md +++ b/docs/parsers/stat.md @@ -13,168 +13,167 @@ only available if the timezone field is UTC. Usage (cli): -$ stat * | jc --stat + $ stat * | jc --stat -or + or -$ jc stat * + $ jc stat * Usage (module): -import jc -result = jc.parse('stat', stat_command_output) + import jc + result = jc.parse('stat', stat_command_output) -or + or -import jc.parsers.stat -result = jc.parsers.stat.parse(stat_command_output) + import jc.parsers.stat + result = jc.parsers.stat.parse(stat_command_output) Schema: -[ -{ -"file": string, -"link_to" string, -"size": integer, -"blocks": integer, -"io_blocks": integer, -"type": string, -"device": string, -"inode": integer, -"links": integer, -"access": string, -"flags": string, -"uid": integer, -"user": string, -"gid": integer, -"group": string, -"access_time": string, # - = null -"access_time_epoch": integer, # naive timestamp -"access_time_epoch_utc": integer, # timezone-aware timestamp -"modify_time": string, # - = null -"modify_time_epoch": integer, # naive timestamp -"modify_time_epoch_utc": integer, # timezone-aware timestamp -"change_time": string, # - = null -"change_time_epoch": integer, # naive timestamp -"change_time_epoch_utc": integer, # timezone-aware timestamp -"birth_time": string, # - = null -"birth_time_epoch": integer, # naive timestamp -"birth_time_epoch_utc": integer, # timezone-aware timestamp -"unix_device": integer, -"rdev": integer, -"block_size": integer, -"unix_flags": string -} -] + [ + { + "file": string, + "link_to" string, + "size": integer, + "blocks": integer, + "io_blocks": integer, + "type": string, + "device": string, + "inode": integer, + "links": integer, + "access": string, + "flags": string, + "uid": integer, + "user": string, + "gid": integer, + "group": string, + "access_time": string, # - = null + "access_time_epoch": integer, # naive timestamp + "access_time_epoch_utc": integer, # timezone-aware timestamp + "modify_time": string, # - = null + "modify_time_epoch": integer, # naive timestamp + "modify_time_epoch_utc": integer, # timezone-aware timestamp + "change_time": string, # - = null + "change_time_epoch": integer, # naive timestamp + "change_time_epoch_utc": integer, # timezone-aware timestamp + "birth_time": string, # - = null + "birth_time_epoch": integer, # naive timestamp + "birth_time_epoch_utc": integer, # timezone-aware timestamp + "unix_device": integer, + "rdev": integer, + "block_size": integer, + "unix_flags": string + } + ] -**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/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 - }, - ... - ] - - $ 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/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 - }, - ... - ] + $ 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/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 + }, + ... + ] + + $ 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/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 + }, + ... + ] @@ -196,18 +195,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/stat_s.md b/docs/parsers/stat_s.md index cab1a5b3..b910afa4 100644 --- a/docs/parsers/stat_s.md +++ b/docs/parsers/stat_s.md @@ -15,77 +15,76 @@ only available if the timezone field is UTC. Usage (cli): -$ stat * | jc --stat-s + $ stat * | jc --stat-s Usage (module): -import jc -# result is an iterable object (generator) -result = jc.parse('stat_s', stat_command_output.splitlines()) -for item in result: -# do something + import jc + # result is an iterable object (generator) + result = jc.parse('stat_s', stat_command_output.splitlines()) + for item in result: + # do something -or + or -import jc.parsers.stat_s -# result is an iterable object (generator) -result = jc.parsers.stat_s.parse(stat_command_output.splitlines()) -for item in result: -# do something + import jc.parsers.stat_s + # result is an iterable object (generator) + result = jc.parsers.stat_s.parse(stat_command_output.splitlines()) + for item in result: + # do something Schema: -{ -"file": string, -"link_to" string, -"size": integer, -"blocks": integer, -"io_blocks": integer, -"type": string, -"device": string, -"inode": integer, -"links": integer, -"access": string, -"flags": string, -"uid": integer, -"user": string, -"gid": integer, -"group": string, -"access_time": string, # - = null -"access_time_epoch": integer, # naive timestamp -"access_time_epoch_utc": integer, # timezone-aware timestamp -"modify_time": string, # - = null -"modify_time_epoch": integer, # naive timestamp -"modify_time_epoch_utc": integer, # timezone-aware timestamp -"change_time": string, # - = null -"change_time_epoch": integer, # naive timestamp -"change_time_epoch_utc": integer, # timezone-aware timestamp -"birth_time": string, # - = null -"birth_time_epoch": integer, # naive timestamp -"birth_time_epoch_utc": integer, # timezone-aware timestamp -"unix_device": integer, -"rdev": integer, -"block_size": integer, -"unix_flags": string, + { + "file": string, + "link_to" string, + "size": integer, + "blocks": integer, + "io_blocks": integer, + "type": string, + "device": string, + "inode": integer, + "links": integer, + "access": string, + "flags": string, + "uid": integer, + "user": string, + "gid": integer, + "group": string, + "access_time": string, # - = null + "access_time_epoch": integer, # naive timestamp + "access_time_epoch_utc": integer, # timezone-aware timestamp + "modify_time": string, # - = null + "modify_time_epoch": integer, # naive timestamp + "modify_time_epoch_utc": integer, # timezone-aware timestamp + "change_time": string, # - = null + "change_time_epoch": integer, # naive timestamp + "change_time_epoch_utc": integer, # timezone-aware timestamp + "birth_time": string, # - = null + "birth_time_epoch": integer, # naive timestamp + "birth_time_epoch_utc": integer, # timezone-aware timestamp + "unix_device": integer, + "rdev": integer, + "block_size": integer, + "unix_flags": string, -# Below object only exists if using -qq or ignore_exceptions=True + # Below object only exists if using -qq or ignore_exceptions=True -"_jc_meta": -{ -"success": boolean, # false if error parsing -"error": string, # exists if "success" is false -"line": string # exists if "success" is false -} -} + "_jc_meta": + { + "success": boolean, # false if error parsing + "error": string, # exists if "success" is false + "line": string # exists if "success" is false + } + } -**Examples**: +Examples: - - $ stat | jc --stat-s - {"file":"(stdin)","unix_device":1027739696,"inode":1155,"flags":"cr...} - - $ stat | jc --stat-s -r - {"file":"(stdin)","unix_device":"1027739696","inode":"1155","flag...} + $ stat | jc --stat-s + {"file":"(stdin)","unix_device":1027739696,"inode":1155,"flags":"cr...} + + $ stat | jc --stat-s -r + {"file":"(stdin)","unix_device":"1027739696","inode":"1155","flag...} @@ -107,27 +106,22 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False) Main text parsing generator function. Returns an iterator object. -**Arguments**: +Parameters: - -- `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 - + data: (iterable) line-based text data to parse + (e.g. sys.stdin or str.splitlines()) -**Yields**: + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + ignore_exceptions: (boolean) ignore parsing exceptions if True - - Dictionary. Raw or processed structured data. - +Yields: -**Returns**: + Dictionary. Raw or processed structured data. - - Iterator object +Returns: + + Iterator object ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/sysctl.md b/docs/parsers/sysctl.md index e36f67c3..9fe2d15f 100644 --- a/docs/parsers/sysctl.md +++ b/docs/parsers/sysctl.md @@ -6,62 +6,61 @@ jc - JSON CLI output utility `sysctl -a` command output parser Note: Since `sysctl` output is not easily parsable only a very simple -key/value object will be output. An attempt is made to convert obvious -integers and floats. If no conversion is desired, use the `-r` -command-line argument or the `raw=True` argument in `parse()`. + key/value object will be output. An attempt is made to convert obvious + integers and floats. If no conversion is desired, use the `-r` + command-line argument or the `raw=True` argument in `parse()`. Usage (cli): -$ sysctl -a | jc --sysctl + $ sysctl -a | jc --sysctl -or + or -$ jc sysctl -a + $ jc sysctl -a Usage (module): -import jc -result = jc.parse('sysctl', sysctl_command_output) + import jc + result = jc.parse('sysctl', sysctl_command_output) -or + or -import jc.parsers.sysctl -result = jc.parsers.sysctl.parse(sysctl_command_output) + import jc.parsers.sysctl + result = jc.parsers.sysctl.parse(sysctl_command_output) Schema: -{ -"key1": string/integer/float, # best guess based on value -"key2": string/integer/float, -"key3": string/integer/float -} + { + "key1": string/integer/float, # best guess based on value + "key2": string/integer/float, + "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 - ... - } - - $ 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", - ... - } + $ 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 + ... + } + + $ 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", + ... + } @@ -83,18 +82,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/systemctl.md b/docs/parsers/systemctl.md index 73bd5968..30f1e9eb 100644 --- a/docs/parsers/systemctl.md +++ b/docs/parsers/systemctl.md @@ -7,62 +7,61 @@ jc - JSON CLI output utility `systemctl` command output parser Usage (cli): -$ systemctl | jc --systemctl + $ systemctl | jc --systemctl -or + or -$ jc systemctl + $ jc systemctl Usage (module): -import jc -result = jc.parse('systemctl', systemctl_command_output) + import jc + result = jc.parse('systemctl', systemctl_command_output) -or + or -import jc.parsers.systemctl -result = jc.parsers.systemctl.parse(systemctl_command_output) + import jc.parsers.systemctl + result = jc.parsers.systemctl.parse(systemctl_command_output) Schema: -[ -{ -"unit": string, -"load": string, -"active": string, -"sub": string, -"description": string -} -] + [ + { + "unit": string, + "load": string, + "active": string, + "sub": string, + "description": string + } + ] -**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"` - "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" - }, - ... - ] + $ 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": "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" + }, + ... + ] @@ -84,18 +83,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/systemctl_lj.md b/docs/parsers/systemctl_lj.md index 8c4ed608..de4ad1b7 100644 --- a/docs/parsers/systemctl_lj.md +++ b/docs/parsers/systemctl_lj.md @@ -7,79 +7,78 @@ jc - JSON CLI output utility `systemctl list-jobs` command output parser Usage (cli): -$ systemctl list-jobs | jc --systemctl-lj + $ systemctl list-jobs | jc --systemctl-lj -or + or -$ jc systemctl list-jobs + $ jc systemctl list-jobs Usage (module): -import jc -result = jc.parse('systemctl_lj', systemctl_lj_command_output) + import jc + result = jc.parse('systemctl_lj', systemctl_lj_command_output) -or + or -import jc.parsers.systemctl_lj -result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output) + import jc.parsers.systemctl_lj + result = jc.parsers.systemctl_lj.parse(systemctl_lj_command_output) Schema: -[ -{ -"job": integer, -"unit": string, -"type": string, -"state": string -} -] + [ + { + "job": integer, + "unit": string, + "type": string, + "state": string + } + ] -**Examples**: +Examples: - - $ systemctl list-jobs| jc --systemctl-lj -p - [ - { -- `"job"` - 3543, -- `"unit"` - "nginxAfterGlusterfs.service", -- `"type"` - "start", -- `"state"` - "waiting" - }, - { -- `"job"` - 3545, -- `"unit"` - "glusterReadyForLocalhostMount.service", -- `"type"` - "start", -- `"state"` - "running" - }, - { -- `"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"` - "3545", -- `"unit"` - "glusterReadyForLocalhostMount.service", -- `"type"` - "start", -- `"state"` - "running" - }, - { -- `"job"` - "3506", -- `"unit"` - "nginx.service", -- `"type"` - "start", -- `"state"` - "waiting" - } - ] + $ systemctl list-jobs| jc --systemctl-lj -p + [ + { + "job": 3543, + "unit": "nginxAfterGlusterfs.service", + "type": "start", + "state": "waiting" + }, + { + "job": 3545, + "unit": "glusterReadyForLocalhostMount.service", + "type": "start", + "state": "running" + }, + { + "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": "3545", + "unit": "glusterReadyForLocalhostMount.service", + "type": "start", + "state": "running" + }, + { + "job": "3506", + "unit": "nginx.service", + "type": "start", + "state": "waiting" + } + ] @@ -101,18 +100,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/systemctl_ls.md b/docs/parsers/systemctl_ls.md index 90f55518..41e0c74e 100644 --- a/docs/parsers/systemctl_ls.md +++ b/docs/parsers/systemctl_ls.md @@ -8,54 +8,53 @@ parser Usage (cli): -$ systemctl list-sockets | jc --systemctl-ls + $ systemctl list-sockets | jc --systemctl-ls -or + or -$ jc systemctl list-sockets + $ jc systemctl list-sockets Usage (module): -import jc -result = jc.parse('systemctl_ls', systemctl_ls_command_output) + import jc + result = jc.parse('systemctl_ls', systemctl_ls_command_output) -or + or -import jc.parsers.systemctl_ls -result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output) + import jc.parsers.systemctl_ls + result = jc.parsers.systemctl_ls.parse(systemctl_ls_command_output) Schema: -[ -{ -"listen": string, -"unit": string, -"activates": string -} -] + [ + { + "listen": string, + "unit": string, + "activates": string + } + ] -**Examples**: +Examples: - - $ systemctl list-sockets | jc --systemctl-ls -p - [ - { -- `"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/dmeventd-client", -- `"unit"` - "dm-event.socket", -- `"activates"` - "dm-event.service" - }, - ... - ] + $ systemctl list-sockets | jc --systemctl-ls -p + [ + { + "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/dmeventd-client", + "unit": "dm-event.socket", + "activates": "dm-event.service" + }, + ... + ] @@ -77,18 +76,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/systemctl_luf.md b/docs/parsers/systemctl_luf.md index 7c3635ed..99dedd49 100644 --- a/docs/parsers/systemctl_luf.md +++ b/docs/parsers/systemctl_luf.md @@ -8,50 +8,49 @@ parser Usage (cli): -$ systemctl list-unit-files | jc --systemctl-luf + $ systemctl list-unit-files | jc --systemctl-luf -or + or -$ jc systemctl list-unit-files + $ jc systemctl list-unit-files Usage (module): -import jc -result = jc.parse('systemctl_luf', systemctl_luf_command_output) + import jc + result = jc.parse('systemctl_luf', systemctl_luf_command_output) -or + or -import jc.parsers.systemctl_luf -result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output) + import jc.parsers.systemctl_luf + result = jc.parsers.systemctl_luf.parse(systemctl_luf_command_output) Schema: -[ -{ -"unit_file": string, -"state": string -} -] + [ + { + "unit_file": string, + "state": string + } + ] -**Examples**: +Examples: - - $ systemctl list-unit-files | jc --systemctl-luf -p - [ - { -- `"unit_file"` - "proc-sys-fs-binfmt_misc.automount", -- `"state"` - "static" - }, - { -- `"unit_file"` - "dev-hugepages.mount", -- `"state"` - "static" - }, - { -- `"unit_file"` - "dev-mqueue.mount", -- `"state"` - "static" - }, - ... - ] + $ systemctl list-unit-files | jc --systemctl-luf -p + [ + { + "unit_file": "proc-sys-fs-binfmt_misc.automount", + "state": "static" + }, + { + "unit_file": "dev-hugepages.mount", + "state": "static" + }, + { + "unit_file": "dev-mqueue.mount", + "state": "static" + }, + ... + ] @@ -73,18 +72,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/systeminfo.md b/docs/parsers/systeminfo.md index b682e0db..e8d62b09 100644 --- a/docs/parsers/systeminfo.md +++ b/docs/parsers/systeminfo.md @@ -17,205 +17,204 @@ the timezone field is UTC. Usage (cli): -$ systeminfo | jc --systeminfo + $ systeminfo | jc --systeminfo Usage (module): -import jc -result = jc.parse('systeminfo', systeminfo_command_output) + import jc + result = jc.parse('systeminfo', systeminfo_command_output) -or + or -import jc.parsers.systeminfo -result = jc.parsers.systeminfo.parse(systeminfo_command_output) + import jc.parsers.systeminfo + result = jc.parsers.systeminfo.parse(systeminfo_command_output) Schema: -{ -"host_name": string, -"os_name": string, -"os_version": string, -"os_manufacturer": string, -"os_configuration": string, -"os_build_type": string, -"registered_owner": string, -"registered_organization": string, -"product_id": string, -"original_install_date": string, -"original_install_date_epoch": integer, # [0] -"original_install_date_epoch_utc": integer, # [1] -"system_boot_time": string, -"system_boot_time_epoch": integer, # [0] -"system_boot_time_epoch_utc": integer, # [1] -"system_manufacturer": string, -"system_model": string, -"system_type": string, -"processors": [ -string -], -"bios_version": string, -"windows_directory": string, -"system_directory": string, -"boot_device": string, -"system_locale": string, -"input_locale": string, -"time_zone": string, -"total_physical_memory_mb": string, -"available_physical_memory_mb": integer, -"virtual_memory_max_size_mb": integer, -"virtual_memory_available_mb": integer, -"virtual_memory_in_use_mb": integer, -"page_file_locations": string, -"domain": string, -"logon_server": string, -"hotfixs": [ -string -], -"network_cards": [ -{ -"name": string, -"connection_name": string, -"status": string, -"dhcp_enabled": boolean, -"dhcp_server": string, -"ip_addresses": [ -string -] -} -], -"hyperv_requirements": { -"vm_monitor_mode_extensions": boolean, -"virtualization_enabled_in_firmware": boolean, -"second_level_address_translation": boolean, -"data_execution_prevention_available": boolean -} -} + { + "host_name": string, + "os_name": string, + "os_version": string, + "os_manufacturer": string, + "os_configuration": string, + "os_build_type": string, + "registered_owner": string, + "registered_organization": string, + "product_id": string, + "original_install_date": string, + "original_install_date_epoch": integer, # [0] + "original_install_date_epoch_utc": integer, # [1] + "system_boot_time": string, + "system_boot_time_epoch": integer, # [0] + "system_boot_time_epoch_utc": integer, # [1] + "system_manufacturer": string, + "system_model": string, + "system_type": string, + "processors": [ + string + ], + "bios_version": string, + "windows_directory": string, + "system_directory": string, + "boot_device": string, + "system_locale": string, + "input_locale": string, + "time_zone": string, + "total_physical_memory_mb": string, + "available_physical_memory_mb": integer, + "virtual_memory_max_size_mb": integer, + "virtual_memory_available_mb": integer, + "virtual_memory_in_use_mb": integer, + "page_file_locations": string, + "domain": string, + "logon_server": string, + "hotfixs": [ + string + ], + "network_cards": [ + { + "name": string, + "connection_name": string, + "status": string, + "dhcp_enabled": boolean, + "dhcp_server": string, + "ip_addresses": [ + string + ] + } + ], + "hyperv_requirements": { + "vm_monitor_mode_extensions": boolean, + "virtualization_enabled_in_firmware": boolean, + "second_level_address_translation": boolean, + "data_execution_prevention_available": boolean + } + } -[0] naive timestamp -[1] timezone-aware timestamp + [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"` - [ - "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"` - [ - "KB2693643", - "KB4601054" - ], -- `"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"` - [ - "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 - }, -- `"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"` - [ - "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"` - [ - "KB2693643", - "KB4601054" - ], -- `"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"` - [ - "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" - } - } + $ 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": [ + "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": [ + "KB2693643", + "KB4601054" + ], + "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": [ + "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 + }, + "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": [ + "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": [ + "KB2693643", + "KB4601054" + ], + "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": [ + "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" + } + } @@ -237,18 +236,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: win32 diff --git a/docs/parsers/time.md b/docs/parsers/time.md index 47517b87..8ed27227 100644 --- a/docs/parsers/time.md +++ b/docs/parsers/time.md @@ -12,131 +12,130 @@ Alternatively, the output from `/usr/bin/time` can be redirected to `STDOUT` so `jc` can receive it. Note: `/usr/bin/time` is similar but different from the Bash builtin -`time` command. + `time` command. Usage (cli): -$ /usr/bin/time -o timefile.out sleep 2; cat timefile.out | \\ -jc --time -p + $ /usr/bin/time -o timefile.out sleep 2; cat timefile.out | \\ + jc --time -p Usage (module): -import jc -result = jc.parse('time', time_command_output) + import jc + result = jc.parse('time', time_command_output) -or + or -import jc.parsers.time -result = jc.parsers.time.parse(time_command_output) + import jc.parsers.time + result = jc.parsers.time.parse(time_command_output) Schema: -Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage -https://man7.org/linux/man-pages/man1/time.1.html + Source: https://www.freebsd.org/cgi/man.cgi?query=getrusage + https://man7.org/linux/man-pages/man1/time.1.html -{ -"real_time": float, -"user_time": float, -"system_time": float, -"elapsed_time": string, -"elapsed_time_hours": integer, -"elapsed_time_minutes": integer, -"elapsed_time_seconds": integer, -"elapsed_time_centiseconds": integer, -"elapsed_time_total_seconds": float, -"cpu_percent": integer, # null if ? -"average_shared_text_size": integer, -"average_unshared_data_size": integer, -"average_unshared_stack_size": integer, -"average_shared_memory_size": integer, -"maximum_resident_set_size": integer, -"block_input_operations": integer, # [0] -"block_output_operations": integer, # [1] -"major_pagefaults": integer, -"minor_pagefaults": integer, -"swaps": integer, -"page_reclaims": integer, -"page_faults": integer, -"messages_sent": integer, -"messages_received": integer, -"signals_received": integer, -"voluntary_context_switches": integer, -"involuntary_context_switches": integer -"command_being_timed": string, -"average_stack_size": integer, -"average_total_size": integer, -"average_resident_set_size": integer, -"signals_delivered": integer, -"page_size": integer, -"exit_status": integer -} + { + "real_time": float, + "user_time": float, + "system_time": float, + "elapsed_time": string, + "elapsed_time_hours": integer, + "elapsed_time_minutes": integer, + "elapsed_time_seconds": integer, + "elapsed_time_centiseconds": integer, + "elapsed_time_total_seconds": float, + "cpu_percent": integer, # null if ? + "average_shared_text_size": integer, + "average_unshared_data_size": integer, + "average_unshared_stack_size": integer, + "average_shared_memory_size": integer, + "maximum_resident_set_size": integer, + "block_input_operations": integer, # [0] + "block_output_operations": integer, # [1] + "major_pagefaults": integer, + "minor_pagefaults": integer, + "swaps": integer, + "page_reclaims": integer, + "page_faults": integer, + "messages_sent": integer, + "messages_received": integer, + "signals_received": integer, + "voluntary_context_switches": integer, + "involuntary_context_switches": integer + "command_being_timed": string, + "average_stack_size": integer, + "average_total_size": integer, + "average_resident_set_size": integer, + "signals_delivered": integer, + "page_size": integer, + "exit_status": integer + } -[0] aka File system inputs -[1] aka File system outputs + [0] aka File system inputs + [1] aka File system outputs -**Examples**: +Examples: - - $ /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 - } - - $ /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" - } + $ /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 + } + + $ /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" + } @@ -158,18 +157,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/timedatectl.md b/docs/parsers/timedatectl.md index 080c6f12..9a85832e 100644 --- a/docs/parsers/timedatectl.md +++ b/docs/parsers/timedatectl.md @@ -10,65 +10,64 @@ available if the `universal_time` field is available. Usage (cli): -$ timedatectl | jc --timedatectl + $ timedatectl | jc --timedatectl -or + or -$ jc timedatectl + $ jc timedatectl Usage (module): -import jc -result = jc.parse('timedatectl', timedatectl_command_output) + import jc + result = jc.parse('timedatectl', timedatectl_command_output) -or + or -import jc.parsers.timedatectl -result = jc.parsers.timedatectl.parse(timedatectl_command_output) + import jc.parsers.timedatectl + result = jc.parsers.timedatectl.parse(timedatectl_command_output) Schema: -{ -"local_time": string, -"universal_time": string, -"epoch_utc": integer, # timezone-aware -"rtc_time": string, -"time_zone": string, -"ntp_enabled": boolean, -"ntp_synchronized": boolean, -"system_clock_synchronized": boolean, -"systemd-timesyncd.service_active": boolean, -"rtc_in_local_tz": boolean, -"dst_active": boolean -} + { + "local_time": string, + "universal_time": string, + "epoch_utc": integer, # timezone-aware + "rtc_time": string, + "time_zone": string, + "ntp_enabled": boolean, + "ntp_synchronized": boolean, + "system_clock_synchronized": boolean, + "systemd-timesyncd.service_active": boolean, + "rtc_in_local_tz": boolean, + "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 - } - - $ 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" - } + $ 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 + } + + $ 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" + } @@ -90,18 +89,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/tracepath.md b/docs/parsers/tracepath.md index 2ffb09f3..1fa61a47 100644 --- a/docs/parsers/tracepath.md +++ b/docs/parsers/tracepath.md @@ -9,133 +9,132 @@ Supports `tracepath` and `tracepath6` output. Usage (cli): -$ tracepath 1.2.3.4 | jc --tracepath + $ tracepath 1.2.3.4 | jc --tracepath -or + or -$ jc tracepath 1.2.3.4 + $ jc tracepath 1.2.3.4 Usage (module): -import jc -result = jc.parse('tracepath', tracepath_command_output) + import jc + result = jc.parse('tracepath', tracepath_command_output) -or + or -import jc.parsers.tracepath -result = jc.parsers.tracepath.parse(tracepath_command_output) + import jc.parsers.tracepath + result = jc.parsers.tracepath.parse(tracepath_command_output) Schema: -{ -"pmtu": integer, -"forward_hops": integer, -"return_hops": integer, -"hops": [ -{ -"ttl": integer, -"guess": boolean, -"host": string, -"reply_ms": float, -"pmtu": integer, -"asymmetric_difference": integer, -"reached": boolean -} -] -} + { + "pmtu": integer, + "forward_hops": integer, + "return_hops": integer, + "hops": [ + { + "ttl": integer, + "guess": boolean, + "host": string, + "reply_ms": float, + "pmtu": integer, + "asymmetric_difference": integer, + "reached": boolean + } + ] + } -**Examples**: +Examples: - - $ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p - { -- `"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"` - 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"` - "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"` - [ - { -- `"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"` - "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 - } - ] - } + $ tracepath6 3ffe:2400:0:109::2 | jc --tracepath -p + { + "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": 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": "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": [ + { + "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": "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 + } + ] + } @@ -157,18 +156,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/traceroute.md b/docs/parsers/traceroute.md index a77b62bf..c802f642 100644 --- a/docs/parsers/traceroute.md +++ b/docs/parsers/traceroute.md @@ -8,123 +8,122 @@ jc - JSON CLI output utility `traceroute` command output parser Supports `traceroute` and `traceroute6` output. Note: On some operating systems you will need to redirect `STDERR` to -`STDOUT` for destination info since the header line is sent to -`STDERR`. A warning message will be printed to `STDERR` if the -header row is not found. + `STDOUT` for destination info since the header line is sent to + `STDERR`. A warning message will be printed to `STDERR` if the + header row is not found. -e.g. `$ traceroute 8.8.8.8 2>&1 | jc --traceroute` + e.g. `$ traceroute 8.8.8.8 2>&1 | jc --traceroute` Usage (cli): -$ traceroute 1.2.3.4 | jc --traceroute + $ traceroute 1.2.3.4 | jc --traceroute -or + or -$ jc traceroute 1.2.3.4 + $ jc traceroute 1.2.3.4 Usage (module): -import jc -result = jc.parse('traceroute', traceroute_command_output) + import jc + result = jc.parse('traceroute', traceroute_command_output) -or + or -import jc.parsers.traceroute -result = jc.parsers.traceroute.parse(traceroute_command_output) + import jc.parsers.traceroute + result = jc.parsers.traceroute.parse(traceroute_command_output) Schema: -{ -"destination_ip": string, -"destination_name": string, -"hops": [ -{ -"hop": integer, -"probes": [ -{ -"annotation": string, -"asn": integer, -"ip": string, -"name": string, -"rtt": float -} -] -} -] -} + { + "destination_ip": string, + "destination_name": string, + "hops": [ + { + "hop": integer, + "probes": [ + { + "annotation": string, + "asn": integer, + "ip": string, + "name": string, + "rtt": float + } + ] + } + ] + } -**Examples**: +Examples: - - $ traceroute google.com | jc --traceroute -p - { -- `"destination_ip"` - "216.58.194.46", -- `"destination_name"` - "google.com", -- `"hops"` - [ - { -- `"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"` - null - }, - { -- `"annotation"` - null, -- `"asn"` - null, -- `"ip"` - "216.230.231.141", -- `"name"` - "216-230-231-141.static.houston.tx.oplink.net", -- `"rtt"` - 198.65 - } - ] - }, - ... - ] - } - - $ traceroute google.com | jc --traceroute -p -r - { -- `"destination_ip"` - "216.58.194.46", -- `"destination_name"` - "google.com", -- `"hops"` - [ - { -- `"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"` - null - }, - { -- `"annotation"` - null, -- `"asn"` - null, -- `"ip"` - "216.230.231.141", -- `"name"` - "216-230-231-141.static.houston.tx.oplink.net", -- `"rtt"` - "198.650" - } - ] - }, - ... - ] - } + $ traceroute google.com | jc --traceroute -p + { + "destination_ip": "216.58.194.46", + "destination_name": "google.com", + "hops": [ + { + "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": null + }, + { + "annotation": null, + "asn": null, + "ip": "216.230.231.141", + "name": "216-230-231-141.static.houston.tx.oplink.net", + "rtt": 198.65 + } + ] + }, + ... + ] + } + + $ traceroute google.com | jc --traceroute -p -r + { + "destination_ip": "216.58.194.46", + "destination_name": "google.com", + "hops": [ + { + "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": null + }, + { + "annotation": null, + "asn": null, + "ip": "216.230.231.141", + "name": "216-230-231-141.static.houston.tx.oplink.net", + "rtt": "198.650" + } + ] + }, + ... + ] + } @@ -194,18 +193,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/ufw.md b/docs/parsers/ufw.md index 1009576a..8c2b43fb 100644 --- a/docs/parsers/ufw.md +++ b/docs/parsers/ufw.md @@ -7,204 +7,203 @@ jc - JSON CLI output utility `ufw status` command output parser Usage (cli): -$ ufw status | jc --ufw + $ ufw status | jc --ufw -or + or -$ jc ufw status + $ jc ufw status Usage (module): -import jc -result = jc.parse('ufw', ufw_command_output) + import jc + result = jc.parse('ufw', ufw_command_output) -or + or -import jc.parsers.ufw -result = jc.parsers.ufw.parse(ufw_command_output) + import jc.parsers.ufw + result = jc.parsers.ufw.parse(ufw_command_output) Schema: -{ -"status": string, -"logging": string, -"logging_level": string, -"default": string, -"new_profiles": string, -"rules": [ -{ -"action": string, -"action_direction": string, # null if blank -"index": integer, # null if blank -"network_protocol": string, -"to_ip": string, -"to_ip_prefix": integer, -"to_interface": string, -"to_transport": string, -"to_ports": [ -integer -], -"to_port_ranges": [ -{ -"start": integer, -"end": integer -} -], -"to_service": string, # [0] -"from_ip": string, -"from_ip_prefix": integer, -"from_interface": string, -"from_transport": string, -"from_ports": [ -integer -], -"from_port_ranges": [ -{ -"start": integer, -"end": integer -} -], -"from_service": string, # [1] -"comment": string # null if no comment -} -] -} + { + "status": string, + "logging": string, + "logging_level": string, + "default": string, + "new_profiles": string, + "rules": [ + { + "action": string, + "action_direction": string, # null if blank + "index": integer, # null if blank + "network_protocol": string, + "to_ip": string, + "to_ip_prefix": integer, + "to_interface": string, + "to_transport": string, + "to_ports": [ + integer + ], + "to_port_ranges": [ + { + "start": integer, + "end": integer + } + ], + "to_service": string, # [0] + "from_ip": string, + "from_ip_prefix": integer, + "from_interface": string, + "from_transport": string, + "from_ports": [ + integer + ], + "from_port_ranges": [ + { + "start": integer, + "end": integer + } + ], + "from_service": string, # [1] + "comment": string # null if no comment + } + ] + } -[0] null if any 'to' ports or port_ranges are set -[1] null if any 'from' ports or port_ranges are set + [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"` - [ - { -- `"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"` - [ - { -- `"start"` - 0, -- `"end"` - 65535 - } - ], -- `"from_service"` - null - }, - { -- `"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"` - [ - { -- `"start"` - 0, -- `"end"` - 65535 - } - ], -- `"from_service"` - null - }, - ... - ] - } - - $ 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"` - [ - { -- `"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"` - [ - { -- `"start"` - "0", -- `"end"` - "65535" - } - ], -- `"from_service"` - null - }, - { -- `"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"` - [ - { -- `"start"` - "0", -- `"end"` - "65535" - } - ], -- `"from_service"` - null - }, - ... - ] - } + $ ufw status verbose | jc --ufw -p + { + "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": [ + 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": [ + { + "start": 0, + "end": 65535 + } + ], + "from_service": null + }, + { + "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": [ + { + "start": 0, + "end": 65535 + } + ], + "from_service": null + }, + ... + ] + } + + $ 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": [ + { + "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": [ + { + "start": "0", + "end": "65535" + } + ], + "from_service": null + }, + { + "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": [ + { + "start": "0", + "end": "65535" + } + ], + "from_service": null + }, + ... + ] + } @@ -226,18 +225,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/ufw_appinfo.md b/docs/parsers/ufw_appinfo.md index 54e819ca..f72a19ce 100644 --- a/docs/parsers/ufw_appinfo.md +++ b/docs/parsers/ufw_appinfo.md @@ -15,134 +15,133 @@ lists and ranges that remove duplicate ports and merge overlapping ranges. Usage (cli): -$ ufw app info OpenSSH | jc --ufw-appinfo + $ ufw app info OpenSSH | jc --ufw-appinfo -or + or -$ jc ufw app info OpenSSH + $ jc ufw app info OpenSSH Usage (module): -import jc -result = jc.parse('ufw_appinfo', ufw_appinfo_command_output) + import jc + result = jc.parse('ufw_appinfo', ufw_appinfo_command_output) -or + or -import jc.parsers.ufw_appinfo -result = jc.parsers.ufw_appinfo.parse(ufw_appinfo_command_output) + import jc.parsers.ufw_appinfo + result = jc.parsers.ufw_appinfo.parse(ufw_appinfo_command_output) Schema: -[ -{ -"profile": string, -"title": string, -"description": string, -"tcp_list": [ -integer -], -"tcp_ranges": [ -{ -"start": integer, # [0] -"end": integer -} -], -"udp_list": [ -integer -], -"udp_ranges": [ -{ -"start": integer, # [0] -"end": integer -} -], -"normalized_tcp_list": [ -integers # [1] -], -"normalized_tcp_ranges": [ -{ -"start": integer, # [0] -"end": integers # [2] -} -], -"normalized_udp_list": [ -integers # [1] -], -"normalized_udp_ranges": [ -{ -"start": integer, # [0] -"end": integers # [2] -} -] -} -] + [ + { + "profile": string, + "title": string, + "description": string, + "tcp_list": [ + integer + ], + "tcp_ranges": [ + { + "start": integer, # [0] + "end": integer + } + ], + "udp_list": [ + integer + ], + "udp_ranges": [ + { + "start": integer, # [0] + "end": integer + } + ], + "normalized_tcp_list": [ + integers # [1] + ], + "normalized_tcp_ranges": [ + { + "start": integer, # [0] + "end": integers # [2] + } + ], + "normalized_udp_list": [ + integers # [1] + ], + "normalized_udp_ranges": [ + { + "start": integer, # [0] + "end": integers # [2] + } + ] + } + ] -[0] 'any' is converted to start/end: 0/65535 -[1] duplicates and overlapping are removed -[2] overlapping are merged + [0] 'any' is converted to start/end: 0/65535 + [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"` - [ - 1863, - 6901 - ], -- `"udp_list"` - [ - 1863, - 6901 - ], -- `"tcp_ranges"` - [ - { -- `"start"` - 6891, -- `"end"` - 6900 - } - ], -- `"normalized_tcp_list"` - [ - 1863, - 6901 - ], -- `"normalized_tcp_ranges"` - [ - { -- `"start"` - 6891, -- `"end"` - 6900 - } - ], -- `"normalized_udp_list"` - [ - 1863, - 6901 - ] - } - ] - - $ 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"` - [ - "1863", - "6901" - ], -- `"udp_list"` - [ - "1863", - "6901" - ], -- `"tcp_ranges"` - [ - { -- `"start"` - "6891", -- `"end"` - "6900" - } - ] - } - ] + $ ufw app info MSN | jc --ufw-appinfo -p + [ + { + "profile": "MSN", + "title": "MSN Chat", + "description": "MSN chat protocol (with file transfer and voice)", + "tcp_list": [ + 1863, + 6901 + ], + "udp_list": [ + 1863, + 6901 + ], + "tcp_ranges": [ + { + "start": 6891, + "end": 6900 + } + ], + "normalized_tcp_list": [ + 1863, + 6901 + ], + "normalized_tcp_ranges": [ + { + "start": 6891, + "end": 6900 + } + ], + "normalized_udp_list": [ + 1863, + 6901 + ] + } + ] + + $ 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": [ + "1863", + "6901" + ], + "udp_list": [ + "1863", + "6901" + ], + "tcp_ranges": [ + { + "start": "6891", + "end": "6900" + } + ] + } + ] @@ -164,18 +163,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/uname.md b/docs/parsers/uname.md index 7c59dba9..eed40e3c 100644 --- a/docs/parsers/uname.md +++ b/docs/parsers/uname.md @@ -9,49 +9,48 @@ Note: Must use `uname -a` Usage (cli): -$ uname -a | jc --uname + $ uname -a | jc --uname -or + or -$ jc uname -a + $ jc uname -a Usage (module): -import jc -result = jc.parse('uname', uname_command_output) + import jc + result = jc.parse('uname', uname_command_output) -or + or -import jc.parsers.uname -result = jc.parsers.uname.parse(uname_command_output) + import jc.parsers.uname + result = jc.parsers.uname.parse(uname_command_output) Schema: -{ -"kernel_name": string, -"node_name": string, -"kernel_release": string, -"operating_system": string, -"hardware_platform": string, -"processor": string, -"machine": string, -"kernel_version": string -} + { + "kernel_name": string, + "node_name": string, + "kernel_release": string, + "operating_system": string, + "hardware_platform": string, + "processor": string, + "machine": string, + "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" - } + $ 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" + } @@ -73,18 +72,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, freebsd diff --git a/docs/parsers/universal.md b/docs/parsers/universal.md index d9b7682e..96201ff8 100644 --- a/docs/parsers/universal.md +++ b/docs/parsers/universal.md @@ -14,23 +14,20 @@ def simple_table_parse(data) Parse simple tables. The last column may contain data with spaces. -**Arguments**: +Parameters: - -- `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 - lowercase by using .lower(). - - Also, ensure there are no blank lines (list items) - in the data. - + 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 + lowercase by using .lower(). -**Returns**: + Also, ensure there are no blank lines (list items) + in the data. - - List of Dictionaries +Returns: + + List of Dictionaries @@ -42,29 +39,26 @@ def sparse_table_parse(data, delim='\u2063') Parse tables with missing column data or with spaces in column data. -**Arguments**: +Parameters: - -- `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 - lowercase by using .lower(). Do not change the - position of header names as the positions are used - to find the data. - - Also, ensure there are no blank lines (list items) - in the data. - -- `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. - + 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 + lowercase by using .lower(). Do not change the + position of header names as the positions are used + to find the data. -**Returns**: + Also, ensure there are no blank lines (list items) + in the data. - - List of Dictionaries + 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: + + List of Dictionaries diff --git a/docs/parsers/upower.md b/docs/parsers/upower.md index a8b58381..33a20ad8 100644 --- a/docs/parsers/upower.md +++ b/docs/parsers/upower.md @@ -13,196 +13,195 @@ only available if the timezone field is UTC. Usage (cli): -$ upower -d | jc --upower + $ upower -d | jc --upower -or + or -$ jc upower -d + $ jc upower -d Usage (module): -import jc -result = jc.parse('upower', upower_command_output) + import jc + result = jc.parse('upower', upower_command_output) -or + or -import jc.parsers.upower -result = jc.parsers.upower.parse(upower_command_output) + import jc.parsers.upower + result = jc.parsers.upower.parse(upower_command_output) Schema: -[ -{ -"type": string, -"device_name": string, -"native_path": string, -"power_supply": boolean, -"updated": string, -"updated_epoch": integer, # [0] -"updated_epoch_utc": integer, # [0] -"updated_seconds_ago": integer, -"has_history": boolean, -"has_statistics": boolean, -"detail": { -"type": string, -"warning_level": string, # null if none -"online": boolean, -"icon_name": string -"present": boolean, -"rechargeable": boolean, -"state": string, -"energy": float, -"energy_unit": string, -"energy_empty": float, -"energy_empty_unit": string, -"energy_full": float, -"energy_full_unit": string, -"energy_full_design": float, -"energy_full_design_unit": string, -"energy_rate": float, -"energy_rate_unit": string, -"voltage": float, -"voltage_unit": string, -"time_to_full": float, -"time_to_full_unit": string, -"percentage": float, -"capacity": float, -"technology": string -}, -"history_charge": [ -{ -"time": integer, -"percent_charged": float, -"status": string -} -], -"history_rate":[ -{ -"time": integer, -"percent_charged": float, -"status": string -} -], -"daemon_version": string, -"on_battery": boolean, -"lid_is_closed": boolean, -"lid_is_present": boolean, -"critical_action": string -} -] + [ + { + "type": string, + "device_name": string, + "native_path": string, + "power_supply": boolean, + "updated": string, + "updated_epoch": integer, # [0] + "updated_epoch_utc": integer, # [0] + "updated_seconds_ago": integer, + "has_history": boolean, + "has_statistics": boolean, + "detail": { + "type": string, + "warning_level": string, # null if none + "online": boolean, + "icon_name": string + "present": boolean, + "rechargeable": boolean, + "state": string, + "energy": float, + "energy_unit": string, + "energy_empty": float, + "energy_empty_unit": string, + "energy_full": float, + "energy_full_unit": string, + "energy_full_design": float, + "energy_full_design_unit": string, + "energy_rate": float, + "energy_rate_unit": string, + "voltage": float, + "voltage_unit": string, + "time_to_full": float, + "time_to_full_unit": string, + "percentage": float, + "capacity": float, + "technology": string + }, + "history_charge": [ + { + "time": integer, + "percent_charged": float, + "status": string + } + ], + "history_rate":[ + { + "time": integer, + "percent_charged": float, + "status": string + } + ], + "daemon_version": string, + "on_battery": boolean, + "lid_is_closed": boolean, + "lid_is_present": boolean, + "critical_action": string + } + ] -[0] null if date-time conversion fails + [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" - }, -- `"history_charge"` - [ - { -- `"time"` - 1328809335, -- `"percent_charged"` - 42.547, -- `"status"` - "charging" - }, - { -- `"time"` - 1328809305, -- `"percent_charged"` - 42.02, -- `"status"` - "charging" - } - ], -- `"history_rate"` - [ - { -- `"time"` - 1328809335, -- `"percent_charged"` - 31.691, -- `"status"` - "charging" - } - ], -- `"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" - }, -- `"history_charge"` - [ - { -- `"time"` - "1328809335", -- `"percent_charged"` - "42.547", -- `"status"` - "charging" - }, - { -- `"time"` - "1328809305", -- `"percent_charged"` - "42.020", -- `"status"` - "charging" - } - ], -- `"history_rate"` - [ - { -- `"time"` - "1328809335", -- `"percent_charged"` - "31.691", -- `"status"` - "charging" - } - ] - } - ] + $ 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" + }, + "history_charge": [ + { + "time": 1328809335, + "percent_charged": 42.547, + "status": "charging" + }, + { + "time": 1328809305, + "percent_charged": 42.02, + "status": "charging" + } + ], + "history_rate": [ + { + "time": 1328809335, + "percent_charged": 31.691, + "status": "charging" + } + ], + "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" + }, + "history_charge": [ + { + "time": "1328809335", + "percent_charged": "42.547", + "status": "charging" + }, + { + "time": "1328809305", + "percent_charged": "42.020", + "status": "charging" + } + ], + "history_rate": [ + { + "time": "1328809335", + "percent_charged": "31.691", + "status": "charging" + } + ] + } + ] @@ -224,18 +223,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/uptime.md b/docs/parsers/uptime.md index 9b62983c..302d279a 100644 --- a/docs/parsers/uptime.md +++ b/docs/parsers/uptime.md @@ -7,69 +7,68 @@ jc - JSON CLI output utility `uptime` command output parser Usage (cli): -$ uptime | jc --uptime + $ uptime | jc --uptime -or + or -$ jc uptime + $ jc uptime Usage (module): -import jc -result = jc.parse('uptime', uptime_command_output) + import jc + result = jc.parse('uptime', uptime_command_output) -or + or -import jc.parsers.uptime -result = jc.parsers.uptime.parse(uptime_command_output) + import jc.parsers.uptime + result = jc.parsers.uptime.parse(uptime_command_output) Schema: -{ -"time": string, -"time_hour": integer, -"time_minute": integer, -"time_second": integer, # null if not displayed -"uptime": string, -"uptime_days": integer, -"uptime_hours": integer, -"uptime_minutes": integer, -"uptime_total_seconds": integer, -"users": integer, -"load_1m": float, -"load_5m": float, -"load_15m": float -} + { + "time": string, + "time_hour": integer, + "time_minute": integer, + "time_second": integer, # null if not displayed + "uptime": string, + "uptime_days": integer, + "uptime_hours": integer, + "uptime_minutes": integer, + "uptime_total_seconds": integer, + "users": integer, + "load_1m": float, + "load_5m": float, + "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 - } - - $ 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" - } + $ 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 + } + + $ 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" + } @@ -91,18 +90,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data + Dictionary. Raw or processed structured data ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/vmstat.md b/docs/parsers/vmstat.md index 18b08ffa..9e5edeed 100644 --- a/docs/parsers/vmstat.md +++ b/docs/parsers/vmstat.md @@ -15,122 +15,121 @@ available if the timezone field is UTC. Usage (cli): -$ vmstat | jc --vmstat + $ vmstat | jc --vmstat -or + or -$ jc vmstat + $ jc vmstat Usage (module): -import jc -result = jc.parse('vmstat', vmstat_command_output) + import jc + result = jc.parse('vmstat', vmstat_command_output) -or + or -import jc.parsers.vmstat -result = jc.parsers.vmstat.parse(vmstat_command_output) + import jc.parsers.vmstat + result = jc.parsers.vmstat.parse(vmstat_command_output) Schema: -[ -{ -"runnable_procs": integer, -"uninterruptible_sleeping_procs": integer, -"virtual_mem_used": integer, -"free_mem": integer, -"buffer_mem": integer, -"cache_mem": integer, -"inactive_mem": integer, -"active_mem": integer, -"swap_in": integer, -"swap_out": integer, -"blocks_in": integer, -"blocks_out": integer, -"interrupts": integer, -"context_switches": integer, -"user_time": integer, -"system_time": integer, -"idle_time": integer, -"io_wait_time": integer, -"stolen_time": integer, -"disk": string, -"total_reads": integer, -"merged_reads": integer, -"sectors_read": integer, -"reading_ms": integer, -"total_writes": integer, -"merged_writes": integer, -"sectors_written": integer, -"writing_ms": integer, -"current_io": integer, -"io_seconds": integer, -"timestamp": string, -"timezone": string, -"epoch": integer, # [0] -"epoch_utc": integer # [1] -} -] + [ + { + "runnable_procs": integer, + "uninterruptible_sleeping_procs": integer, + "virtual_mem_used": integer, + "free_mem": integer, + "buffer_mem": integer, + "cache_mem": integer, + "inactive_mem": integer, + "active_mem": integer, + "swap_in": integer, + "swap_out": integer, + "blocks_in": integer, + "blocks_out": integer, + "interrupts": integer, + "context_switches": integer, + "user_time": integer, + "system_time": integer, + "idle_time": integer, + "io_wait_time": integer, + "stolen_time": integer, + "disk": string, + "total_reads": integer, + "merged_reads": integer, + "sectors_read": integer, + "reading_ms": integer, + "total_writes": integer, + "merged_writes": integer, + "sectors_written": integer, + "writing_ms": integer, + "current_io": integer, + "io_seconds": integer, + "timestamp": string, + "timezone": string, + "epoch": integer, # [0] + "epoch_utc": integer # [1] + } + ] -[0] naive timestamp if -t flag is used -[1] aware timestamp if -t flag is used and UTC TZ + [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 - } - ] - - $ 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 - } - ] + $ 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 + } + ] + + $ 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 + } + ] @@ -152,18 +151,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux diff --git a/docs/parsers/vmstat_s.md b/docs/parsers/vmstat_s.md index f6e58020..13fe3d6d 100644 --- a/docs/parsers/vmstat_s.md +++ b/docs/parsers/vmstat_s.md @@ -17,7 +17,7 @@ available if the timezone field is UTC. Usage (cli): -$ vmstat | jc --vmstat-s + $ vmstat | jc --vmstat-s > Note: When piping `jc` converted `vmstat` output to other processes it may appear the output is hanging due to the OS pipe buffers. This is because @@ -28,83 +28,82 @@ for more information. Usage (module): -import jc -# result is an iterable object (generator) -result = jc.parse('vmstat_s', vmstat_command_output.splitlines()) -for item in result: -# do something + import jc + # result is an iterable object (generator) + result = jc.parse('vmstat_s', vmstat_command_output.splitlines()) + for item in result: + # do something -or + or -import jc.parsers.vmstat_s -# result is an iterable object (generator) -result = jc.parsers.vmstat_s.parse(vmstat_command_output.splitlines()) -for item in result: -# do something + import jc.parsers.vmstat_s + # result is an iterable object (generator) + result = jc.parsers.vmstat_s.parse(vmstat_command_output.splitlines()) + for item in result: + # do something Schema: -{ -"runnable_procs": integer, -"uninterruptible_sleeping_procs": integer, -"virtual_mem_used": integer, -"free_mem": integer, -"buffer_mem": integer, -"cache_mem": integer, -"inactive_mem": integer, -"active_mem": integer, -"swap_in": integer, -"swap_out": integer, -"blocks_in": integer, -"blocks_out": integer, -"interrupts": integer, -"context_switches": integer, -"user_time": integer, -"system_time": integer, -"idle_time": integer, -"io_wait_time": integer, -"stolen_time": integer, -"disk": string, -"total_reads": integer, -"merged_reads": integer, -"sectors_read": integer, -"reading_ms": integer, -"total_writes": integer, -"merged_writes": integer, -"sectors_written": integer, -"writing_ms": integer, -"current_io": integer, -"io_seconds": integer, -"timestamp": string, -"timezone": string, -"epoch": integer, # [0] -"epoch_utc": integer # [1] + { + "runnable_procs": integer, + "uninterruptible_sleeping_procs": integer, + "virtual_mem_used": integer, + "free_mem": integer, + "buffer_mem": integer, + "cache_mem": integer, + "inactive_mem": integer, + "active_mem": integer, + "swap_in": integer, + "swap_out": integer, + "blocks_in": integer, + "blocks_out": integer, + "interrupts": integer, + "context_switches": integer, + "user_time": integer, + "system_time": integer, + "idle_time": integer, + "io_wait_time": integer, + "stolen_time": integer, + "disk": string, + "total_reads": integer, + "merged_reads": integer, + "sectors_read": integer, + "reading_ms": integer, + "total_writes": integer, + "merged_writes": integer, + "sectors_written": integer, + "writing_ms": integer, + "current_io": integer, + "io_seconds": integer, + "timestamp": string, + "timezone": string, + "epoch": integer, # [0] + "epoch_utc": integer # [1] -# Below object only exists if using -qq or ignore_exceptions=True + # Below object only exists if using -qq or ignore_exceptions=True -"_jc_meta": -{ -"success": boolean, # [2] -"error": string, # [3] -"line": string # [3] -} -} + "_jc_meta": + { + "success": boolean, # [2] + "error": string, # [3] + "line": string # [3] + } + } -[0] naive timestamp if -t flag is used -[1] aware timestamp if -t flag is used and UTC TZ -[2] false if error parsing -[3] exists if "success" is false + [0] naive timestamp if -t flag is used + [1] aware timestamp if -t flag is used and UTC TZ + [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...} - ... - - $ vmstat | jc --vmstat-s -r - {"runnable_procs":"2","uninterruptible_sleeping_procs":"0","virtua...} - ... + $ vmstat | jc --vmstat-s + {"runnable_procs":2,"uninterruptible_sleeping_procs":0,"virtual_mem...} + ... + + $ vmstat | jc --vmstat-s -r + {"runnable_procs":"2","uninterruptible_sleeping_procs":"0","virtua...} + ... @@ -126,27 +125,22 @@ def parse(data, raw=False, quiet=False, ignore_exceptions=False) Main text parsing generator function. Returns an iterator object. -**Arguments**: +Parameters: - -- `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 - + data: (iterable) line-based text data to parse + (e.g. sys.stdin or str.splitlines()) -**Yields**: + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True + ignore_exceptions: (boolean) ignore parsing exceptions if True - - Dictionary. Raw or processed structured data. - +Yields: -**Returns**: + Dictionary. Raw or processed structured data. - - Iterator object +Returns: + + Iterator object ## Parser Information Compatibility: linux diff --git a/docs/parsers/w.md b/docs/parsers/w.md index bb7d53f7..d675faa5 100644 --- a/docs/parsers/w.md +++ b/docs/parsers/w.md @@ -7,107 +7,106 @@ jc - JSON CLI output utility `w` command output parser Usage (cli): -$ w | jc --w + $ w | jc --w -or + or -$ jc w + $ jc w Usage (module): -import jc -result = jc.parse('w', w_command_output) + import jc + result = jc.parse('w', w_command_output) -or + or -import jc.parsers.w -result = jc.parsers.w.parse(w_command_output) + import jc.parsers.w + result = jc.parsers.w.parse(w_command_output) Schema: -[ -{ -"user": string, # '-' = null -"tty": string, # '-' = null -"from": string, # '-' = null -"login_at": string, # '-' = null -"idle": string, # '-' = null -"jcpu": string, -"pcpu": string, -"what": string # '-' = null -} -] + [ + { + "user": string, # '-' = null + "tty": string, # '-' = null + "from": string, # '-' = null + "login_at": string, # '-' = null + "idle": string, # '-' = null + "jcpu": string, + "pcpu": string, + "what": string # '-' = null + } + ] -**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"` - "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" - } - ] - - $ 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"` - "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" - } - ] + $ 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": "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" + } + ] + + $ 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": "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" + } + ] @@ -129,18 +128,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/wc.md b/docs/parsers/wc.md index 5d1967e0..3a363b04 100644 --- a/docs/parsers/wc.md +++ b/docs/parsers/wc.md @@ -7,58 +7,57 @@ jc - JSON CLI output utility `wc` command output parser Usage (cli): -$ wc file.txt | jc --wc + $ wc file.txt | jc --wc -or + or -$ jc wc file.txt + $ jc wc file.txt Usage (module): -import jc -result = jc.parse('wc', wc_command_output) + import jc + result = jc.parse('wc', wc_command_output) -or + or -import jc.parsers.wc -result = jc.parsers.wc.parse(wc_command_output) + import jc.parsers.wc + result = jc.parsers.wc.parse(wc_command_output) Schema: -[ -{ -"filename": string, -"lines": integer, -"words": integer, -"characters": integer -} -] + [ + { + "filename": string, + "lines": integer, + "words": integer, + "characters": integer + } + ] -**Examples**: +Examples: - - $ wc * | jc --wc -p - [ - { -- `"filename"` - "airport-I.json", -- `"lines"` - 1, -- `"words"` - 30, -- `"characters"` - 307 - }, - { -- `"filename"` - "airport-I.out", -- `"lines"` - 15, -- `"words"` - 33, -- `"characters"` - 348 - }, - { -- `"filename"` - "airport-s.json", -- `"lines"` - 1, -- `"words"` - 202, -- `"characters"` - 2152 - }, - ... - ] + $ wc * | jc --wc -p + [ + { + "filename": "airport-I.json", + "lines": 1, + "words": 30, + "characters": 307 + }, + { + "filename": "airport-I.out", + "lines": 15, + "words": 33, + "characters": 348 + }, + { + "filename": "airport-s.json", + "lines": 1, + "words": 202, + "characters": 2152 + }, + ... + ] @@ -80,18 +79,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/who.md b/docs/parsers/who.md index 1c3b8e85..1640a94a 100644 --- a/docs/parsers/who.md +++ b/docs/parsers/who.md @@ -12,134 +12,133 @@ time of the system the parser is run on) Usage (cli): -$ who | jc --who + $ who | jc --who -or + or -$ jc who + $ jc who Usage (module): -import jc -result = jc.parse('who', who_command_output) + import jc + result = jc.parse('who', who_command_output) -or + or -import jc.parsers.who -result = jc.parsers.who.parse(who_command_output) + import jc.parsers.who + result = jc.parsers.who.parse(who_command_output) Schema: -[ -{ -"user": string, -"event": string, -"writeable_tty": string, -"tty": string, -"time": string, -"epoch": integer, # [0] -"idle": string, -"pid": integer, -"from": string, -"comment": string -} -] + [ + { + "user": string, + "event": string, + "writeable_tty": string, + "tty": string, + "time": string, + "epoch": integer, # [0] + "idle": string, + "pid": integer, + "from": string, + "comment": string + } + ] -[0] naive timestamp. null if time cannot be converted + [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 - }, - { -- `"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"` - "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 - } - ] - - $ who -a | jc --who -p -r - [ - { -- `"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"` - "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"` - "ttys004", -- `"time"` - "Mar 1 16:35", -- `"idle"` - ".", -- `"pid"` - "15679", -- `"from"` - "192.168.1.5" - } - ] + $ who -a | jc --who -p + [ + { + "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": "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": "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" + }, + { + "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": "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" + } + ] @@ -161,18 +160,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, aix, freebsd diff --git a/docs/parsers/xml.md b/docs/parsers/xml.md index 03a87369..fbc76326 100644 --- a/docs/parsers/xml.md +++ b/docs/parsers/xml.md @@ -7,74 +7,73 @@ jc - JSON CLI output utility `XML` file parser Usage (cli): -$ cat foo.xml | jc --xml + $ cat foo.xml | jc --xml Usage (module): -import jc -result = jc.parse('xml', xml_file_output) + import jc + result = jc.parse('xml', xml_file_output) -or + or -import jc.parsers.xml -result = jc.parsers.xml.parse(xml_file_output) + import jc.parsers.xml + result = jc.parsers.xml.parse(xml_file_output) Schema: -XML Document converted to a Dictionary -See https://github.com/martinblech/xmltodict for details + XML Document converted to a Dictionary + See https://github.com/martinblech/xmltodict for details -{ -"key1": string/object, -"key2": string/object -} + { + "key1": string/object, + "key2": string/object + } -**Examples**: +Examples: - - $ cat cd_catalog.xml - - - - Empire Burlesque - Bob Dylan - USA - Columbia - 10.90 - 1985 - - - Hide your heart - Bonnie Tyler - UK - CBS Records - 9.90 - 1988 - - ... - - $ cat cd_catalog.xml | jc --xml -p - { -- `"CATALOG"` - { -- `"CD"` - [ - { -- `"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" - }, - ... - } + $ cat cd_catalog.xml + + + + Empire Burlesque + Bob Dylan + USA + Columbia + 10.90 + 1985 + + + Hide your heart + Bonnie Tyler + UK + CBS Records + 9.90 + 1988 + + ... + + $ cat cd_catalog.xml | jc --xml -p + { + "CATALOG": { + "CD": [ + { + "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" + }, + ... + } @@ -96,18 +95,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - Dictionary. Raw or processed structured data. + Dictionary. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/yaml.md b/docs/parsers/yaml.md index 683ebc66..5ab389c1 100644 --- a/docs/parsers/yaml.md +++ b/docs/parsers/yaml.md @@ -7,88 +7,87 @@ jc - JSON CLI output utility `YAML` file parser Usage (cli): -$ cat foo.yaml | jc --yaml + $ cat foo.yaml | jc --yaml Usage (module): -import jc -result = jc.parse('yaml', yaml_file_output) + import jc + result = jc.parse('yaml', yaml_file_output) -or + or -import jc.parsers.yaml -result = jc.parsers.yaml.parse(yaml_file_output) + import jc.parsers.yaml + result = jc.parsers.yaml.parse(yaml_file_output) Schema: -YAML Document converted to a Dictionary -See https://pypi.org/project/ruamel.yaml for details + YAML Document converted to a Dictionary + See https://pypi.org/project/ruamel.yaml for details -[ -{ -"key1": string/int/float/boolean/null/array/object, -"key2": string/int/float/boolean/null/array/object -} -] + [ + { + "key1": string/int/float/boolean/null/array/object, + "key2": string/int/float/boolean/null/array/object + } + ] -**Examples**: +Examples: - - $ cat istio-mtls-permissive.yaml -- `apiVersion` - "authentication.istio.io/v1alpha1" -- `kind` - "Policy" - metadata: -- `name` - "default" -- `namespace` - "default" - spec: - peers: - - mtls: {} - --- -- `apiVersion` - "networking.istio.io/v1alpha3" -- `kind` - "DestinationRule" - metadata: -- `name` - "default" -- `namespace` - "default" - spec: -- `host` - "*.default.svc.cluster.local" - trafficPolicy: - tls: -- `mode` - ISTIO_MUTUAL - - $ cat istio-mtls-permissive.yaml | jc --yaml -p - [ - { -- `"apiVersion"` - "authentication.istio.io/v1alpha1", -- `"kind"` - "Policy", -- `"metadata"` - { -- `"name"` - "default", -- `"namespace"` - "default" - }, -- `"spec"` - { -- `"peers"` - [ - { -- `"mtls"` - {} - } - ] - } - }, - { -- `"apiVersion"` - "networking.istio.io/v1alpha3", -- `"kind"` - "DestinationRule", -- `"metadata"` - { -- `"name"` - "default", -- `"namespace"` - "default" - }, -- `"spec"` - { -- `"host"` - "*.default.svc.cluster.local", -- `"trafficPolicy"` - { -- `"tls"` - { -- `"mode"` - "ISTIO_MUTUAL" - } - } - } - } - ] + $ cat istio-mtls-permissive.yaml + apiVersion: "authentication.istio.io/v1alpha1" + kind: "Policy" + metadata: + name: "default" + namespace: "default" + spec: + peers: + - mtls: {} + --- + apiVersion: "networking.istio.io/v1alpha3" + kind: "DestinationRule" + metadata: + name: "default" + namespace: "default" + spec: + host: "*.default.svc.cluster.local" + trafficPolicy: + tls: + mode: ISTIO_MUTUAL + + $ cat istio-mtls-permissive.yaml | jc --yaml -p + [ + { + "apiVersion": "authentication.istio.io/v1alpha1", + "kind": "Policy", + "metadata": { + "name": "default", + "namespace": "default" + }, + "spec": { + "peers": [ + { + "mtls": {} + } + ] + } + }, + { + "apiVersion": "networking.istio.io/v1alpha3", + "kind": "DestinationRule", + "metadata": { + "name": "default", + "namespace": "default" + }, + "spec": { + "host": "*.default.svc.cluster.local", + "trafficPolicy": { + "tls": { + "mode": "ISTIO_MUTUAL" + } + } + } + } + ] @@ -110,18 +109,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries representing the YAML documents. + List of Dictionaries representing the YAML documents. ## Parser Information Compatibility: linux, darwin, cygwin, win32, aix, freebsd diff --git a/docs/parsers/zipinfo.md b/docs/parsers/zipinfo.md index db1508de..e8ad978b 100644 --- a/docs/parsers/zipinfo.md +++ b/docs/parsers/zipinfo.md @@ -12,78 +12,77 @@ Note: The default listing format. Usage (cli): -$ zipinfo | jc --zipinfo + $ zipinfo | jc --zipinfo -or + or -$ jc zipinfo + $ jc zipinfo Usage (module): -import jc -result = jc.parse('zipinfo', zipinfo_command_output) + import jc + result = jc.parse('zipinfo', zipinfo_command_output) -or + or -import jc.parsers.zipinfo -result = jc.parsers.zipinfo.parse(zipinfo_command_output) + import jc.parsers.zipinfo + result = jc.parsers.zipinfo.parse(zipinfo_command_output) Schema: -[ -{ -"archive": string, -"size": integer, -"size_unit": string, -"number_entries": integer, -"number_files": integer, -"bytes_uncompressed": integer, -"bytes_compressed": integer, -"percent_compressed": float, -"files": [ -{ -"flags": string, -"zipversion": string, -"zipunder": string -"filesize": integer, -"type": string, -"method": string, -"date": string, -"time": string, -"filename": string -} -] -} -] + [ + { + "archive": string, + "size": integer, + "size_unit": string, + "number_entries": integer, + "number_files": integer, + "bytes_uncompressed": integer, + "bytes_compressed": integer, + "percent_compressed": float, + "files": [ + { + "flags": string, + "zipversion": string, + "zipunder": string + "filesize": integer, + "type": string, + "method": string, + "date": string, + "time": string, + "filename": string + } + ] + } + ] -**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"` - [ - { -- `"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" - }, - ... + $ 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": [ + { + "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" + }, + ... @@ -105,18 +104,15 @@ def parse(data, raw=False, quiet=False) Main text parsing function -**Arguments**: +Parameters: - -- `data` - (string) text data to parse -- `raw` - (boolean) unprocessed output if True -- `quiet` - (boolean) suppress warning messages if True - + data: (string) text data to parse + raw: (boolean) unprocessed output if True + quiet: (boolean) suppress warning messages if True -**Returns**: +Returns: - - List of Dictionaries. Raw or processed structured data. + List of Dictionaries. Raw or processed structured data. ## Parser Information Compatibility: linux, darwin diff --git a/docs/utils.md b/docs/utils.md index c7a8bf92..642c794e 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -16,16 +16,13 @@ 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. -**Arguments**: +Parameters: - -- `message` - (list) list of string lines - + message: (list) list of string lines -**Returns**: +Returns: - - None - just prints output to STDERR + None - just prints output to STDERR @@ -39,16 +36,13 @@ 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. -**Arguments**: +Parameters: - -- `message` - (list) list of string lines - + message: (list) list of string lines -**Returns**: +Returns: - - None - just prints output to STDERR + None - just prints output to STDERR @@ -61,22 +55,19 @@ def compatibility(mod_name, compatible, quiet=False) Checks for the parser's compatibility with the running OS platform. -**Arguments**: +Parameters: - -- `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 - + mod_name: (string) __name__ of the calling module -**Returns**: + compatible: (list) sys.platform name(s) compatible with + the parser. compatible options: + linux, darwin, cygwin, win32, aix, freebsd - - None - just prints output to STDERR + quiet: (bool) supress compatibility message if True + +Returns: + + None - just prints output to STDERR @@ -89,17 +80,14 @@ def has_data(data) Checks if the input contains data. If there are any non-whitespace characters then return True, else return False. -**Arguments**: +Parameters: - -- `data` - (string) input to check whether it contains data - + data: (string) input to check whether it contains data -**Returns**: +Returns: - - Boolean True if input string (data) contains non-whitespace - characters, otherwise False + Boolean True if input string (data) contains non-whitespace + characters, otherwise False @@ -112,16 +100,13 @@ def convert_to_int(value) Converts string and float input to int. Strips all non-numeric characters from strings. -**Arguments**: +Parameters: - -- `value` - (string/integer/float) Input value - + value: (string/integer/float) Input value -**Returns**: +Returns: - - integer/None Integer if successful conversion, otherwise None + integer/None Integer if successful conversion, otherwise None @@ -134,16 +119,13 @@ def convert_to_float(value) Converts string and int input to float. Strips all non-numeric characters from strings. -**Arguments**: +Parameters: - -- `value` - (string) Input value - + value: (string) Input value -**Returns**: +Returns: - - float/None Float if successful conversion, otherwise None + float/None Float if successful conversion, otherwise None @@ -156,17 +138,14 @@ def convert_to_bool(value) Converts string, integer, or float input to boolean by checking for 'truthy' values. -**Arguments**: +Parameters: - -- `value` - (string/integer/float) Input value - + value: (string/integer/float) Input value -**Returns**: +Returns: - - True/False False unless a 'truthy' number or string is found - ('y', 'yes', 'true', '1', 1, -1, etc.) + True/False False unless a 'truthy' number or string is found + ('y', 'yes', 'true', '1', 1, -1, etc.) @@ -230,26 +209,23 @@ class timestamp() Input a date-time text string of several formats and convert to a naive or timezone-aware epoch timestamp in UTC. -**Arguments**: +Parameters: - -- `datetime_string` - (str) a string representation of a - date-time in several supported formats - + datetime_string: (str) a string representation of a + date-time in several supported formats -**Attributes**: +Attributes: - - string (str) the input datetime string - - format (int) the format rule that was used to - decode the datetime string. None if - conversion fails - - naive (int) timestamp based on locally configured - timezone. None if conversion fails - - utc (int) aware timestamp only if UTC timezone - detected in datetime string. None if - conversion fails + string (str) the input datetime string + + format (int) the format rule that was used to + decode the datetime string. None if + conversion fails + + naive (int) timestamp based on locally configured + timezone. None if conversion fails + + utc (int) aware timestamp only if UTC timezone + detected in datetime string. None if + conversion fails