gluetool.html_log module

gluetool.html_log._code_filter(ctx, value, syntax, apply_format=False, line_numbers=False, line_start=None, line_highlight=None)[source]

Generic filter to highlight the code. Emits tags and content to employ Prism to do the highlighting.

Parameters:
  • ctx – render context governed by Jinja.
  • value – text or actual data structure to highlight as code.
  • syntax (str) – what syntax to use for highlighting, e.g. python.
  • apply_format (bool) – if set, format_dict is called to pretty-print the structure in value.
  • line_numbers (bool) – if set, lines in the output are prefixed with their numbers.
  • line_start (int) – if set, it specifies how far from the beginning of the file (line 1) the code starts, and how much we have to fake the line counter before prefixing lines.
  • line_highlight (int) – if set, line of this number would be highlighted.
gluetool.html_log._snippet_filter(ctx, filepath, lineno, syntax, window=10)[source]

Generic filter providing snippet of the code from a source file, including the highlight.

Parameters:
  • ctx – render context governed by Jinja.
  • filepath (str) – source file.
  • lineno (int) – important line we want to highligh.
  • syntax (str) – what syntax to use for highlighting, e.g. python.
  • window (int) – size of the “window” we cut from the file. It is actually a half of the window, we peek window lines up and down around lineno.
gluetool.html_log.decode_stacked(document, pos=0, decoder=<json.decoder.JSONDecoder object>)[source]

Generator returning log entries - entries are not part of one large list of log entries, they are simply added to the log file one by one, therefore we cannot use json module to read them, it’d return just the first one.

gluetool.html_log.file_content_filter(ctx, value)[source]

Return content of the given file. File path must be relative to an assets directory set by --assets option.

Parameters:
  • ctx – render context governed by Jinja.
  • value (str) – path to a file to include.
gluetool.html_log.json_filter(ctx, value)[source]

Return highlighted JSON code.

Parameters:
  • ctx – render context governed by Jinja.
  • value (str) – JSON snippet to highlight.
gluetool.html_log.log_entries(stream)[source]

Return generator of log entries.

Parameters:stream (file) – file-like stream to read JSON input from.
gluetool.html_log.main()[source]
gluetool.html_log.message_filter(ctx, value)[source]

Return slightly escaped log message to make it keep its formatting in HTML.

  • spaces are replaced with non-breakable spaces (&nbsp;);
  • new-line characters are replaced with <br/> elements.
Parameters:
  • ctx – render context governed by Jinja.
  • value (str) – message to escape.
gluetool.html_log.python_snippet_filter(ctx, filepath, lineno)[source]
Parameters:
  • ctx – render context governed by Jinja.
  • filepath (str) – source file.
  • lineno (int) – line to highlight.