gemseo / third_party / prettytable

factory module

Pretty table factory

class gemseo.third_party.prettytable.factory.TableHandler(**kwargs)[source]

Bases: HTMLParser

Initialize and reset this instance.

If convert_charrefs is True (the default), all character references are automatically converted to the corresponding Unicode characters.

check_for_whole_start_tag(i)
clear_cdata_mode()
close()

Handle any buffered data.

error(message)
feed(data)

Feed data to the parser.

Call this as often as you want, with as little or as much text as you want (may include ‘n’).

generate_table(rows)[source]

Generates from a list of rows a PrettyTable object.

Parameters:

rows

get_starttag_text()

Return full source of start tag: ‘<…>’.

getpos()

Return current line number and offset.

goahead(end)
handle_charref(name)
handle_comment(data)
handle_data(data)[source]
Parameters:

data

handle_decl(decl)
handle_endtag(tag)[source]
Parameters:

tag

handle_entityref(name)
handle_pi(data)
handle_startendtag(tag, attrs)
handle_starttag(tag, attrs)[source]
Parameters:
  • tag – param attrs:

  • attrs

static make_fields_unique(fields)[source]

iterates over the row and make each field unique

Parameters:

fields – fields

parse_bogus_comment(i, report=1)
parse_comment(i, report=1)
parse_declaration(i)
parse_endtag(i)
parse_html_declaration(i)
parse_marked_section(i, report=1)
parse_pi(i)
parse_starttag(i)
reset()

Reset this instance. Loses all unprocessed data.

set_cdata_mode(elem)
unknown_decl(data)
updatepos(i, j)
CDATA_CONTENT_ELEMENTS = ('script', 'style')
gemseo.third_party.prettytable.factory.from_csv(filepath, field_names=None, **kwargs)[source]

Loads table from CSV file

Parameters:
  • filepath – param field_names: (Default value = None)

  • field_names – (Default value = None)

gemseo.third_party.prettytable.factory.from_db_cursor(cursor, **kwargs)[source]
Parameters:
  • cursor

  • kwargs

gemseo.third_party.prettytable.factory.from_html(html_code, **kwargs)[source]

Generates a list of PrettyTables from a string of HTML code.

Each <table> in the HTML becomes one PrettyTable object.

Parameters:
  • html_code (str) – HTML code

  • kwargs – additional arguments

gemseo.third_party.prettytable.factory.from_html_one(html_code, **kwargs)[source]

Generates a PrettyTables from a string of HTML code which contains only a single <table>

Parameters:
  • html_code (str) – HTML code

  • kwargs – additional arguments

gemseo.third_party.prettytable.factory.from_md(markdown, **kwargs)[source]

Generate PrettyTable from markdown string.

Parameters:
  • markdown – markdown type string.

  • kwargs – additional arguments

Returns:

a PrettyTable object.

gemseo.third_party.prettytable.factory.split_md_row(row)[source]

Split markdown table.

Parameters:

row – a row of markdown table

Returns:

Split content list

gemseo.third_party.prettytable.factory.strip_md_content(markdown)[source]

Strip the blank space and : in markdown table content cell.

Parameters:

markdown – a row of markdown table

Returns:

stripped content cell