|
| 1 | +from atlassian import Jira |
| 2 | +import requests |
| 3 | + |
| 4 | +jira = Jira( |
| 5 | + url='http://localhost:8090', |
| 6 | + username='admin', |
| 7 | + password='admin') |
| 8 | + |
| 9 | + |
| 10 | +def compare_dicts(dict1, dict2): |
| 11 | + count = 0 |
| 12 | + hint = [] |
| 13 | + if len(dict1) != len(dict2) and len(dict1) != len(dict2) + 1 and len(dict2) != len(dict1) + 1: |
| 14 | + return False |
| 15 | + |
| 16 | + for key in dict1: |
| 17 | + if dict1[key] != dict2.get(key): |
| 18 | + count += 1 |
| 19 | + hint.append(key) |
| 20 | + if count > 1: |
| 21 | + return False |
| 22 | + if len(dict1) != len(dict2): |
| 23 | + print('(Different size') |
| 24 | + if count == 1: |
| 25 | + print('(Different: ', hint[0]) |
| 26 | + |
| 27 | + return True |
| 28 | + |
| 29 | +notificationscheme_dict = {} |
| 30 | +all_notificationschemes_dict = {} |
| 31 | + |
| 32 | +notificationschemes_ids = jira.get_notification_schemes() |
| 33 | +names = [] |
| 34 | + |
| 35 | +for notificationschemes_id in notificationschemes_ids['values']: |
| 36 | + |
| 37 | + id = notificationschemes_id['id'] |
| 38 | + notificationschemes = jira.get_notification_scheme(id, 'all') |
| 39 | + names.append(notificationschemes['name']) |
| 40 | + notificationscheme_dict = {} |
| 41 | + |
| 42 | + for scheme in notificationschemes['notificationSchemeEvents']: |
| 43 | + notificationTypes = [] |
| 44 | + |
| 45 | + for notificationType in scheme['notifications']: |
| 46 | + notificationTypes.append(notificationType['notificationType']) |
| 47 | + notificationscheme_dict[scheme['event']['name']] = notificationTypes |
| 48 | + all_notificationschemes_dict[notificationschemes['name']] = notificationscheme_dict |
| 49 | + |
| 50 | +for i in range(len(names)): |
| 51 | + for j in range(len(names)): |
| 52 | + if names and i < j: |
| 53 | + if compare_dicts(all_notificationschemes_dict[names[i]], all_notificationschemes_dict[names[j]]): |
| 54 | + print(names[i], '/', names[j]) |
| 55 | + print('same) \n -----------------------------------------------------------------') |
0 commit comments