hal.streams package¶
Submodules¶
hal.streams.logger module¶
Logging module
hal.streams.markdown module¶
Markdown r/w models
hal.streams.pretty_table module¶
Pretty prints table in SQL style
-
class
hal.streams.pretty_table.
SqlTable
(labels, data, num_format, line_separator)[source]¶ Bases:
object
Table in SQL-syntax like form
-
static
from_df
(data_frame)[source]¶ Parses data and builds an instance of this class
Parameters: data_frame – pandas DataFrame Returns: SqlTable
-
get_blank_row
(filler='-', splitter='+')[source]¶ Gets blank row
Parameters: - filler – Fill empty columns with this char
- splitter – Separate columns with this char
Returns: Pretty formatted blank row (with no meaningful data in it)
-
static
-
hal.streams.pretty_table.
parse_colorama
(text)[source]¶ Parses colorama
Parameters: text – Colorama text to parse Returns: Parsed colorama text
-
hal.streams.pretty_table.
pretty_df
(data_frame)[source]¶ Parses data and builds an instance of this class
Parameters: data_frame – pandas DataFrame Returns: Pretty formatted table (first row is labels, then actual data)
-
hal.streams.pretty_table.
pretty_dicts
(dicts)[source]¶ Converts list of dicts to data frame, then calls ‘pretty_df’
Parameters: dicts – list of dicts Returns: Pretty formatted table (first row is labels, then actual data)
-
hal.streams.pretty_table.
pretty_format_table
(labels, data, num_format='{:.3f}', line_separator='\n')[source]¶ Parses and creates pretty table
Parameters: - labels – List of labels of data
- data – Matrix of any type
- num_format – Format numbers with this format
- line_separator – Separate each new line with this
Returns: Pretty formatted table (first row is labels, then actual data)
hal.streams.user module¶
Deal with user on standard output/input
-
class
hal.streams.user.
UserInput
(yes_choices=None, no_choices=None, threshold=None, interactive=True)[source]¶ Bases:
object
Chat with user and ask questions
-
NO_INPUT
= ['no', 'not ok', 'none']¶
-
THRESHOLD_INPUT
= 0.9¶
-
YES_INPUT
= ['yes', 'ok', 'fine']¶
-
get_answer
(question)[source]¶ Asks user a question, then gets user answer
Parameters: question – Question: to ask user Returns: User answer
-
get_list
(question, splitter=', ', at_least=0, at_most=inf)[source]¶ Parses answer and gets list
Parameters: - question – Question: to ask user
- splitter – Split list elements with this char
- at_least – List must have at least this amount of elements
- at_most – List must have at most this amount of elements
Returns: User answer
-
get_number
(question, min_i=-inf, max_i=inf, just_these=None)[source]¶ Parses answer and gets number
Parameters: - question – Question: to ask user
- min_i – min acceptable number
- max_i – max acceptable number
- just_these – Accept only these numbers
Returns: User answer
-
get_yes_no
(question)[source]¶ Checks if question is yes (True) or no (False)
Parameters: question – Question to ask user Returns: User answer
-
is_no
(answer)[source]¶ Checks if considered a “yes” answer
Parameters: answer – User answer Returns: True iff considered a “yes” answer
-