Browse Source

fixed matching delimiters bug

master
Ben Savage 7 years ago
parent
commit
1af10ed6f6
  1. 9
      stanza

9
stanza

@ -8,6 +8,7 @@ from pprint import *
# Debug function
# Setup vars
buffering=False
buffered_lines=0
matched=False
output=''
@ -46,6 +47,7 @@ with open(cmd.filename,'r') if cmd.filename else sys.stdin as handle:
# Continue buffering if we've already started
if buffering:
buffered_lines+=1
output+=line
# If a line in the stanza matches, we output the stanza
@ -55,6 +57,9 @@ with open(cmd.filename,'r') if cmd.filename else sys.stdin as handle:
# Output/clear buffer when we encounter an end to the stanza
if re.search(end,line) and buffering==True:
# if we have the same start and end delimiters, assume there has to be one line differed. Alternatively we could check whether there are at least two on the line... but I'm lazy
if start == end and buffered_lines<=1:
continue
debug('Finished buffering on '+end)
if matched:
# Strip newlines if requrired
@ -65,7 +70,5 @@ with open(cmd.filename,'r') if cmd.filename else sys.stdin as handle:
buffering=False
matched=False
output=''
else:
output=''
buffering=False
buffered_lines=0

Loading…
Cancel
Save