The pretty module

This module implements various output-formatters that have been found useful for creating web pages and console output.

seaice.pretty.printPrettyDate(T)[source]

Format output of a timestamp.

If a small amount of time has elapsed between T_now and T, then return the interval. TODO: This should be localized based on the HTTP request.
Parameters:T (datetime.datetime) – Timestamp.
Return type:str
seaice.pretty.processTags(db_con, string)[source]

Process tags in DB text entries into HTML.

Parameters:
Returns:

HTML-formatted string.

Plain text

seaice.pretty.printAsJSObject(rows, fd=<open file '<stdout>', mode 'w' at 0x2b438740d150>)[source]

Print table rows as JSON-formatted object.

Parameters:
  • rows (dict iterator) – Table rows.
  • fd (file) – File descriptor to which to output the result (default is sys.stdout).
seaice.pretty.printTermsPretty(db_con, rows)[source]

Print term rows to terminal.

Parameters:

HTML

seaice.pretty.printTermAsHTML(db_con, row, user_id=0)[source]

Format a term for the term page, e.g. this.

This is the main page where you can look at a term. It includes a term definition, examples, a voting form, ownership, and other stuff.
Parameters:
  • db_con (seaice.SeaIceConnector.SeaIceConnector) – DB connection.
  • row (dict) – Term row.
  • user_id (int) – Surrogate ID of user requesting the page. Defaults to 0 if session is unauthenticated.
Returns:

HTML-formatted string.

seaice.pretty.printTermsAsHTML(db_con, rows, user_id=0)[source]

Format search results for display on the web page.

Parameters:
  • db_con (seaice.SeaIceConnector.SeaIceConnector) – DB connection.
  • row (dict iterator) – Term rows.
  • user_id (int) – Surrogate ID of user requesting the page. Defaults to 0 if session is unauthenticated.
Returns:

HTML-formatted string.

seaice.pretty.printTermsAsBriefHTML(db_con, rows, user_id=0)[source]
Format table rows as abbreviated HTML table, e.g.
this.
Parameters:
  • db_con (seaice.SeaIceConnector.SeaIceConnector) – DB connection.
  • row (dict iterator) – Term rows.
  • user_id (int) – Surrogate ID of user requesting the page. Defaults to 0 if session is unauthenticated.
Returns:

HTML-formatted string.

Print terms as a link list (pun intended).

Parameters:rows (dict iterator) – Table rows.
Returns:HTML-formatted string.
seaice.pretty.printCommentsAsHTML(db_con, rows, user_id=0)[source]

Format comments for display on the term page.

Parameters:
  • db_con (seaice.SeaIceConnector.SeaIceConnector) – DB connection.
  • row (dict iterator) – Comment rows.
  • user_id (int) – Surrogate ID of user requesting the page. Defaults to 0 if session is unauthenticated.
Returns:

HTML-formatted string.

Table Of Contents

Previous topic

The notify module

Next topic

Term scoring and classification

This Page