Showing 1 of 1 files from the diff.

@@ -150,16 +150,49 @@
Loading
150 150
151 151
152 152
class MessageFormatterBase(util.ComparableMixin):
153 -
    template_filename = 'default_mail.txt'
153 +
154 154
    template_type = 'plain'
155 155
156 +
    def __init__(self, ctx=None, wantProperties=True, wantSteps=False, wantLogs=False):
157 +
        if ctx is None:
158 +
            ctx = {}
159 +
        self.context = ctx
160 +
        self.wantProperties = wantProperties
161 +
        self.wantSteps = wantSteps
162 +
        self.wantLogs = wantLogs
163 +
164 +
    def buildAdditionalContext(self, master, ctx):
165 +
        pass
166 +
167 +
    @defer.inlineCallbacks
168 +
    def render_message_dict(self, master, context):
169 +
        """Generate a buildbot reporter message and return a dictionary
170 +
           containing the message body, type and subject."""
171 +
        yield self.buildAdditionalContext(master, context)
172 +
        context.update(self.context)
173 +
174 +
        return {
175 +
            'body': self.render_message_body(context),
176 +
            'type': self.template_type,
177 +
            'subject': self.render_message_subject(context)
178 +
        }
179 +
180 +
    def render_message_body(self, context):
181 +
        return None
182 +
183 +
    def render_message_subject(self, context):
184 +
        return None
185 +
186 +
187 +
class MessageFormatterBaseJinja(MessageFormatterBase):
188 +
    template_filename = 'default_mail.txt'
189 +
156 190
    compare_attrs = ['body_template', 'subject_template', 'template_type']
157 191
158 192
    def __init__(self, template_dir=None,
159 193
                 template_filename=None, template=None,
160 194
                 subject_filename=None, subject=None,
161 -
                 template_type=None, ctx=None,
162 -
                 ):
195 +
                 template_type=None, **kwargs):
163 196
        self.body_template = self.getTemplate(template_filename, template_dir, template)
164 197
        self.subject_template = None
165 198
        if subject_filename or subject:
@@ -168,10 +201,7 @@
Loading
168 201
        if template_type is not None:
169 202
            self.template_type = template_type
170 203
171 -
        if ctx is None:
172 -
            ctx = {}
173 -
174 -
        self.ctx = ctx
204 +
        super().__init__(**kwargs)
175 205
176 206
    def getTemplate(self, filename, dirname, content):
177 207
        if content and (filename or dirname):
@@ -195,61 +225,39 @@
Loading
195 225
    def buildAdditionalContext(self, master, ctx):
196 226
        pass
197 227
198 -
    @defer.inlineCallbacks
199 -
    def renderMessage(self, master, ctx):
200 -
        """Generate a buildbot mail message and return a dictionary
201 -
           containing the message body, type and subject."""
202 -
203 -
        yield self.buildAdditionalContext(master, ctx)
204 -
        ctx.update(self.ctx)
228 +
    def render_message_body(self, context):
229 +
        return self.body_template.render(context)
205 230
206 -
        msgdict = {
207 -
            'body': self.body_template.render(ctx),
208 -
            'type': self.template_type,
209 -
            'subject': None
210 -
        }
211 -
        if self.subject_template is not None:
212 -
            msgdict['subject'] = self.subject_template.render(ctx)
213 -
        return msgdict
231 +
    def render_message_subject(self, context):
232 +
        if self.subject_template is None:
233 +
            return None
234 +
        return self.subject_template.render(context)
214 235
215 236
216 -
class MessageFormatter(MessageFormatterBase):
237 +
class MessageFormatter(MessageFormatterBaseJinja):
217 238
    template_filename = 'default_mail.txt'
218 -
    template_type = 'plain'
219 239
220 240
    compare_attrs = ['wantProperties', 'wantSteps', 'wantLogs']
221 241
222 -
    def __init__(self, template_dir=None,
223 -
                 template_filename=None, template=None, template_name=None,
224 -
                 subject_filename=None, subject=None,
225 -
                 template_type=None, ctx=None,
226 -
                 wantProperties=True, wantSteps=False, wantLogs=False):
242 +
    def __init__(self, template_name=None, **kwargs):
227 243
228 244
        if template_name is not None:
229 245
            warn_deprecated('0.9.1', "template_name is deprecated, use template_filename")
230 -
            template_filename = template_name
231 -
        super().__init__(template_dir=template_dir,
232 -
                         template_filename=template_filename,
233 -
                         template=template,
234 -
                         subject_filename=subject_filename,
235 -
                         subject=subject,
236 -
                         template_type=template_type, ctx=ctx)
237 -
        self.wantProperties = wantProperties
238 -
        self.wantSteps = wantSteps
239 -
        self.wantLogs = wantLogs
246 +
            kwargs['template_filename'] = template_name
247 +
        super().__init__(**kwargs)
240 248
241 249
    @defer.inlineCallbacks
242 250
    def format_message_for_build(self, mode, buildername, build, master, blamelist):
243 251
        ctx = create_context_for_build(mode, buildername, build, master, blamelist)
244 -
        msgdict = yield self.renderMessage(master, ctx)
252 +
        msgdict = yield self.render_message_dict(master, ctx)
245 253
        return msgdict
246 254
247 255
248 -
class MessageFormatterMissingWorker(MessageFormatterBase):
256 +
class MessageFormatterMissingWorker(MessageFormatterBaseJinja):
249 257
    template_filename = 'missing_mail.txt'
250 258
251 259
    @defer.inlineCallbacks
252 260
    def formatMessageForMissingWorker(self, master, worker):
253 261
        ctx = create_context_for_worker(master, worker)
254 -
        msgdict = yield self.renderMessage(master, ctx)
262 +
        msgdict = yield self.render_message_dict(master, ctx)
255 263
        return msgdict
Files Coverage
master/buildbot 90.19%
worker/buildbot_worker 85.09%
Project Totals (352 files) 89.89%
13424.3
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
13424.2
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
13424.1
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
Untitled

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading