~brendan-donegan/checkbox/bug1196531

« back to all changes in this revision

Viewing changes to plainbox/plainbox/impl/checkbox.py

  • Committer: Tarmac
  • Author(s): Zygmunt Krynicki
  • Date: 2013-06-21 14:14:16 UTC
  • mfrom: (2199.1.11 launchpad/misc)
  • Revision ID: tarmac-20130621141416-hv12juje6qdwfbes
"[r=roadmr][bug=][author=zkrynicki] automatic merge by tarmac"

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    and appended (respectively) to the actual pattern specified in the file.
59
59
    """
60
60
 
61
 
    def __init__(self, pattern_list):
 
61
    def __init__(self, pattern_list, name=None):
62
62
        """
63
63
        Initialize a whitelist object with the specified list of patterns.
64
64
 
67
67
        inclusive = [RegExpJobQualifier(pattern) for pattern in pattern_list]
68
68
        exclusive = ()
69
69
        super(WhiteList, self).__init__(inclusive, exclusive)
 
70
        self._name = name
 
71
 
 
72
    @property
 
73
    def name(self):
 
74
        """
 
75
        name of this WhiteList (might be None)
 
76
        """
 
77
        return self._name
70
78
 
71
79
    @classmethod
72
80
    def from_file(cls, pathname):
77
85
        :returns: a fresh WhiteList object
78
86
        """
79
87
        pattern_list = cls._load_patterns(pathname)
80
 
        return cls(pattern_list)
 
88
        name = os.path.splitext(os.path.basename(pathname))[0]
 
89
        return cls(pattern_list, name=name)
81
90
 
82
91
    @classmethod
83
92
    def _load_patterns(self, pathname):
126
135
 
127
136
    Historically plainbox used a git submodule with checkbox tree (converted to
128
137
    git). This ended with the merge of plainbox into the checkbox tree.
129
 
    
 
138
 
 
139
 
130
140
    Now it's the other way around and the checkbox tree can be located two
131
141
    directories "up" from the plainbox module, in a checkbox-old directory.
132
142
    """
281
291
        for name in os.listdir(self.whitelists_dir):
282
292
            if name.endswith(".whitelist"):
283
293
                whitelist_list.append(
284
 
                    WhiteList.from_file(os.path.join(self.jobs_dir, name)))
 
294
                    WhiteList.from_file(os.path.join(
 
295
                        self.whitelists_dir, name)))
285
296
        return whitelist_list
286
297
 
287
298
    def get_builtin_jobs(self):
318
329
            raise TypeError(
319
330
                "Unsupported type of 'somewhere': {!r}".format(
320
331
                    type(somewhere)))
 
332
 
 
333
    @property
 
334
    def name(self):
 
335
        """
 
336
        name of this provider (always checkbox)
 
337
        """
 
338
        return "checkbox"