1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

update documentation

This commit is contained in:
Kelly Brazil
2021-04-08 12:42:01 -07:00
parent a4b6846f63
commit e28c08b136
46 changed files with 976 additions and 1209 deletions

View File

@ -13,6 +13,17 @@ Usage (module):
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
[
{
"column_name1": string,
"column_name2": string
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
@ -69,30 +80,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Each Dictionary represents a row in the csv file:
[
{
csv file converted to a Dictionary
https://docs.python.org/3/library/csv.html
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -19,6 +19,30 @@ Usage (module):
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, # naive timestamp
"epoch_utc": integer, # timezone-aware timestamp. Only available if timezone field is UTC
"timezone_aware": boolean # if true, all fields are correctly based on UTC
}
Compatibility:
'linux', 'darwin', 'freebsd'
@ -53,44 +77,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (Dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following 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, # naive timestamp
"epoch_utc": integer, # timezone-aware timestamp. Only available if timezone field is UTC
"timezone_aware": boolean # if true, all fields are correctly based on UTC
}
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -15,6 +15,25 @@ Usage (module):
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
}
]
Compatibility:
'linux', 'darwin', 'freebsd'
@ -84,40 +103,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following 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
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -19,6 +19,62 @@ Usage (module):
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
}
],
"question": {
"name": string,
"class": string,
"type": string
},
"answer": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"authority": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"query_time": integer, # in msec
"server": string,
"when": string,
"when_epoch": integer, # naive timestamp if when field is parsable, else null
"when_epoch_utc": integer, # timezone aware timestamp availabe for UTC, else null
"rcvd": integer
"size": string
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
@ -346,77 +402,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following 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
}
],
"question": {
"name": string,
"class": string,
"type": string
},
"answer": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"authority": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"query_time": integer, # in msec
"server": string,
"when": string,
"when_epoch": integer, # naive timestamp if when field is parsable, else null
"when_epoch_utc": integer, # timezone aware timestamp availabe for UTC, else null
"rcvd": integer
"size": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -23,6 +23,20 @@ Usage (module):
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
}
]
Compatibility:
'win32'
@ -112,35 +126,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (Dictionary of Lists) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"date": string,
"time": string,
"epoch": integer, # naive timestamp
"dir": boolean,
"size": integer,
"filename: string,
"parent": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -15,6 +15,23 @@ Usage (module):
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,
]
}
}
]
Compatibility:
'linux'
@ -114,38 +131,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"handle": string,
"type": integer,
"bytes": integer,
"description": string,
"values": { (null if empty)
"lowercase_no_spaces_keys": string,
"multiline_key_values": [
string,
]
}
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -19,6 +19,21 @@ Usage (module):
import jc.parsers.dpkg
result = jc.parsers.dpkg.parse(dpkg_command_output)
Schema:
[
{
"codes": string,
"name": string,
"version": string,
"architecture": string,
"description": string,
"desired": string,
"status": string,
"error": string
}
]
Compatibility:
'linux'
@ -121,36 +136,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"codes": string,
"name": string,
"version": string,
"architecture": string,
"description": string,
"desired": string,
"status": string,
"error": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -15,6 +15,15 @@ Usage (module):
import jc.parsers.du
result = jc.parsers.du.parse(du_command_output)
Schema:
[
{
"size": integer,
"name": string
}
]
Compatibility:
'linux', 'darwin', 'aix', 'freebsd'
@ -84,30 +93,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"size": integer,
"name": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -17,6 +17,15 @@ Usage (module):
import jc.parsers.env
result = jc.parsers.env.parse(env_command_output)
Schema:
[
{
"name": string,
"value": string
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
@ -66,30 +75,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (Dictionary) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"name": string,
"value": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -15,6 +15,15 @@ Usage (module):
import jc.parsers.file
result = jc.parsers.file.parse(file_command_output)
Schema:
[
{
"filename": string,
"type ": string
}
]
Compatibility:
'linux', 'aix', 'freebsd', 'darwin'
@ -59,30 +68,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"filename": string,
"type ": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -17,6 +17,24 @@ Usage (module):
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
}
]
Compatibility:
'linux', 'darwin', 'cygwin', freebsd'
@ -78,39 +96,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following 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
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -15,6 +15,20 @@ Usage (module):
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
}
]
Compatibility:
'linux'
@ -64,35 +78,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"type": string,
"total": integer,
"used": integer,
"free": integer,
"shared": integer,
"buff_cache": integer,
"available": integer
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -11,6 +11,19 @@ Usage (module):
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
}
]
Compatibility:
'linux', 'freebsd'
@ -78,34 +91,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"fs_spec": string,
"fs_file": string,
"fs_vfstype": string,
"fs_mntops": string,
"fs_freq": integer,
"fs_passno": integer
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -11,6 +11,19 @@ Usage (module):
import jc.parsers.group
result = jc.parsers.group.parse(group_file_output)
Schema:
[
{
"group_name": string,
"password": string,
"gid": integer,
"members": [
string
]
}
]
Compatibility:
'linux', 'darwin', 'aix', 'freebsd'
@ -102,34 +115,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"group_name": string,
"password": string,
"gid": integer,
"members": [
string
]
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -11,6 +11,21 @@ Usage (module):
import jc.parsers.gshadow
result = jc.parsers.gshadow.parse(gshadow_file_output)
Schema:
[
{
"group_name": string,
"password": string,
"administrators": [
string
],
"members": [
string
]
}
]
Compatibility:
'linux', 'aix', 'freebsd'
@ -68,36 +83,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"group_name": string,
"password": string,
"administrators": [
string
],
"members": [
string
]
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -11,6 +11,15 @@ Usage (module):
import jc.parsers.hash
result = jc.parsers.hash.parse(hash_command_output)
Schema:
[
{
"command": string,
"hits": integer
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
@ -34,30 +43,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"command": string,
"hits": integer
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -25,6 +25,15 @@ Usage (module):
import jc.parsers.hashsum
result = jc.parsers.hashsum.parse(md5sum_command_output)
Schema:
[
{
"filename": string,
"hash": string,
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
@ -65,30 +74,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"filename": string,
"hash": string,
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -15,6 +15,57 @@ Usage (module):
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
}
]
Compatibility:
'linux'
@ -272,72 +323,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following 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
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -13,6 +13,15 @@ Usage (module):
import jc.parsers.history
result = jc.parsers.history.parse(history_command_output)
Schema:
[
{
"line": integer,
"command": string
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
@ -54,30 +63,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (Dictionary) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"line": integer,
"command": string
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -11,6 +11,17 @@ Usage (module):
import jc.parsers.hosts
result = jc.parsers.hosts.parse(hosts_file_output)
Schema:
[
{
"ip": string,
"hostname": [
string
]
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
@ -69,32 +80,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"ip": string,
"hostname": [
string
]
}
]
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -15,6 +15,35 @@ Usage (module):
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
}
}
Compatibility:
'linux', 'darwin', 'aix', 'freebsd'
@ -82,50 +111,7 @@ Examples:
```python
info()
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (Dictionary) raw structured data to process
Returns:
Dictionary. Structured data with the following 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
}
}
Provides parser metadata (version, author, etc.)
## parse
```python

View File

@ -17,6 +17,41 @@ Usage (module):
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
}
]
Compatibility:
'linux', 'aix', 'freebsd', 'darwin'
@ -157,7 +192,7 @@ Examples:
```python
info()
```
Provides parser metadata (version, author, etc.)
## IfconfigParser
```python
@ -165,55 +200,6 @@ IfconfigParser(console_output)
```
## process
```python
process(proc_data)
```
Final processing to conform to the schema.
Parameters:
proc_data: (List of Dictionaries) raw structured data to process
Returns:
List of Dictionaries. Structured data with the following 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
}
]
## parse
```python
parse(data, raw=False, quiet=False)

View File

@ -11,6 +11,17 @@ Usage (module):
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
[
{
"column_name1": string,
"column_name2": string
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
@ -67,7 +78,8 @@ import csv
class info():
version = '1.1'
"""Provides parser metadata (version, author, etc.)"""
version = '1.2'
description = 'CSV file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -80,7 +92,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -90,14 +102,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Each Dictionary represents a row in the csv file:
[
{
csv file converted to a Dictionary
https://docs.python.org/3/library/csv.html
}
]
List of Dictionaries. Each Dictionary represents a row in the csv file.
"""
# No further processing
@ -143,4 +148,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -17,6 +17,30 @@ Usage (module):
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, # naive timestamp
"epoch_utc": integer, # timezone-aware timestamp. Only available if timezone field is UTC
"timezone_aware": boolean # if true, all fields are correctly based on UTC
}
Compatibility:
'linux', 'darwin', 'freebsd'
@ -51,7 +75,8 @@ import jc.utils
class info():
version = '2.0'
"""Provides parser metadata (version, author, etc.)"""
version = '2.1'
description = '`date` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -64,7 +89,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -74,28 +99,7 @@ def process(proc_data):
Returns:
Dictionary. Structured data with the following 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, # naive timestamp
"epoch_utc": integer, # timezone-aware timestamp. Only available if timezone field is UTC
"timezone_aware": boolean # if true, all fields are correctly based on UTC
}
Dictionary. Structured data to conform to the schema.
"""
# no further processing
return proc_data
@ -188,4 +192,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -13,6 +13,25 @@ Usage (module):
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
}
]
Compatibility:
'linux', 'darwin', 'freebsd'
@ -82,7 +101,8 @@ import jc.parsers.universal
class info():
version = '1.5'
"""Provides parser metadata (version, author, etc.)"""
version = '1.6'
description = '`df` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -95,7 +115,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -105,24 +125,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following 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
}
]
List of Dictionaries. Structured data to conform to the schema:
"""
for entry in proc_data:
@ -208,4 +211,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -17,6 +17,62 @@ Usage (module):
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
}
],
"question": {
"name": string,
"class": string,
"type": string
},
"answer": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"authority": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"query_time": integer, # in msec
"server": string,
"when": string,
"when_epoch": integer, # naive timestamp if when field is parsable, else null
"when_epoch_utc": integer, # timezone aware timestamp availabe for UTC, else null
"rcvd": integer
"size": string
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
@ -343,7 +399,8 @@ import jc.utils
class info():
version = '1.6'
"""Provides parser metadata (version, author, etc.)"""
version = '1.7'
description = '`dig` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -356,7 +413,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -366,61 +423,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following 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
}
],
"question": {
"name": string,
"class": string,
"type": string
},
"answer": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"authority": [
{
"name": string,
"class": string,
"type": string,
"ttl": integer,
"data": string
}
],
"query_time": integer, # in msec
"server": string,
"when": string,
"when_epoch": integer, # naive timestamp if when field is parsable, else null
"when_epoch_utc": integer, # timezone aware timestamp availabe for UTC, else null
"rcvd": integer
"size": string
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
@ -472,7 +475,7 @@ def process(proc_data):
return proc_data
def parse_header(header):
def _parse_header(header):
# ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 6140
header = header.split()
opcode = header[3].rstrip(',')
@ -484,7 +487,7 @@ def parse_header(header):
'status': status}
def parse_flags_line(flagsline):
def _parse_flags_line(flagsline):
# ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
flagsline = flagsline.split(';')
flags = flagsline.pop(0)
@ -508,7 +511,7 @@ def parse_flags_line(flagsline):
'additional_num': additional_num}
def parse_question(question):
def _parse_question(question):
# ;www.cnn.com. IN A
question = question.split()
dns_name = question[0].lstrip(';')
@ -520,7 +523,7 @@ def parse_question(question):
'type': dns_type}
def parse_authority(authority):
def _parse_authority(authority):
# cnn.com. 3600 IN NS ns-1086.awsdns-07.org.
authority = authority.split()
authority_name = authority[0]
@ -536,7 +539,7 @@ def parse_authority(authority):
'data': authority_data}
def parse_answer(answer):
def _parse_answer(answer):
# www.cnn.com. 5 IN CNAME turner-tls.map.fastly.net.
answer = answer.split(maxsplit=4)
answer_name = answer[0]
@ -556,7 +559,7 @@ def parse_answer(answer):
'data': answer_data}
def parse_axfr(axfr):
def _parse_axfr(axfr):
# ; <<>> DiG 9.11.14-3-Debian <<>> @81.4.108.41 axfr zonetransfer.me +nocookie
# ; (1 server found)
# ;; global options: +cmd
@ -617,17 +620,17 @@ def parse(data, raw=False, quiet=False):
continue
if ';' not in line and axfr:
axfr_list.append(parse_axfr(line))
axfr_list.append(_parse_axfr(line))
output_entry.update({'axfr': axfr_list})
continue
if line.startswith(';; ->>HEADER<<-'):
output_entry = {}
output_entry.update(parse_header(line))
output_entry.update(_parse_header(line))
continue
if line.startswith(';; flags:'):
output_entry.update(parse_flags_line(line))
output_entry.update(_parse_flags_line(line))
continue
if line.startswith(';; QUESTION SECTION:'):
@ -638,7 +641,7 @@ def parse(data, raw=False, quiet=False):
continue
if question:
output_entry['question'] = parse_question(line)
output_entry['question'] = _parse_question(line)
question = False
authority = False
answer = False
@ -654,7 +657,7 @@ def parse(data, raw=False, quiet=False):
continue
if ';' not in line and authority:
authority_list.append(parse_authority(line))
authority_list.append(_parse_authority(line))
output_entry.update({'authority': authority_list})
continue
@ -667,7 +670,7 @@ def parse(data, raw=False, quiet=False):
continue
if ';' not in line and answer:
answer_list.append(parse_answer(line))
answer_list.append(_parse_answer(line))
output_entry.update({'answer': answer_list})
continue
@ -704,4 +707,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -21,6 +21,20 @@ Usage (module):
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
}
]
Compatibility:
'win32'
@ -110,7 +124,8 @@ import jc.utils
class info():
version = '1.0'
"""Provides parser metadata (version, author, etc.)"""
version = '1.1'
description = '`dir` command parser'
author = 'Rasheed Elsaleh'
author_email = 'rasheed@rebelliondefense.com'
@ -123,7 +138,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -133,19 +148,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"date": string,
"time": string,
"epoch": integer, # naive timestamp
"dir": boolean,
"size": integer,
"filename: string,
"parent": string
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
# add timestamps
@ -216,4 +219,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -13,6 +13,23 @@ Usage (module):
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,
]
}
}
]
Compatibility:
'linux'
@ -111,7 +128,8 @@ import jc.utils
class info():
version = '1.1'
"""Provides parser metadata (version, author, etc.)"""
version = '1.2'
description = '`dmidecode` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -125,7 +143,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -135,22 +153,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"handle": string,
"type": integer,
"bytes": integer,
"description": string,
"values": { (null if empty)
"lowercase_no_spaces_keys": string,
"multiline_key_values": [
string,
]
}
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
int_list = ['type', 'bytes']
@ -347,4 +350,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -17,6 +17,21 @@ Usage (module):
import jc.parsers.dpkg
result = jc.parsers.dpkg.parse(dpkg_command_output)
Schema:
[
{
"codes": string,
"name": string,
"version": string,
"architecture": string,
"description": string,
"desired": string,
"status": string,
"error": string
}
]
Compatibility:
'linux'
@ -119,7 +134,8 @@ import jc.parsers.universal
class info():
version = '1.0'
"""Provides parser metadata (version, author, etc.)"""
version = '1.1'
description = '`dpkg -l` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -133,7 +149,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -143,20 +159,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"codes": string,
"name": string,
"version": string,
"architecture": string,
"description": string,
"desired": string,
"status": string,
"error": string
}
]
List of Dictionaries. Structured data to conform to the schema:
"""
for entry in proc_data:
if 'codes' in entry:
@ -245,4 +248,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -13,6 +13,15 @@ Usage (module):
import jc.parsers.du
result = jc.parsers.du.parse(du_command_output)
Schema:
[
{
"size": integer,
"name": string
}
]
Compatibility:
'linux', 'darwin', 'aix', 'freebsd'
@ -82,7 +91,8 @@ import jc.parsers.universal
class info():
version = '1.2'
"""Provides parser metadata (version, author, etc.)"""
version = '1.3'
description = '`du` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -96,7 +106,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -106,14 +116,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"size": integer,
"name": string
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = ['size']
for entry in proc_data:
@ -158,4 +161,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -15,6 +15,15 @@ Usage (module):
import jc.parsers.env
result = jc.parsers.env.parse(env_command_output)
Schema:
[
{
"name": string,
"value": string
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
@ -63,7 +72,8 @@ import jc.utils
class info():
version = '1.2'
"""Provides parser metadata (version, author, etc.)"""
version = '1.3'
description = '`env` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -76,7 +86,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -86,14 +96,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"name": string,
"value": string
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
# rebuild output for added semantic information
@ -139,4 +142,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -13,6 +13,15 @@ Usage (module):
import jc.parsers.file
result = jc.parsers.file.parse(file_command_output)
Schema:
[
{
"filename": string,
"type ": string
}
]
Compatibility:
'linux', 'aix', 'freebsd', 'darwin'
@ -57,7 +66,8 @@ import jc.parsers.universal
class info():
version = '1.2'
"""Provides parser metadata (version, author, etc.)"""
version = '1.3'
description = '`file` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -70,7 +80,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -80,14 +90,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"filename": string,
"type ": string
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
# No further processing
return proc_data
@ -137,4 +140,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -15,6 +15,24 @@ Usage (module):
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
}
]
Compatibility:
'linux', 'darwin', 'cygwin', freebsd'
@ -77,7 +95,8 @@ import jc.parsers.universal
class info():
version = '1.0'
"""Provides parser metadata (version, author, etc.)"""
version = '1.1'
description = '`finger` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -91,7 +110,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -101,23 +120,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following 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
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
if 'tty' in entry:
@ -212,4 +215,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -15,6 +15,16 @@ Usage (module):
import jc.parsers.foo
result = jc.parsers.foo.parse(foo_command_output)
Schema:
[
{
"foo": string,
"bar": boolean,
"baz": integer
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
@ -31,6 +41,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.0'
description = '`foo` command parser'
author = 'John Doe'
@ -45,7 +56,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -55,15 +66,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"foo": string,
"bar": boolean,
"baz": integer
}
]
List of Dictionaries. Structured to conform to the schema.
"""
# rebuild output for added semantic information
@ -98,4 +101,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -13,6 +13,20 @@ Usage (module):
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
}
]
Compatibility:
'linux'
@ -62,7 +76,8 @@ import jc.parsers.universal
class info():
version = '1.2'
"""Provides parser metadata (version, author, etc.)"""
version = '1.3'
description = '`free` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -75,7 +90,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -85,19 +100,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"type": string,
"total": integer,
"used": integer,
"free": integer,
"shared": integer,
"buff_cache": integer,
"available": integer
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
@ -147,4 +150,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -9,6 +9,19 @@ Usage (module):
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
}
]
Compatibility:
'linux', 'freebsd'
@ -75,7 +88,8 @@ import jc.utils
class info():
version = '1.3'
"""Provides parser metadata (version, author, etc.)"""
version = '1.4'
description = '`/etc/fstab` file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -87,7 +101,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -97,18 +111,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"fs_spec": string,
"fs_file": string,
"fs_vfstype": string,
"fs_mntops": string,
"fs_freq": integer,
"fs_passno": integer
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
int_list = ['fs_freq', 'fs_passno']
@ -174,4 +177,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -9,6 +9,19 @@ Usage (module):
import jc.parsers.group
result = jc.parsers.group.parse(group_file_output)
Schema:
[
{
"group_name": string,
"password": string,
"gid": integer,
"members": [
string
]
}
]
Compatibility:
'linux', 'darwin', 'aix', 'freebsd'
@ -99,7 +112,8 @@ import jc.utils
class info():
version = '1.1'
"""Provides parser metadata (version, author, etc.)"""
version = '1.2'
description = '`/etc/group` file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -112,7 +126,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -122,18 +136,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"group_name": string,
"password": string,
"gid": integer,
"members": [
string
]
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
int_list = ['gid']
@ -193,4 +196,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -9,6 +9,21 @@ Usage (module):
import jc.parsers.gshadow
result = jc.parsers.gshadow.parse(gshadow_file_output)
Schema:
[
{
"group_name": string,
"password": string,
"administrators": [
string
],
"members": [
string
]
}
]
Compatibility:
'linux', 'aix', 'freebsd'
@ -65,7 +80,8 @@ import jc.utils
class info():
version = '1.1'
"""Provides parser metadata (version, author, etc.)"""
version = '1.2'
description = '`/etc/gshadow` file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -78,7 +94,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -88,20 +104,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"group_name": string,
"password": string,
"administrators": [
string
],
"members": [
string
]
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
if entry['administrators'] == ['']:
@ -155,4 +158,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -9,6 +9,15 @@ Usage (module):
import jc.parsers.hash
result = jc.parsers.hash.parse(hash_command_output)
Schema:
[
{
"command": string,
"hits": integer
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
@ -32,7 +41,8 @@ import jc.parsers.universal
class info():
version = '1.0'
"""Provides parser metadata (version, author, etc.)"""
version = '1.1'
description = '`hash` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -44,7 +54,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -54,14 +64,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"command": string,
"hits": integer
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
# change to int
@ -105,4 +108,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -23,6 +23,15 @@ Usage (module):
import jc.parsers.hashsum
result = jc.parsers.hashsum.parse(md5sum_command_output)
Schema:
[
{
"filename": string,
"hash": string,
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
@ -62,7 +71,8 @@ import jc.utils
class info():
version = '1.0'
"""Provides parser metadata (version, author, etc.)"""
version = '1.1'
description = 'hashsum command parser (`md5sum`, `shasum`, etc.)'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -76,7 +86,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -86,14 +96,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"filename": string,
"hash": string,
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
# no further processing for this parser
@ -142,4 +145,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -13,6 +13,57 @@ Usage (module):
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
}
]
Compatibility:
'linux'
@ -269,7 +320,8 @@ import jc.utils
class info():
version = '1.0'
"""Provides parser metadata (version, author, etc.)"""
version = '1.1'
description = '`hciconfig` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -283,7 +335,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -293,56 +345,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following 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
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
@ -526,4 +529,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -11,6 +11,15 @@ Usage (module):
import jc.parsers.history
result = jc.parsers.history.parse(history_command_output)
Schema:
[
{
"line": integer,
"command": string
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
@ -51,7 +60,8 @@ import jc.utils
class info():
version = '1.3'
"""Provides parser metadata (version, author, etc.)"""
version = '1.4'
description = '`history` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -64,7 +74,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -74,14 +84,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"line": integer,
"command": string
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
# rebuild output for added semantic information
@ -132,4 +135,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -9,6 +9,17 @@ Usage (module):
import jc.parsers.hosts
result = jc.parsers.hosts.parse(hosts_file_output)
Schema:
[
{
"ip": string,
"hostname": [
string
]
}
]
Compatibility:
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
@ -66,7 +77,8 @@ import jc.utils
class info():
version = '1.2'
"""Provides parser metadata (version, author, etc.)"""
version = '1.3'
description = '`/etc/hosts` file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -78,7 +90,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -88,16 +100,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following schema:
[
{
"ip": string,
"hostname": [
string
]
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
# no additional processing needed
@ -157,4 +160,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -13,6 +13,35 @@ Usage (module):
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
}
}
Compatibility:
'linux', 'darwin', 'aix', 'freebsd'
@ -79,7 +108,8 @@ import jc.utils
class info():
version = '1.1'
"""Provides parser metadata (version, author, etc.)"""
version = '1.2'
description = '`id` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -93,7 +123,7 @@ class info():
__version__ = info.version
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -103,34 +133,7 @@ def process(proc_data):
Returns:
Dictionary. Structured data with the following 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
}
}
Dictionary. Structured data to conform to the schema.
"""
if 'uid' in proc_data:
if 'id' in proc_data['uid']:
@ -221,4 +224,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

View File

@ -15,6 +15,41 @@ Usage (module):
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
}
]
Compatibility:
'linux', 'aix', 'freebsd', 'darwin'
@ -156,7 +191,8 @@ import jc.utils
class info():
version = '1.8'
"""Provides parser metadata (version, author, etc.)"""
version = '1.9'
description = '`ifconfig` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@ -384,7 +420,7 @@ class InterfaceNotFound(Exception):
pass
def process(proc_data):
def _process(proc_data):
"""
Final processing to conform to the schema.
@ -394,40 +430,7 @@ def process(proc_data):
Returns:
List of Dictionaries. Structured data with the following 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
}
]
List of Dictionaries. Structured data to conform to the schema.
"""
for entry in proc_data:
int_list = ['flags', 'mtu', 'ipv6_mask', 'rx_packets', 'rx_bytes', 'rx_errors', 'rx_dropped', 'rx_overruns',
@ -496,4 +499,4 @@ def parse(data, raw=False, quiet=False):
if raw:
return raw_output
else:
return process(raw_output)
return _process(raw_output)

Binary file not shown.