cloudmesh-common.cloudmesh.common.prettytable
¶
Module Contents¶
Classes¶
Find tags and other markup and call handler functions. |
Functions¶
|
|
|
|
|
|
|
|
|
|
|
Generates a list of PrettyTables from a string of HTML code. Each <table> in |
|
Generates a PrettyTables from a string of HTML code which contains only a |
|
-
cloudmesh-common.cloudmesh.common.prettytable.
__version__
= 0.7.3¶
-
cloudmesh-common.cloudmesh.common.prettytable.
py3k
¶
-
cloudmesh-common.cloudmesh.common.prettytable.
unicode
¶
-
cloudmesh-common.cloudmesh.common.prettytable.
FRAME
= 0¶
-
cloudmesh-common.cloudmesh.common.prettytable.
ALL
= 1¶
-
cloudmesh-common.cloudmesh.common.prettytable.
NONE
= 2¶
-
cloudmesh-common.cloudmesh.common.prettytable.
HEADER
= 3¶
-
cloudmesh-common.cloudmesh.common.prettytable.
DEFAULT
= 10¶
-
cloudmesh-common.cloudmesh.common.prettytable.
MSWORD_FRIENDLY
= 11¶
-
cloudmesh-common.cloudmesh.common.prettytable.
PLAIN_COLUMNS
= 12¶
-
cloudmesh-common.cloudmesh.common.prettytable.
RANDOM
= 20¶
-
cloudmesh-common.cloudmesh.common.prettytable.
_get_size
(text)¶
-
class
cloudmesh-common.cloudmesh.common.prettytable.
PrettyTable
(field_names=None, **kwargs)¶ Bases:
object
-
field_names
¶
-
align
¶
-
valign
¶
-
max_width
¶
-
fields
¶
-
start
¶
-
end
¶
-
sortby
¶
-
reversesort
¶
-
sort_key
¶
-
header
¶
-
header_style
¶
-
border
¶
-
hrules
¶
-
vrules
¶
-
int_format
¶
-
float_format
¶
-
padding_width
¶
-
left_padding_width
¶
-
right_padding_width
¶
-
vertical_char
¶
-
horizontal_char
¶
-
junction_char
¶
-
format
¶
-
attributes
¶
-
_unicode
(self, value)¶
-
_justify
(self, text, width, align)¶
-
__getattr__
(self, name)¶
-
__getitem__
(self, index)¶
-
__unicode__
(self)¶
-
_validate_option
(self, option, val)¶
-
_validate_field_names
(self, val)¶
-
_validate_header_style
(self, val)¶
-
_validate_align
(self, val)¶
-
_validate_valign
(self, val)¶
-
_validate_nonnegative_int
(self, name, val)¶
-
_validate_true_or_false
(self, name, val)¶
-
_validate_int_format
(self, name, val)¶
-
_validate_float_format
(self, name, val)¶
-
_validate_function
(self, name, val)¶
-
_validate_hrules
(self, name, val)¶
-
_validate_vrules
(self, name, val)¶
-
_validate_field_name
(self, name, val)¶
-
_validate_all_field_names
(self, name, val)¶
-
_validate_single_char
(self, name, val)¶
-
_validate_attributes
(self, name, val)¶
-
_get_field_names
(self)¶
-
_set_field_names
(self, val)¶
-
_get_align
(self)¶
-
_set_align
(self, val)¶
-
_get_valign
(self)¶
-
_set_valign
(self, val)¶
-
_get_max_width
(self)¶
-
_set_max_width
(self, val)¶
-
_get_fields
(self)¶ List or tuple of field names to include in displays
Arguments:
fields - list or tuple of field names to include in displays
-
_set_fields
(self, val)¶
-
_get_start
(self)¶ Start index of the range of rows to print
Arguments:
start - index of first data row to include in output
-
_set_start
(self, val)¶
-
_get_end
(self)¶ End index of the range of rows to print
Arguments:
end - index of last data row to include in output PLUS ONE (list slice style)
-
_set_end
(self, val)¶
-
_get_sortby
(self)¶ Name of field by which to sort rows
Arguments:
sortby - field name to sort by
-
_set_sortby
(self, val)¶
-
_get_reversesort
(self)¶ Controls direction of sorting (ascending vs descending)
Arguments:
reveresort - set to True to sort by descending order, or False to sort by ascending order
-
_set_reversesort
(self, val)¶
-
_get_sort_key
(self)¶ Sorting key function, applied to data points before sorting
Arguments:
sort_key - a function which takes one argument and returns something to be sorted
-
_set_sort_key
(self, val)¶
-
_get_header
(self)¶ Controls printing of table header with field names
Arguments:
header - print a header showing field names (True or False)
-
_set_header
(self, val)¶
-
_get_header_style
(self)¶ Controls stylisation applied to field names in header
Arguments:
header_style - stylisation to apply to field names in header (“cap”, “title”, “upper”, “lower” or None)
-
_set_header_style
(self, val)¶
-
_get_border
(self)¶ Controls printing of border around table
Arguments:
border - print a border around the table (True or False)
-
_set_border
(self, val)¶
-
_get_hrules
(self)¶ Controls printing of horizontal rules after rows
Arguments:
hrules - horizontal rules style. Allowed values: FRAME, ALL, HEADER, NONE
-
_set_hrules
(self, val)¶
-
_get_vrules
(self)¶ Controls printing of vertical rules between columns
Arguments:
vrules - vertical rules style. Allowed values: FRAME, ALL, NONE
-
_set_vrules
(self, val)¶
-
_get_int_format
(self)¶ Controls formatting of integer data Arguments:
int_format - integer format string
-
_set_int_format
(self, val)¶
-
_get_float_format
(self)¶ Controls formatting of floating point data Arguments:
float_format - floating point format string
-
_set_float_format
(self, val)¶
-
_get_padding_width
(self)¶ The number of empty spaces between a column’s edge and its content
Arguments:
padding_width - number of spaces, must be a positive integer
-
_set_padding_width
(self, val)¶
-
_get_left_padding_width
(self)¶ The number of empty spaces between a column’s left edge and its content
Arguments:
left_padding - number of spaces, must be a positive integer
-
_set_left_padding_width
(self, val)¶
-
_get_right_padding_width
(self)¶ The number of empty spaces between a column’s right edge and its content
Arguments:
right_padding - number of spaces, must be a positive integer
-
_set_right_padding_width
(self, val)¶
-
_get_vertical_char
(self)¶ The charcter used when printing table borders to draw vertical lines
Arguments:
vertical_char - single character string used to draw vertical lines
-
_set_vertical_char
(self, val)¶
-
_get_horizontal_char
(self)¶ The charcter used when printing table borders to draw horizontal lines
Arguments:
horizontal_char - single character string used to draw horizontal lines
-
_set_horizontal_char
(self, val)¶
-
_get_junction_char
(self)¶ The charcter used when printing table borders to draw line junctions
Arguments:
junction_char - single character string used to draw line junctions
-
_set_junction_char
(self, val)¶
-
_get_format
(self)¶ Controls whether or not HTML tables are formatted to match styling options
Arguments:
format - True or False
-
_set_format
(self, val)¶
-
_get_attributes
(self)¶ A dictionary of HTML attribute name/value pairs to be included in the <table> tag when printing HTML
Arguments:
attributes - dictionary of attributes
-
_set_attributes
(self, val)¶
-
_get_options
(self, kwargs)¶
-
set_style
(self, style)¶
-
_set_default_style
(self)¶
-
_set_msword_style
(self)¶
-
_set_columns_style
(self)¶
-
_set_random_style
(self)¶
-
add_row
(self, row)¶ Add a row to the table
Arguments:
row - row of data, should be a list with as many elements as the table has fields
-
del_row
(self, row_index)¶ Delete a row to the table
Arguments:
row_index - The index of the row you want to delete. Indexing starts at 0.
-
add_column
(self, fieldname, column, align='c', valign='t')¶ Add a column to the table.
Arguments:
fieldname - name of the field to contain the new column of data column - column of data, should be a list with as many elements as the table has rows align - desired alignment for this column - “l” for left, “c” for centre and “r” for right valign - desired vertical alignment for new columns - “t” for top, “m” for middle and “b” for bottom
-
clear_rows
(self)¶ Delete all rows from the table but keep the current field names
-
clear
(self)¶ Delete all rows and field names from the table, maintaining nothing but styling options
-
copy
(self)¶
-
_format_value
(self, field, value)¶
-
_compute_widths
(self, rows, options)¶
-
_get_padding_widths
(self, options)¶
-
_get_rows
(self, options)¶ Return only those data rows that should be printed, based on slicing and sorting.
Arguments:
options - dictionary of option settings.
-
_format_row
(self, row, options)¶
-
_format_rows
(self, rows, options)¶
-
get_string
(self, **kwargs)¶ Return string representation of table in current state.
Arguments:
start - index of first data row to include in output end - index of last data row to include in output PLUS ONE (list slice style) fields - names of fields (columns) to include header - print a header showing field names (True or False) border - print a border around the table (True or False) hrules - controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE vrules - controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE int_format - controls formatting of integer data float_format - controls formatting of floating point data padding_width - number of spaces on either side of column data (only used if left and right paddings are None) left_padding_width - number of spaces on left hand side of column data right_padding_width - number of spaces on right hand side of column data vertical_char - single character string used to draw vertical lines horizontal_char - single character string used to draw horizontal lines junction_char - single character string used to draw line junctions sortby - name of field to sort rows by sort_key - sorting key function, applied to data points before sorting reversesort - True or False to sort in descending or ascending order
-
_stringify_hrule
(self, options)¶
-
_stringify_header
(self, options)¶
-
_stringify_row
(self, row, options)¶
-
get_html_string
(self, **kwargs)¶ Return string representation of HTML formatted version of table in current state.
Arguments:
start - index of first data row to include in output end - index of last data row to include in output PLUS ONE (list slice style) fields - names of fields (columns) to include header - print a header showing field names (True or False) border - print a border around the table (True or False) hrules - controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE vrules - controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE int_format - controls formatting of integer data float_format - controls formatting of floating point data padding_width - number of spaces on either side of column data (only used if left and right paddings are None) left_padding_width - number of spaces on left hand side of column data right_padding_width - number of spaces on right hand side of column data sortby - name of field to sort rows by sort_key - sorting key function, applied to data points before sorting attributes - dictionary of name/value pairs to include as HTML attributes in the <table> tag
-
_get_simple_html_string
(self, options)¶
-
_get_formatted_html_string
(self, options)¶
-
-
cloudmesh-common.cloudmesh.common.prettytable.
_char_block_width
(char)¶
-
cloudmesh-common.cloudmesh.common.prettytable.
_str_block_width
(val)¶
-
cloudmesh-common.cloudmesh.common.prettytable.
from_csv
(fp, field_names=None, **kwargs)¶
-
cloudmesh-common.cloudmesh.common.prettytable.
from_db_cursor
(cursor, **kwargs)¶
-
class
cloudmesh-common.cloudmesh.common.prettytable.
TableHandler
(**kwargs)¶ Bases:
html.parser.HTMLParser
Find tags and other markup and call handler functions.
- Usage:
p = HTMLParser() p.feed(data) … p.close()
Start tags are handled by calling self.handle_starttag() or self.handle_startendtag(); end tags by self.handle_endtag(). The data between tags is passed from the parser to the derived class by calling self.handle_data() with the data as argument (the data may be split up in arbitrary chunks). If convert_charrefs is True the character references are converted automatically to the corresponding Unicode character (and self.handle_data() is no longer split in chunks), otherwise they are passed by calling self.handle_entityref() or self.handle_charref() with the string containing respectively the named or numeric reference as the argument.
-
handle_starttag
(self, tag, attrs)¶
-
handle_endtag
(self, tag)¶
-
handle_data
(self, data)¶
-
generate_table
(self, rows)¶ Generates from a list of rows a PrettyTable object.
-
make_fields_unique
(self, fields)¶ iterates over the row and make each field unique
-
cloudmesh-common.cloudmesh.common.prettytable.
from_html
(html_code, **kwargs)¶ Generates a list of PrettyTables from a string of HTML code. Each <table> in the HTML becomes one PrettyTable object.
-
cloudmesh-common.cloudmesh.common.prettytable.
from_html_one
(html_code, **kwargs)¶ Generates a PrettyTables from a string of HTML code which contains only a single <table>
-
cloudmesh-common.cloudmesh.common.prettytable.
main
()¶