mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
new docstring format for improved documentation
This commit is contained in:
@ -17,6 +17,21 @@ Usage (module):
|
|||||||
import jc.parsers.arp
|
import jc.parsers.arp
|
||||||
result = jc.parsers.arp.parse(arp_command_output)
|
result = jc.parsers.arp.parse(arp_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"address": string,
|
||||||
|
"hwtype": string,
|
||||||
|
"hwaddress": string,
|
||||||
|
"flags_mask": string,
|
||||||
|
"iface": string,
|
||||||
|
"permanent": boolean,
|
||||||
|
"expires": integer
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'aix', 'freebsd', 'darwin'
|
'linux', 'aix', 'freebsd', 'darwin'
|
||||||
@ -108,36 +123,7 @@ Examples:
|
|||||||
```python
|
```python
|
||||||
info()
|
info()
|
||||||
```
|
```
|
||||||
|
Provides parser metadata (version, author, etc.)
|
||||||
|
|
||||||
## 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,
|
|
||||||
"address": string,
|
|
||||||
"hwtype": string,
|
|
||||||
"hwaddress": string,
|
|
||||||
"flags_mask": string,
|
|
||||||
"iface": string,
|
|
||||||
"permanent": boolean,
|
|
||||||
"expires": integer
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
## parse
|
## parse
|
||||||
```python
|
```python
|
||||||
|
@ -15,6 +15,21 @@ Usage (module):
|
|||||||
import jc.parsers.arp
|
import jc.parsers.arp
|
||||||
result = jc.parsers.arp.parse(arp_command_output)
|
result = jc.parsers.arp.parse(arp_command_output)
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": string,
|
||||||
|
"address": string,
|
||||||
|
"hwtype": string,
|
||||||
|
"hwaddress": string,
|
||||||
|
"flags_mask": string,
|
||||||
|
"iface": string,
|
||||||
|
"permanent": boolean,
|
||||||
|
"expires": integer
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
||||||
'linux', 'aix', 'freebsd', 'darwin'
|
'linux', 'aix', 'freebsd', 'darwin'
|
||||||
@ -106,7 +121,8 @@ import jc.parsers.universal
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.6'
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
version = '1.7'
|
||||||
description = '`arp` command parser'
|
description = '`arp` command parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -119,7 +135,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.
|
||||||
|
|
||||||
@ -129,20 +145,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:
|
||||||
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"name": string,
|
|
||||||
"address": string,
|
|
||||||
"hwtype": string,
|
|
||||||
"hwaddress": string,
|
|
||||||
"flags_mask": string,
|
|
||||||
"iface": string,
|
|
||||||
"permanent": boolean,
|
|
||||||
"expires": integer
|
|
||||||
}
|
|
||||||
]
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# in BSD style, change name to null if it is a question mark
|
# in BSD style, change name to null if it is a question mark
|
||||||
@ -212,7 +215,7 @@ 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)
|
||||||
|
|
||||||
# detect if linux style was used
|
# detect if linux style was used
|
||||||
elif cleandata[0].startswith('Address'):
|
elif cleandata[0].startswith('Address'):
|
||||||
@ -239,4 +242,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)
|
||||||
|
Reference in New Issue
Block a user