From 38b8d696a99f86576e72869e9eeba3b1c3039b81 Mon Sep 17 00:00:00 2001 From: Colin Copeland Date: Tue, 26 May 2020 21:56:03 -0400 Subject: [PATCH] catch offenses with ampersands --- ciprs/parsers.py | 2 +- tests/test_parsers.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ciprs/parsers.py b/ciprs/parsers.py index dd5c6f1..823b352 100644 --- a/ciprs/parsers.py +++ b/ciprs/parsers.py @@ -118,7 +118,7 @@ class OffenseRecordRowWithNumber(Parser): """ # pylint: disable=line-too-long - pattern = r"\s*(?P[\d]+)\s*(?P\w+)\s+(?P[\w \-\(\)]+)[ ]{2,}(?P\w+)[ ]{2,}(?P[\w. \-\(\)]+)" + pattern = r"\s*(?P[\d]+)\s*(?P\w+)\s+(?P.+)[ ]{2,}(?P\w+)[ ]{2,}(?P[\w. \-\(\)]+)" def extract(self, matches, report): record = { diff --git a/tests/test_parsers.py b/tests/test_parsers.py index bce57ad..a7eee31 100644 --- a/tests/test_parsers.py +++ b/tests/test_parsers.py @@ -55,6 +55,16 @@ def test_offense_record_charged_with_number(line): assert matches["law"] == "G.S. 20-141(B)" +def test_offense_record_charged_with_number__ampersand(): + string = "54 CHARGED SPEEDING(80 & 65 mph zone) INFRACTION G.S. 20-141(B)" # noqa + matches = parsers.OffenseRecordRowWithNumber().match(string) + assert matches is not None, "Regex match failed" + assert matches["action"] == "CHARGED" + assert matches["desc"] == "SPEEDING(80 & 65 mph zone)" + assert matches["severity"] == "INFRACTION" + assert matches["law"] == "G.S. 20-141(B)" + + def test_offense_record_arrainged(): string = "ARRAIGNED SPEEDING(80 mph in a 65 mph zone) INFRACTION G.S. 20-141(B) 4450" # noqa matches = parsers.OffenseRecordRow().match(string)