Template

Note

The documentation in this section is aimed at people wishing to contribute to hubugs, and can be skipped if you are simply using the tool from the command line.

hubugs.template.get_template(__group, __name)

Fetch a Jinja template instance.

Parameters
  • __group (str) – Template group identifier

  • __name (str) – Template name

Return type

Template

Returns

Jinja template instance

Jinja filter support

hubugs.template.jinja_filter(__func)

Simple decorator to add a new filter to Jinja environment.

Parameters

__func (Callable) – Function to add to Jinja environment

Return type

Callable

Returns

Unmodified function

hubugs.template.colourise(__text, fg=None, bg=None, **kwargs)

Colourise text.

Returns text untouched if colour output is not enabled

Parameters
  • __text (str) – Text to colourise

  • fg (Optional[str]) – Foreground colour

  • bg (Optional[str]) – Background colour

  • kwargs – Formatting to apply to text

Return type

str

Returns

Colourised text, when possible

hubugs.template.highlight(__text, lexer='diff', formatter='terminal')

Highlight text with pygments.

Returns text untouched if colour output is not enabled

Parameters
  • __text (str) – Text to highlight

  • lexer (Optional[str]) – Jinja lexer to use

  • formatter (Optional[str]) – Jinja formatter to use

Return type

str

Returns

Syntax highlighted output, when possible

hubugs.template.html2text(__html, width=80, ascii_replacements=False)

HTML to plain text renderer.

Parameters
  • __html (str) – Text to process

  • width (Optional[int]) – Paragraph width

  • ascii_replacements (Optional[bool]) – Use psuedo-ascii replacements for Unicode

Return type

str

Returns

Rendered text

User interface support

hubugs.template.display_bugs(__bugs, __order, **extras)

Display bugs to users.

Parameters
  • __bugs (List[Dict[str, str]]) – Bugs to display

  • __order (str) – Sorting order for displaying bugs

  • extras – Additional values to pass to templates

Return type

str

Returns

Rendered template output

hubugs.template.edit_text(edit_type='default', data=None)

Edit data with external editor.

Parameters
  • edit_type (Optional[str]) – Template to use in editor

  • data (Optional[str]) – Information to pass to template

Return type

str

Returns

User supplied text

Raises