smpl.debug

Simplified python debuging.

file(key, value[, level, times, seperator, ...])

Prints the message msg if level > debug_level to file filename

file1(_key, _value[, level, times, _back])

Just like file() but times set to 1.

get_line_number_file([split, _back])

Gets the current filename and the current linenumber within it.

msg(msg[, tag, level, times, line_, _back])

Prints the message msg if level > debug_level and always returns the msg.

msg1(_msg[, tag, level, times, line_, _back])

Just like msg() but times set to 1.

once([_back])

Returns true only one time

table(key, value[, level, times, seperator, ...])

Saves key:value in filename.

table_flush_header([filename, seperator])

Saves the current keys from table() to filename

table_flush_line([filename, seperator])

Saves the current values from table() to filename

Functions

smpl.debug.file(key, value, level=0, times=-1, seperator=';', _print=True, _back=0, filename='debug.csv')[source]

Prints the message msg if level > debug_level to file filename

smpl.debug.file1(_key, _value, level=0, times=1, _back=0, **kwargs)[source]

Just like file() but times set to 1.

smpl.debug.get_line_number_file(split=True, _back=0)[source]

Gets the current filename and the current linenumber within it.

Parameters
splitbool

Indicates whenever the folders above of the file should be included in the returned filename.

_backint

Number of stack/frames to go back.

Returns
filenumberint

First element in the return array

filenamestr

Second element in the return array

smpl.debug.msg(msg, tag='', level=0, times=-1, line_=False, _back=0, **kwargs)[source]

Prints the message msg if level > debug_level and always returns the msg.

Parameters
tagstr

Sets a tag to be printed for the debug message.

levelint

Debug level.

timesint

How often should the message be printed if the function gets called multiple times (e.g. in a loop).

_linebool

Print the current line in the python source.

_backint

Number of stack/frames to go back.

Examples

>>> msg("hi", level = -9999)
DBG::debug.py:...: hi
'hi'
>>> msg("hi")
'hi'
smpl.debug.msg1(_msg, tag='', level=0, times=1, line_=False, _back=0, **kwargs)[source]

Just like msg() but times set to 1.

smpl.debug.once(_back=0)[source]

Returns true only one time

Examples

>>> for i in range(10):
...     if once():
...         print(i)
0
smpl.debug.table(key, value, level=0, times=-1, seperator=';', _print=False, _back=0, filename='debug_table.csv')[source]

Saves key:value in filename.

smpl.debug.table_flush_header(filename='debug_table.csv', seperator=';')[source]

Saves the current keys from table() to filename

smpl.debug.table_flush_line(filename='debug_table.csv', seperator=';')[source]

Saves the current values from table() to filename