Skip to content

Commit

Permalink
attribute error in pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
yjmantilla committed Dec 2, 2021
1 parent 7690ba4 commit 6ebe862
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sovabids/parsers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Module with parser utilities."""
import re
from copy import deepcopy

from numpy import mat
from sovabids.misc import flat_paren_counter
from sovabids.dicts import deep_merge_N,nested_notation_to_tree

Expand Down Expand Up @@ -87,6 +89,10 @@ def parse_from_regex(string,pattern,fields):
if not num_fields == num_groups:
return {}
match = re.search(pattern,string)

if not hasattr(match, 'groups'):
raise AttributeError(f"Couldn't find fields in the string {string} using the pattern {pattern}. Recheck the pattern for errors.")

if not num_groups == len(match.groups()):
return {}

Expand Down

0 comments on commit 6ebe862

Please sign in to comment.