mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
doc update
This commit is contained in:
@ -1,5 +1,11 @@
|
||||
jc changelog
|
||||
|
||||
20210408 v1.15.1
|
||||
- New feature to show parser documentation interactively with -h --parsername
|
||||
for example: $ jc -h --arp
|
||||
- Add man page to pypi package for easier packaging in homebrew
|
||||
- Add Systeminfo parser tested on Windows 10
|
||||
|
||||
20210407 v1.15.0
|
||||
- Add acpi command parser tested on linux
|
||||
- Add upower command parser tested on linux
|
||||
|
@ -17,6 +17,19 @@ Usage (module):
|
||||
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
|
||||
}
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -40,34 +53,7 @@ Example:
|
||||
```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:
|
||||
|
||||
{
|
||||
"kernel_name": string,
|
||||
"node_name": string,
|
||||
"kernel_release": string,
|
||||
"operating_system": string,
|
||||
"hardware_platform": string,
|
||||
"processor": string,
|
||||
"machine": string,
|
||||
"kernel_version": string
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -19,6 +19,68 @@ Usage (module):
|
||||
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, # null if date-time conversion fails
|
||||
"updated_epoch_utc": integer, # null if date-time conversion fails
|
||||
"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
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -138,83 +200,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,
|
||||
"device_name": string,
|
||||
"native_path": string,
|
||||
"power_supply": boolean,
|
||||
"updated": string,
|
||||
"updated_epoch": integer, # null if date-time conversion fails
|
||||
"updated_epoch_utc": integer, # null if date-time conversion fails
|
||||
"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
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,24 @@ Usage (module):
|
||||
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
|
||||
}
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -53,39 +71,7 @@ Example:
|
||||
```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:
|
||||
|
||||
{
|
||||
"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
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,21 @@ Usage (module):
|
||||
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
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -94,36 +109,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:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string, # '-'' = null
|
||||
"tty": string, # '-'' = null
|
||||
"from": string, # '-'' = null
|
||||
"login_at": string, # '-'' = null
|
||||
"idle": string, # '-'' = null
|
||||
"jcpu": string,
|
||||
"pcpu": string,
|
||||
"what": string # '-'' = null
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,17 @@ Usage (module):
|
||||
import jc.parsers.wc
|
||||
result = jc.parsers.wc.parse(wc_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"lines": integer,
|
||||
"words": integer,
|
||||
"characters": integer
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -49,32 +60,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,
|
||||
"lines": integer,
|
||||
"words": integer,
|
||||
"characters": integer
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -19,6 +19,23 @@ Usage (module):
|
||||
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, # naive timestamp. null if time cannot be converted
|
||||
"idle": string,
|
||||
"pid": integer,
|
||||
"from": string,
|
||||
"comment": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -121,38 +138,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:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string,
|
||||
"event": string,
|
||||
"writeable_tty": string,
|
||||
"tty": string,
|
||||
"time": string,
|
||||
"epoch": integer, # naive timestamp. null if time cannot be converted
|
||||
"idle": string,
|
||||
"pid": integer,
|
||||
"from": string,
|
||||
"comment": string
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -11,6 +11,16 @@ Usage (module):
|
||||
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
|
||||
|
||||
{
|
||||
"key1": string/object,
|
||||
"key2": string/object
|
||||
}
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -66,28 +76,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 representing an XML document:
|
||||
|
||||
{
|
||||
XML Document converted to a Dictionary
|
||||
See https://github.com/martinblech/xmltodict for details
|
||||
}
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -11,6 +11,18 @@ Usage (module):
|
||||
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
|
||||
|
||||
[
|
||||
{
|
||||
"key1": string/int/float/boolean/null/array/object,
|
||||
"key2": string/int/float/boolean/null/array/object
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -78,30 +90,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 YAML document:
|
||||
|
||||
[
|
||||
{
|
||||
YAML Document converted to a Dictionary
|
||||
See https://pypi.org/project/ruamel.yaml for details
|
||||
}
|
||||
]
|
||||
|
||||
Provides parser metadata (version, author, etc.)
|
||||
|
||||
## parse
|
||||
```python
|
||||
|
@ -15,6 +15,19 @@ Usage (module):
|
||||
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
|
||||
}
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'freebsd'
|
||||
@ -37,7 +50,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.4'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.5'
|
||||
description = '`uname -a` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -54,7 +68,7 @@ class ParseError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -64,18 +78,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following schema:
|
||||
|
||||
{
|
||||
"kernel_name": string,
|
||||
"node_name": string,
|
||||
"kernel_release": string,
|
||||
"operating_system": string,
|
||||
"hardware_platform": string,
|
||||
"processor": string,
|
||||
"machine": string,
|
||||
"kernel_version": string
|
||||
}
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
# nothing to process
|
||||
return proc_data
|
||||
@ -138,4 +141,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -17,6 +17,68 @@ Usage (module):
|
||||
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, # null if date-time conversion fails
|
||||
"updated_epoch_utc": integer, # null if date-time conversion fails
|
||||
"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
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux'
|
||||
@ -135,7 +197,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
description = '`upower` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -149,7 +212,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -159,67 +222,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"type": string,
|
||||
"device_name": string,
|
||||
"native_path": string,
|
||||
"power_supply": boolean,
|
||||
"updated": string,
|
||||
"updated_epoch": integer, # null if date-time conversion fails
|
||||
"updated_epoch_utc": integer, # null if date-time conversion fails
|
||||
"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
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
# time conversions
|
||||
@ -414,4 +417,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,24 @@ Usage (module):
|
||||
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
|
||||
}
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -50,7 +68,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`uptime` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -63,7 +82,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -73,23 +92,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary. Structured data with the following 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
|
||||
}
|
||||
Dictionary. Structured data to conform to the schema.
|
||||
"""
|
||||
if 'time' in proc_data:
|
||||
time_list = proc_data['time'].split(':')
|
||||
@ -186,4 +189,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,21 @@ Usage (module):
|
||||
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
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -92,7 +107,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = '`w` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -105,7 +121,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -115,20 +131,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string, # '-'' = null
|
||||
"tty": string, # '-'' = null
|
||||
"from": string, # '-'' = null
|
||||
"login_at": string, # '-'' = null
|
||||
"idle": string, # '-'' = null
|
||||
"jcpu": string,
|
||||
"pcpu": string,
|
||||
"what": string # '-'' = null
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
null_list = ['user', 'tty', 'from', 'login_at', 'idle', 'what']
|
||||
@ -196,4 +199,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -13,6 +13,17 @@ Usage (module):
|
||||
import jc.parsers.wc
|
||||
result = jc.parsers.wc.parse(wc_command_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"lines": integer,
|
||||
"words": integer,
|
||||
"characters": integer
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -46,7 +57,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.0'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
description = '`wc` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -59,7 +71,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -69,16 +81,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"filename": string,
|
||||
"lines": integer,
|
||||
"words": integer,
|
||||
"characters": integer
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
|
||||
for entry in proc_data:
|
||||
@ -126,4 +129,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -17,6 +17,23 @@ Usage (module):
|
||||
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, # naive timestamp. null if time cannot be converted
|
||||
"idle": string,
|
||||
"pid": integer,
|
||||
"from": string,
|
||||
"comment": string
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'aix', 'freebsd'
|
||||
@ -119,7 +136,8 @@ import jc.utils
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.2'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.3'
|
||||
description = '`who` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -133,7 +151,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -143,22 +161,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Structured data with the following schema:
|
||||
|
||||
[
|
||||
{
|
||||
"user": string,
|
||||
"event": string,
|
||||
"writeable_tty": string,
|
||||
"tty": string,
|
||||
"time": string,
|
||||
"epoch": integer, # naive timestamp. null if time cannot be converted
|
||||
"idle": string,
|
||||
"pid": integer,
|
||||
"from": string,
|
||||
"comment": string
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
for entry in proc_data:
|
||||
int_list = ['pid']
|
||||
@ -302,4 +305,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -9,6 +9,16 @@ Usage (module):
|
||||
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
|
||||
|
||||
{
|
||||
"key1": string/object,
|
||||
"key2": string/object
|
||||
}
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -70,7 +80,8 @@ except Exception:
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = 'XML file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -83,7 +94,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -93,12 +104,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
Dictionary representing an XML document:
|
||||
|
||||
{
|
||||
XML Document converted to a Dictionary
|
||||
See https://github.com/martinblech/xmltodict for details
|
||||
}
|
||||
Dictionary representing an XML document.
|
||||
"""
|
||||
|
||||
# No further processing
|
||||
@ -131,4 +137,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
@ -9,6 +9,18 @@ Usage (module):
|
||||
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
|
||||
|
||||
[
|
||||
{
|
||||
"key1": string/int/float/boolean/null/array/object,
|
||||
"key2": string/int/float/boolean/null/array/object
|
||||
}
|
||||
]
|
||||
|
||||
Compatibility:
|
||||
|
||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||
@ -82,7 +94,8 @@ except Exception:
|
||||
|
||||
|
||||
class info():
|
||||
version = '1.3'
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.4'
|
||||
description = 'YAML file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -95,7 +108,7 @@ class info():
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def process(proc_data):
|
||||
def _process(proc_data):
|
||||
"""
|
||||
Final processing to conform to the schema.
|
||||
|
||||
@ -105,14 +118,7 @@ def process(proc_data):
|
||||
|
||||
Returns:
|
||||
|
||||
List of Dictionaries. Each dictionary represents a YAML document:
|
||||
|
||||
[
|
||||
{
|
||||
YAML Document converted to a Dictionary
|
||||
See https://pypi.org/project/ruamel.yaml for details
|
||||
}
|
||||
]
|
||||
List of Dictionaries. Each dictionary represents a YAML document.
|
||||
"""
|
||||
|
||||
# No further processing
|
||||
@ -153,4 +159,4 @@ def parse(data, raw=False, quiet=False):
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return process(raw_output)
|
||||
return _process(raw_output)
|
||||
|
BIN
man/jc.1.gz
BIN
man/jc.1.gz
Binary file not shown.
Reference in New Issue
Block a user