Fork me on GitHub

pyhrf.tools.message module

This package provide a mean to print colored message to a standard terminal if color is available else message are print in black and white mode. If stdout is redirected in a file or piped to an other program, the output is made black and white to avoid issus with strange caracters that defined colors in terminals. Remember that all messages are print to stdout.

This package exists in 3 places, for some very good arguments :
datamind.tools.message soma.wip.message pyhrf.tools.message

To use these functionalities, play with ‘msg’ instance. Here, some classical uses :

msg.info(‘something cool happend’): msg.error(self, ‘too bad, an error’): msg.warning(self, ‘something strange but not fatal’): msg.write_list((‘no color’, (‘color in red’, ‘red’))): msg.write(‘simple colored write function’) msg.string(‘string to colored string’)
class pyhrf.tools.message.Message

Bases: object

sys = <module 'sys' (built-in)>
class pyhrf.tools.message.MessageColor

Bases: object

classmethod error(msg)
haveColor()
classmethod info(msg)
classmethod string(msg, color='back')
classmethod warning(msg)
classmethod write(msg, color='back')
classmethod write_list(msg_list)
class pyhrf.tools.message.MessageNoColor

Bases: pyhrf.tools.message.MessageColor

classmethod error(msg)
haveColor()
classmethod info(msg)
classmethod string(msg, color='back')
classmethod warning(msg)
class pyhrf.tools.message.NoMessage

Bases: object

error(msg)
haveColor()
info(msg)
string(msg, color='back')
warning(msg)
write(msg, color='back')
write_list(msg_list)