From 5f771656e3fdd703d449b2817faa4faeff1cd879 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Thu, 12 Dec 2019 16:07:52 -0800 Subject: [PATCH] use universal parser --- jc/parsers/route.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/jc/parsers/route.py b/jc/parsers/route.py index 733fd39a..bd319c81 100644 --- a/jc/parsers/route.py +++ b/jc/parsers/route.py @@ -97,6 +97,7 @@ Examples: ] """ import jc.utils +import jc.parsers.universal def process(proc_data): @@ -161,13 +162,10 @@ def parse(data, raw=False, quiet=False): if not quiet: jc.utils.compatibility(__name__, compatible) - # code adapted from Conor Heine at: - # https://gist.github.com/cahna/43a1a3ff4d075bcd71f9d7120037a501 - cleandata = data.splitlines()[1:] - headers = [h for h in ' '.join(cleandata[0].lower().strip().split()).split() if h] - raw_data = map(lambda s: s.strip().split(None, len(headers) - 1), cleandata[1:]) - raw_output = [dict(zip(headers, r)) for r in raw_data] + cleandata[0] = cleandata[0].lower() + + raw_output = jc.parsers.universal.simple_table_parse(cleandata) if raw: return raw_output