Код: Выделить всё
import re
#Return a list containing every occurrence of "ai":
redmineToGitlabIdMap = dict()
redmineToGitlabIdMap[150767] = { 'iid': 1 }
redmineToGitlabIdMap[150768] = { 'iid': 2 }
redmineToGitlabIdMap[150769] = { 'iid': 3 }
description = '*(from redmine: issue id 150767, created on 2024-02-27 by **me**)*\n\n* Relations:\n * copied_to #150767\n * relates #150568\n * relates #150569'
pattern = r'(\s*\* (?:relates|parent|child|copied_to)) #(\d+)'
for _, redmineId in re.findall(pattern, description):
targetGitlabId = redmineToGitlabIdMap[redmineId]
Я также пытался преобразовать ключ в int:
Код: Выделить всё
targetGitlabId = redmineToGitlabIdMap[int(redmineId)]
Подробнее здесь: https://stackoverflow.com/questions/792 ... -it-exists
Мобильная версия