Utilities

Note

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

Data loading

find_entries(path)
Parameters:path (str) – Path to search
Return type:table
Returns:Matching entries
find_marker(file)

Find location to insert new entries

Parameters:file (str) – File to operate on
Return type:int
Returns:Line to insert new entries

File creation

build_file(file, marker, entries, version, date)

Generate new NEWS file

Parameters:
  • file (str) – File to operate on
  • marker (int) – Line to insert new text at
  • entries (table) – New entries to insert
Return type:

table

Returns:

Lines comprising complete output

write_output(ofile, output, use_temp)

Write output to file or stdout

Parameters:
  • ofile (str) – Output file name
  • output (str) – Output to write

Text formatting

colourise(text, colour, bold, underline)

Generate coloured output for the terminal.

Parameters:
  • text (str) – Text to colourise
  • colour (str) – Colour to use
  • bold (bool) – Use bold output
  • underline (bool) – Use underline output
Return type:

str

Returns:

Colourised output

success(text, bold)

Standardised success message.

Parameters:
  • text (str) – Text to colourise
  • bold (bool) – Use bold output
Return type:

str

Returns:

Prettified success message

fail(text, bold)

Standardised failure message.

Parameters:
  • text (str) – Text to colourise
  • bold (bool) – Use bold output
Return type:

str

Returns:

Prettified failure message

warn(text, bold)

Standardised warning message.

Parameters:
  • text (str) – Text to colourise
  • bold (bool) – Use bold output
Return type:

str

Returns:

Prettified warning message

wrap_entry(text, width, initial_indent, subsequent_indent)

Wrap text for output

Parameters:
  • text (str) – Text to format
  • int – Width of formatted text
  • initial_indent (str) – String to indent first line with
  • subsequent_indent (str) – String to indent all but the first line with
Return type:

str

Returns:

Line wrapped text