すべてのタグ「依存関係」を見つけて結合し、それらを出力する次のコードがあります..今、最後の依存関係のみを取得し、出力は値です..予想される出力と現在の出力を以下に示します。
Current output:-
['348523', '350167', '350169', '348522', '350166', '350168', '350169', '350170', '350428', '350435', '350439', '350446', '350449', '350450', '350459', '350462', '350463', '350466', '350472', '350475', '350810', '350811', '350812', '350870', '350871', '350875', '350876', '350882', '350883', '350884', '350885', '348521']
Expected output:-
['348521','238567']
コード:-
import re
def findexternaldep ():
#print "Processing dependency for change %s", change
#change=str(change)
comments = ''' comments:
timestamp: 2013-06-12 09:18:36 PDT
reviewer:
name: user L
email: username@com.company.com
username: username
message: Patch Set 2:
Depends-on: 348523 350167 350169
timestamp: 2013-06-12 09:18:36 PDT
reviewer:
name: user L
email: username@com.company.com
username: username
message: Patch Set 2:
Depends-on: 348522 350166 350168 350169 350170 350428 350435 350439 350446 350449 350450 350459 350462 350463 350466 350472 350475 350810 350811 350812 350870 350871 350875 350876 350882 350883 350884 350885
comments:
timestamp: 2013-06-12 10:39:46 PDT
reviewer:
name: user L
email: username@com.company.com
username: username
message: Patch Set 2:
Depends-on: 348521 238567
'''
print "COMMENTS"
print comments
deps = ' '.join(re.findall(r'(?<=Depends-on:\s)[\d ]+(?=\n)', comments)).split()
print "DEPS"
print deps
#print depgerrit
return deps
def main ():
findexternaldep()
if __name__ == '__main__':
main()