1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
import re
description = \
"tgor3401,#20 trouduc#20 #20#20 a r=tgor3401, \
ti #124 dddsource#125 petrus#126.Ticket: 120 author=tgor3401, \
time=2006-09-15 15:19:21, , newvalue=closed. (#98) Ticket 120 \
author=tgor301t..Ticket #20, organise images into one !#678 \
ticket: 1111 ticket:111 folder [se:/#1 SVN Rn 1] abla#1234 ticket `#12`:trac:<>[4:2] -- \
Opens change set 42 </li><li>#42 -- Opens ticket number 42 </li><li>{1} -- Opens report 1 \
Changesets: r1, [2], changeset:3 or (restricted) [4/trunk], changeset:5/trunk, [6:9/trunk] changeset:berk"
searchstring = "changeset:\d+|\[\d+\]|\[\d+/\S+]|\[\d+:\d+/\S+]|\Wr\d+"
resultsPat = []
for x in re.compile(searchstring).findall(description):
if len(x): # for each changeset found
ltempo = []
for num in re.compile("\d+").findall(x): # take the number of revision
ltempo.append(int(num))
if len(ltempo) == 2 and int(ltempo[0]) < int(ltempo[1]) : # if there are 2 numbers, there is an interval
ltempo = range(int(ltempo[0]), int(ltempo[1])+1) # take all the revisions between first and last
print ltempo
resultsPat.extend(ltempo)
print resultsPat
#[1]
#[2]
#[3]
#[4]
#[5]
#[6, 7, 8, 9]
#[1, 2, 3, 4, 5, 6, 7, 8, 9] |
Partager