mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
use universal parser
This commit is contained in:
@ -103,6 +103,7 @@ Examples:
|
|||||||
]
|
]
|
||||||
"""
|
"""
|
||||||
import jc.utils
|
import jc.utils
|
||||||
|
import jc.parsers.universal
|
||||||
|
|
||||||
|
|
||||||
def process(proc_data):
|
def process(proc_data):
|
||||||
@ -163,14 +164,10 @@ def parse(data, raw=False, quiet=False):
|
|||||||
if not quiet:
|
if not quiet:
|
||||||
jc.utils.compatibility(__name__, compatible)
|
jc.utils.compatibility(__name__, compatible)
|
||||||
|
|
||||||
# code adapted from Conor Heine at:
|
|
||||||
# https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501
|
|
||||||
|
|
||||||
cleandata = data.splitlines()
|
cleandata = data.splitlines()
|
||||||
headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h]
|
cleandata[0] = cleandata[0].lower()
|
||||||
|
|
||||||
raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:])
|
raw_output = jc.parsers.universal.simple_table_parse(cleandata)
|
||||||
raw_output = [dict(zip(headers, r)) for r in raw_data]
|
|
||||||
|
|
||||||
for mod in raw_output:
|
for mod in raw_output:
|
||||||
if 'by' in mod:
|
if 'by' in mod:
|
||||||
|
Reference in New Issue
Block a user