mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
update docs
This commit is contained in:
@ -13,6 +13,19 @@ Usage (module):
|
|||||||
import jc.parsers.ini
|
import jc.parsers.ini
|
||||||
result = jc.parsers.ini.parse(ini_file_output)
|
result = jc.parsers.ini.parse(ini_file_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
ini or key/value document converted to a dictionary - see configparser standard
|
||||||
|
library documentation for more details.
|
||||||
|
|
||||||
|
Note: Values starting and ending with quotation marks will have the marks removed.
|
||||||
|
If you would like to keep the quotation marks, use the -r or raw=True argument.
|
||||||
|
|
||||||
|
{
|
||||||
|
"key1": string,
|
||||||
|
"key2": string
|
||||||
|
}
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd'
|
||||||
@ -56,7 +69,8 @@ import configparser
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.3'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.4'
|
||||||
description = 'INI file parser'
|
description = 'INI file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -69,7 +83,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -79,15 +93,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Dictionary representing an ini or simple key/value pair document:
|
Dictionary representing an ini or simple key/value pair document.
|
||||||
|
|
||||||
{
|
|
||||||
ini or key/value document converted to a dictionary - see configparser standard
|
|
||||||
library documentation for more details.
|
|
||||||
|
|
||||||
Note: Values starting and ending with quotation marks will have the marks removed.
|
|
||||||
If you would like to keep the quotation marks, use the -r or raw=True argument.
|
|
||||||
}
|
|
||||||
"""
|
"""
|
||||||
# remove quotation marks from beginning and end of values
|
# remove quotation marks from beginning and end of values
|
||||||
for heading in proc_data:
|
for heading in proc_data:
|
||||||
@ -145,4 +151,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -15,6 +15,29 @@ Usage (module):
|
|||||||
import jc.parsers.iptables
|
import jc.parsers.iptables
|
||||||
result = jc.parsers.iptables.parse(iptables_command_output)
|
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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -143,7 +166,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.4'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.5'
|
||||||
description = '`iptables` command parser'
|
description = '`iptables` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -156,7 +180,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -166,28 +190,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the 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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
for entry in proc_data:
|
for entry in proc_data:
|
||||||
for rule in entry['rules']:
|
for rule in entry['rules']:
|
||||||
@ -289,4 +292,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return process(raw_output)
|
return _process(raw_output)
|
||||||
|
@ -15,6 +15,16 @@ Usage (module):
|
|||||||
import jc.parsers.iw-scan
|
import jc.parsers.iw-scan
|
||||||
result = jc.parsers.iw-scan.parse(iw-scan_command_output)
|
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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux'
|
'linux'
|
||||||
@ -114,7 +124,8 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '0.5'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '0.6'
|
||||||
description = '`iw dev [device] scan` command parser'
|
description = '`iw dev [device] scan` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -128,7 +139,7 @@ class info():
|
|||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def _process(proc_data):
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
|
|
||||||
@ -138,14 +149,7 @@ def process(proc_data):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
List of Dictionaries. Structured data with the following schema:
|
List of Dictionaries. Structured data to conform to the schema.
|
||||||
[
|
|
||||||
{
|
|
||||||
"foo": string/integer/float, # best guess based on value
|
|
||||||
"bar": string/integer/float,
|
|
||||||
"baz": string/integer/float
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# convert ints and floats for top-level keys
|
# convert ints and floats for top-level keys
|
||||||
@ -174,7 +178,7 @@ def process(proc_data):
|
|||||||
return proc_data
|
return proc_data
|
||||||
|
|
||||||
|
|
||||||
def post_parse(data):
|
def _post_parse(data):
|
||||||
# remove empty items
|
# remove empty items
|
||||||
cleandata = []
|
cleandata = []
|
||||||
for ssid in data:
|
for ssid in data:
|
||||||
@ -276,7 +280,7 @@ def post_parse(data):
|
|||||||
item['vht_tx_highest_supported_mbps'] = item['vht_tx_highest_supported'].replace(' Mbps', '')
|
item['vht_tx_highest_supported_mbps'] = item['vht_tx_highest_supported'].replace(' Mbps', '')
|
||||||
del item['vht_tx_highest_supported']
|
del item['vht_tx_highest_supported']
|
||||||
|
|
||||||
return process(cleandata)
|
return _process(cleandata)
|
||||||
|
|
||||||
|
|
||||||
def parse(data, raw=False, quiet=False):
|
def parse(data, raw=False, quiet=False):
|
||||||
@ -331,4 +335,4 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if raw:
|
if raw:
|
||||||
return raw_output
|
return raw_output
|
||||||
else:
|
else:
|
||||||
return post_parse(raw_output)
|
return _post_parse(raw_output)
|
||||||
|
BIN
man/jc.1.gz
BIN
man/jc.1.gz
Binary file not shown.
Reference in New Issue
Block a user