[docs]deffileno(self):ifself.fileisnotNone:returnself.file.fileno()else:raiseUnsupportedOperation('Cannot access fileno without a file object')
[docs]defcolourise(self,msg,force=False):""" Convert msg to the self.color colour in html Parameters ---------- msg str: The message to colourise force bool: By default, do not colorise html code (to avoid messing up existing colours). This forces the colorise nonetheless. Returns ------- """ifself.colorisnotNone:try:html=lxml.html.fromstring(msg)is_html=html.find('.//*')isnotNoneexceptlxml.etree.ParserError:is_html=Falseifforceornotis_html:iflen(msg.split(':'))>2andmsg.split(':')[2].endswith('Warning'):html_col=cnames['yellow']else:html_col=cnames[self.color]colour_msg=f'<p style="color:{html_col}">{msg}</p>'else:colour_msg=msgelse:colour_msg=msgreturncolour_msg