每当retry
和last_submitted_tag_retry
相等时,我试图从下面的for和for循环中中断,但事实并非如此,如何从此循环中中断?
import re
retry = 0
last_submitted_tag_retry = 0
train = 'train1'
output = '''Thu Jan 24 18:08:18 2019 firstname lastname <first_last@company.com> submitted project-394 to train1
Thu Jan 24 18:08:18 2019 firstname lastname <first_last@company.com> forwarded project-394 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Thu Jan 24 19:18:47 2019 firstname lastname <first_last@company.com> submitted project-395 to train1
Thu Jan 24 19:18:47 2019 firstname lastname <first_last@company.com> forwarded project-395 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Fri Jan 25 14:52:00 2019 username System <username@company.com> submitted project-397 to train1
Fri Jan 25 14:52:00 2019 username System <username@company.com> forwarded project-397 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Wed Jan 30 14:40:43 2019 username System <username@company.com> submitted project-398 to train1
Wed Jan 30 14:40:43 2019 username System <username@company.com> forwarded project-398 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Sat Feb 2 17:28:10 2019 username System <username@company.com> submitted project-401 to train1
Sat Feb 2 17:28:10 2019 username System <username@company.com> forwarded project-401 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Sat Feb 2 17:31:11 2019 username System <username@company.com> submitted project-401 to train1
Sat Feb 2 17:31:11 2019 username System <username@company.com> forwarded project-401 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo'''
last_submitted_tag_retry = 0
retry = 0
while True:
print 'retry %s last_submitted_tag_retry %s'%(retry,last_submitted_tag_retry)
for line in reversed(output.splitlines()) :
line = line.strip()
#logger.info('line2')
print 'submissionInfo line%s'%line
#match = re.fullmatch(r"(?ms).*(?:submitted|forwarded)\s+(.*?)\s+to.*release2(?!.*project.*release2).*",output)
match = re.match(r'.*(submitted|forwarded)(.*) to .*\b%s\b.*'%train,line)
print'retry %s last_submitted_tag_retry %s'%(retry,last_submitted_tag_retry)
if retry != last_submitted_tag_retry:
print 'not equal'
retry +=1
elif retry == last_submitted_tag_retry:
print 'matches,breaking...'
break