rules.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Copyright 2015 The Distro Tracker Developers
  2. # See the COPYRIGHT file at the top-level directory of this distribution and
  3. # at http://deb.li/DTAuthors
  4. #
  5. # This file is part of Distro Tracker. It is subject to the license terms
  6. # in the LICENSE file found in the top-level directory of this
  7. # distribution and at http://deb.li/DTLicense. No part of Distro Tracker,
  8. # including this file, may be copied, modified, propagated, or distributed
  9. # except according to the terms contained in the LICENSE file.
  10. """
  11. Kali specific rules
  12. """
  13. from __future__ import unicode_literals
  14. import os.path
  15. import re
  16. from distro_tracker.mail import mail_news
  17. def classify_message(msg, package, keyword):
  18. # Default values for git commit notifications
  19. xgitrepo = msg.get('X-Git-Repo')
  20. if xgitrepo:
  21. if not package:
  22. if xgitrepo.endswith('.git'):
  23. xgitrepo = xgitrepo[:-4]
  24. package = os.path.basename(xgitrepo)
  25. if not keyword:
  26. keyword = 'vcs'
  27. # Recognize build logs
  28. if msg.get('X-Rebuildd-Host'):
  29. match = re.search('build of (\S+)_', msg.get('Subject'))
  30. if match:
  31. keyword = 'build'
  32. package = match.group(1)
  33. # Store some messages as news
  34. if msg.get('X-Distro-Tracker-News', 'no') == 'yes' and package:
  35. mail_news.create_news(msg, package)
  36. return (package, keyword)
  37. def approve_default_message(msg):
  38. """
  39. The function should return a ``Boolean`` indicating whether this message
  40. should be forwarded to subscribers which are subscribed to default
  41. keyword messages.
  42. :param msg: The message to approve
  43. :type msg: :py:class:`email.message.Message`
  44. """
  45. return False