def start_workunit(self, workunit):
    """Implementation of Reporter callback."""
    # We use these properties of the workunit to decide how to render information about it.
    is_bootstrap = workunit.has_label(WorkUnitLabel.BOOTSTRAP)
    is_tool = workunit.has_label(WorkUnitLabel.TOOL)
    is_multitool = workunit.has_label(WorkUnitLabel.MULTITOOL)
    is_test = workunit.has_label(WorkUnitLabel.TEST)

    initially_open = is_test or not (is_bootstrap or is_tool or is_multitool)

    # Render the workunit's div.
    s = self._start_workunit_fmt_string.format(
      indent=len(workunit.ancestors()) * 10,
      id=workunit.id,
      parent_id=workunit.parent.id if workunit.parent else '',
      workunit=workunit,
      icon_caret='down' if initially_open else 'right',
      display_class='' if initially_open else 'nodisplay',
      icon='cog' if is_tool else 'cogs' if is_multitool else 'none'
    )
    self._emit(s)

    if is_tool:
      tool_invocation_details = '\n'.join([
        self._render_tool_detail(workunit=workunit, title='cmd', class_prefix='cmd'),
        # Have test framework stdout open by default, but not that of other tools.
        # This is an arbitrary choice, but one that turns out to be useful to users in practice.
        self._render_tool_detail(workunit=workunit, title='stdout', initially_open=is_test),
        self._render_tool_detail(workunit=workunit, title='stderr'),
      ])

      cmd = workunit.cmd or ''
      linkified_cmd = linkify(self._buildroot, cmd.replace('$', '\\\\$'), self._linkify_memo)

      s = self._start_tool_invocation_fmt_string.format(
        tool_invocation_details=tool_invocation_details,
        html_path_base=self._html_path_base,
        id=workunit.id,
        cmd=linkified_cmd
      )

      self._emit(s)
def start_workunit ( self , workunit ) : is_bootstrap = workunit . has_label ( WorkUnitLabel . BOOTSTRAP ) is_tool = workunit . has_label ( WorkUnitLabel . TOOL ) is_multitool = workunit . has_label ( WorkUnitLabel . MULTITOOL ) is_test = workunit . has_label ( WorkUnitLabel . TEST ) initially_open = is_test or not ( is_bootstrap or is_tool or is_multitool ) s = self . _start_workunit_fmt_string . format ( indent = len ( workunit . ancestors ( ) ) * 10 , id = workunit . id , parent_id = workunit . parent . id if workunit . parent else '' , workunit = workunit , icon_caret = 'down' if initially_open else 'right' , display_class = '' if initially_open else 'nodisplay' , icon = 'cog' if is_tool else 'cogs' if is_multitool else 'none' ) self . _emit ( s ) if is_tool : tool_invocation_details = '\n' . join ( [ self . _render_tool_detail ( workunit = workunit , title = 'cmd' , class_prefix = 'cmd' ) , self . _render_tool_detail ( workunit = workunit , title = 'stdout' , initially_open = is_test ) , self . _render_tool_detail ( workunit = workunit , title = 'stderr' ) , ] ) cmd = workunit . cmd or '' linkified_cmd = linkify ( self . _buildroot , cmd . replace ( '$' , '\\\\$' ) , self . _linkify_memo ) s = self . _start_tool_invocation_fmt_string . format ( tool_invocation_details = tool_invocation_details , html_path_base = self . _html_path_base , id = workunit . id , cmd = linkified_cmd ) self . _emit ( s )
Implementation of Reporter callback.