get-approval-request-comment.py 988 B

123456789101112131415161718192021222324
  1. from urllib3 import PoolManager
  2. import json
  3. import sys
  4. if __name__ == '__main__':
  5. bugzillaID = sys.argv[1]
  6. bugzilla_project_name = 'bugzilla.mozilla.org'
  7. request = 'https://{}/rest/bug/{}/comment'.format(bugzilla_project_name,
  8. bugzillaID)
  9. introducerIDs = set()
  10. res = PoolManager().request('GET', request, retries=10)
  11. j = json.loads(res.data)
  12. for comment in j['bugs'][bugzillaID]['comments']:
  13. for line in comment['text'].split('\n'):
  14. if '[Feature' in line:
  15. introducerIDs |= {word for word in line.
  16. replace(',', ' ').
  17. replace(';', ' ').
  18. replace(':', ' ').
  19. replace('#', ' ').split()
  20. if word.isdigit() and int(word) > 1000}
  21. if len(introducerIDs) > 0:
  22. print(json.dumps(list(introducerIDs)))