| 1 | # -*- coding: utf-8 -*- |
---|
| 2 | # |
---|
| 3 | # Copyright (C) 2005-2007 Christopher Lenz <cmlenz@gmx.de> |
---|
| 4 | # Copyright (C) 2007-2010 Edgewall Software |
---|
| 5 | # All rights reserved. |
---|
| 6 | # |
---|
| 7 | # This software is licensed as described in the file COPYING, which |
---|
| 8 | # you should have received as part of this distribution. The terms |
---|
| 9 | # are also available at http://bitten.edgewall.org/wiki/License. |
---|
| 10 | |
---|
| 11 | """Interfaces of extension points provided by the Bitten Trac plugin.""" |
---|
| 12 | |
---|
| 13 | from trac.core import * |
---|
| 14 | |
---|
| 15 | __all__ = ['IBuildListener', 'ILogFormatter', 'IReportChartGenerator', |
---|
| 16 | 'IReportSummarizer'] |
---|
| 17 | __docformat__ = 'restructuredtext en' |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | class IBuildListener(Interface): |
---|
| 21 | """Extension point interface for components that need to be notified of |
---|
| 22 | build events. |
---|
| 23 | |
---|
| 24 | Note that these will be notified in the process running the build master, |
---|
| 25 | not the web interface. |
---|
| 26 | """ |
---|
| 27 | |
---|
| 28 | def build_started(build): |
---|
| 29 | """Called when a build slave has accepted a build initiation. |
---|
| 30 | |
---|
| 31 | :param build: the build that was started |
---|
| 32 | :type build: `Build` |
---|
| 33 | """ |
---|
| 34 | |
---|
| 35 | def build_aborted(build): |
---|
| 36 | """Called when a build slave cancels a build or disconnects. |
---|
| 37 | |
---|
| 38 | :param build: the build that was aborted |
---|
| 39 | :type build: `Build` |
---|
| 40 | """ |
---|
| 41 | |
---|
| 42 | def build_completed(build): |
---|
| 43 | """Called when a build slave has completed a build, regardless of the |
---|
| 44 | outcome. |
---|
| 45 | |
---|
| 46 | :param build: the build that was completed |
---|
| 47 | :type build: `Build` |
---|
| 48 | """ |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | class ILogFormatter(Interface): |
---|
| 52 | """Extension point interface for components that format build log |
---|
| 53 | messages.""" |
---|
| 54 | |
---|
| 55 | def get_formatter(req, build): |
---|
| 56 | """Return a function that gets called for every log message. |
---|
| 57 | |
---|
| 58 | The function must take four positional arguments, ``step``, |
---|
| 59 | ``generator``, ``level`` and ``message``, and return the formatted |
---|
| 60 | message as a string. |
---|
| 61 | |
---|
| 62 | :param req: the request object |
---|
| 63 | :param build: the build to which the logs belong that should be |
---|
| 64 | formatted |
---|
| 65 | :type build: `Build` |
---|
| 66 | :return: the formatted log message |
---|
| 67 | :rtype: `basestring` |
---|
| 68 | """ |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | class IReportSummarizer(Interface): |
---|
| 72 | """Extension point interface for components that render a summary of reports |
---|
| 73 | of some kind.""" |
---|
| 74 | |
---|
| 75 | def get_supported_categories(): |
---|
| 76 | """Return a list of strings identifying the types of reports this |
---|
| 77 | component supports. |
---|
| 78 | """ |
---|
| 79 | |
---|
| 80 | def render_summary(req, config, build, step, category): |
---|
| 81 | """Render a summary for the given report. |
---|
| 82 | |
---|
| 83 | This function should return a tuple of the form ``(template, data)``, |
---|
| 84 | where ``template` is the name of the template to use and ``data`` is |
---|
| 85 | the data to be passed to the template. |
---|
| 86 | |
---|
| 87 | :param req: the request object |
---|
| 88 | :param config: the build configuration |
---|
| 89 | :type config: `BuildConfig` |
---|
| 90 | :param build: the build |
---|
| 91 | :type build: `Build` |
---|
| 92 | :param step: the build step |
---|
| 93 | :type step: `BuildStep` |
---|
| 94 | :param category: the category of the report that should be summarized |
---|
| 95 | :type category: `basestring` |
---|
| 96 | """ |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | class IReportChartGenerator(Interface): |
---|
| 100 | """Extension point interface for components that generate a chart for a |
---|
| 101 | set of reports.""" |
---|
| 102 | |
---|
| 103 | def get_supported_categories(): |
---|
| 104 | """Return a list of strings identifying the types of reports this |
---|
| 105 | component supports. |
---|
| 106 | """ |
---|
| 107 | |
---|
| 108 | def generate_chart_data(req, config, category): |
---|
| 109 | """Generate the data for a report chart. |
---|
| 110 | |
---|
| 111 | This function should return a tuple of the form ``(template, data)``, |
---|
| 112 | where ``template`` is the name of the template to use and ``data`` is |
---|
| 113 | the data to be passed to the template. |
---|
| 114 | |
---|
| 115 | :param req: the request object |
---|
| 116 | :param config: the build configuration |
---|
| 117 | :type config: `BuildConfig` |
---|
| 118 | :param category: the category of reports to include in the chart |
---|
| 119 | :type category: `basestring` |
---|
| 120 | """ |
---|