Skip to content

Commit

Permalink
Merge pull request #50 from nthall/parse_slashes_in_offense
Browse files Browse the repository at this point in the history
update OffenseRecordRow description regex
  • Loading branch information
robert-w-gries authored Apr 13, 2021
2 parents 59ea4bf + 2388739 commit 927cb89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ciprs_reader/parser/section/offense.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class OffenseRecordRow(OffenseSectionParser):
"""

# pylint: disable=line-too-long
pattern = r"\s*(?P<action>\w+)\s+(?P<desc>[\w \-\(\)]+)[ ]{2,}(?P<severity>\w+)[ ]{2,}(?P<law>[\w. \-\(\)]+)"
pattern = r"\s*(?P<action>\w+)\s+(?P<desc>.+)[ ]{2,}(?P<severity>\w+)[ ]{2,}(?P<law>[\w. \-\(\)]+)"

def is_enabled(self):
in_offense_section = super().is_enabled()
Expand Down
7 changes: 7 additions & 0 deletions tests/parsers/test_offense.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ def test_offense_record_arrainged(report, state):
assert matches["law"] == "G.S. 20-141(B)"


def test_offense_record_with_slashes(report, state):
string = "CONVICTED CITY/TOWN VIOLATION (I) INFRACTION LOCAL ORDINANCE"
matches = offense.OffenseRecordRow(report, state).match(string)
assert matches is not None, "Regex match failed"
assert matches["desc"] == "CITY/TOWN VIOLATION (I)"


def test_offense_record_convicted(report, state):
string = "CONVICTED IMPROPER EQUIP - SPEEDOMETER INFRACTION G.S. 20-123.2" # noqa
matches = offense.OffenseRecordRow(report, state).match(string)
Expand Down

0 comments on commit 927cb89

Please sign in to comment.