1# Copyright 2015 The Distro Tracker Developers
2# See the COPYRIGHT file at the top-level directory of this distribution and
3# at https://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 https://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"""
11Kali specific rules
12"""
14import os.path
15import re
17from distro_tracker.core.package_tables import create_table
18from distro_tracker.debci_status.tracker_package_tables import DebciTableField
19from distro_tracker.mail import mail_news
22def classify_message(msg, package, keyword):
23 """Classify incoming email messages with a package and a keyword."""
24 # Default values for git commit notifications
25 xgitrepo = msg.get('X-GitLab-Project-Path', msg.get('X-Git-Repo'))
26 if xgitrepo: 26 ↛ 27line 26 didn't jump to line 27, because the condition on line 26 was never true
27 if not package:
28 if xgitrepo.endswith('.git'):
29 xgitrepo = xgitrepo[:-4]
30 package = os.path.basename(xgitrepo)
31 if not keyword:
32 keyword = 'vcs'
34 # Recognize build logs
35 if msg.get('X-Rebuildd-Host'): 35 ↛ 42line 35 didn't jump to line 42, because the condition on line 35 was never false
36 match = re.search(r'build of (\S+)_', msg.get('Subject'))
37 if match: 37 ↛ 42line 37 didn't jump to line 42, because the condition on line 37 was never false
38 keyword = 'build'
39 package = match.group(1)
41 # Store some messages as news
42 if msg.get('X-Distro-Tracker-News', 'no') == 'yes' and package: 42 ↛ 43line 42 didn't jump to line 43, because the condition on line 42 was never true
43 mail_news.create_news(msg, package)
44 return (package, keyword)
47def approve_default_message(msg):
48 """
49 The function should return a ``Boolean`` indicating whether this message
50 should be forwarded to subscribers which are subscribed to default
51 keyword messages.
53 :param msg: The message to approve
54 :type msg: :py:class:`email.message.Message`
55 """
56 return False
59def get_table_fields(table):
60 """
61 The function provides additional fields which should be displayed in
62 the team's packages table
63 """
64 return table.default_fields + [DebciTableField]
67def get_tables_for_team_page(team, limit):
68 """
69 The function must return a list of :class:`BasePackageTable` objects
70 to be displayed in the main page of teams.
72 :param team: The team for which the tables must be added.
73 :type package: :class:`Team <distro_tracker.core.models.Team>`
74 :param int limit: The number of packages to be displayed in the tables
75 """
76 return [
77 create_table(slug='general', scope=team, limit=limit),
78 create_table(
79 slug='general', scope=team, limit=limit,
80 tag='tag:debci-failures')
81 ]