Skip to content

Commit

Permalink
Simplify brackets_check(): reimplement without the generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
chisholm committed Sep 23, 2020
1 parent 0c298c8 commit 6c283b7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions stix2patterns/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ def brackets_check(pattern):
:return: True if the pattern had its brackets; False if not
"""
if isinstance(pattern, six.string_types):
# the non-whitespace chars
non_ws_chars = (c for c in pattern if not c.isspace())

# There can be an arbitrary number of open parens first... skip over those
c = next(non_ws_chars, None)
while c == "(":
c = next(non_ws_chars, None)
# There can be an arbitrary number of open parens first... skip over
# those
for c in pattern:
if c != "(" and not c.isspace():
break

if c == "[":
result = True
Expand Down

0 comments on commit 6c283b7

Please sign in to comment.