This file is indexed.

/usr/share/pyshared/lpltk/bug_tasks.py is in python-launchpadlib-toolkit 2.3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/python

import sys
from datetime import timedelta, datetime
from bug_task                        import BugTask
from utils                           import (
    typecheck_Collection,
    typecheck_Entry,
    )

class BugTasks(object):
    # __init__
    #
    # Initialize the instance from a Launchpad bug.
    #
    def __init__(self, service, lp_tasks):
        self.__service       = service
        self.__lp_tasks      = typecheck_Collection(lp_tasks)

        self.__filter_distro = None
        self.__filter_status = None
        self.__filter_bug_tracker_type = None
        self.__filter_reopened = None
        self.__filter_status_length = None
        self.__filter_importance_length = None
        self.__filtered_tasks = None

    def filtered_tasks(self):
        if self.__filtered_tasks is None:
            self.__filtered_tasks = list(self.__iter__())
        return self.__filtered_tasks

    # __len__
    #
    def __len__(self):
        return len(self.filtered_tasks())

    # __getitem__
    #
    def __getitem__(self, key):
        tasks = self.filtered_tasks()
        return tasks[key]

    # __iter__
    #
    def __iter__(self):
        for task in self.__lp_tasks:
            task = BugTask(self.__service, task)
            if self.__filter_distro:
                if self.__filter_distro not in task.bug_target_display_name:
                    continue

            if self.__filter_status:
                status = self.__filter_status
                is_complete = task.is_complete
                if status == 'open' and is_complete:
                    continue
                if status == 'complete' and not is_complete:
                    continue
                if status not in ['open', 'complete'] and task.status != status:
                    continue

            if self.__filter_bug_tracker_type:
                bt_type = self.__filter_bug_tracker_type
                upstream_product = task.target.upstream_product
                if upstream_product is None:
                    continue
                bt = upstream_product.bug_tracker
                if bt is None:
                    # Is this part of a project group?
                    project_group = upstream_product.project_group
                    if project_group is not None:
                        bt = project_group.bug_tracker
                if bt is None:
                    sys.stderr.write("No bug tracker found for upstream product\n")
                    continue
                sys.stderr.write("Bug tracker type: %s (looking for %s)\n" %(bt.bug_tracker_type, bt_type))
                if bt.bug_tracker_type != bt_type:
                    continue

            if self.__filter_reopened:
                if not task.date_left_closed:
                    continue

            if self.__filter_status_length:
                status_length = self.__filter_status_length
                # status_age will be None for bug tasks with out date_ info
                if task.status_age() is None:
                    continue
                if status_length.startswith('>'):
                    if task.status_age() <= timedelta(int(status_length.replace('>', ''))):
                        continue
                elif status_length.startswith('<'):
                    if task.status_age() >= timedelta(int(status_length.replace('<', ''))):
                        continue
                elif status_length.startswith('='):
                    if task.status_age() == timedelta(int(status_length.replace('=', ''))):
                        continue

            if self.__filter_importance_length:
                importance_length = self.__filter_importance_length
                now = datetime.utcnow().replace(tzinfo=None)
                dis = task.date_importance_set
                if dis is None:
                    continue
                else:
                    dis = dis.replace(tzinfo=None)
                if importance_length.startswith('>'):
                    if dis >= (now - timedelta(int(importance_length.replace('>', '')))):
                        continue
                elif importance_length.startswith('<'):
                    if dis <= (now - timedelta(int(importance_length.replace('<', '')))):
                        continue
                elif importance_length.startswith('='):
                    if dis == (now - timedelta(int(importance_length.replace('=', '')))):
                        continue

            yield task

    # __contains__
    #
    def __contains__(self, item):
        return item in self.__iter__()

    # Filters
    def set_filter_by_distro(self, distroname='Ubuntu'):
        '''Only include tasks that are targeted to the given distro'''
        self.__filter_distro = distroname
        self.__filtered_tasks = None

    def set_filter_by_status(self, state):
        '''Include tasks only in the specified state

        The regular bug statuses "Incomplete", "Fix Committed", et al
        are supported, as well as special keywords 'open' and 'complete'.
        '''
        self.__filter_status = state
        self.__filtered_tasks = None

    def set_filter_by_bug_tracker_type(self, bugtracker_type):
        '''Include only tasks for upstream projects using this type of bug tracker'''
        self.__filter_bug_tracker_type = bugtracker_type
        self.__filtered_tasks = None

    def set_filter_reopened(self):
        '''Include only tasks that have been set to an open state from a closed one'''

        self.__filter_reopened = True
        self.__filtered_tasks = None

    def set_filter_status_length(self, status_length):
        '''Include only tasks that have been in their state <>= status_length in days'''

        self.__filter_status_length = status_length
        self.__filtered_tasks = None

    def set_filter_importance_length(self, importance_length):
        '''Include only tasks that have had their importance <>= importance_length in days'''

        self.__filter_importance_length = importance_length
        self.__filtered_tasks = None

# vi:set ts=4 sw=4 expandtab: