(self, message, **kwargs)
return "{}:{}: {}".format(fn, sourceline, message)
Prepend a file and/or line reference to the message, if possible.

        If filename is given as a keyword argument, it is used on its own.

        If filename is not given, this will attempt to retrieve the filename and line from an XML element.
        If 'elem' is given as a keyword argument and is not None, it is used to find the line.
        If 'elem' is given as None, no XML elements are looked at.
        If 'elem' is not supplied, the error context element is used.

        If using XML, the filename, if available, is retrieved from the Registry class.
        If using XML and python-lxml is installed, the source line is retrieved from whatever element is chosen.
Prepend a file and/or line reference to the message, if possible.
Prepend a file and / or line reference to the message if possible .
def _prepend_sourceline_to_message(self, message, **kwargs):
        """Prepend a file and/or line reference to the message, if possible.

        If filename is given as a keyword argument, it is used on its own.

        If filename is not given, this will attempt to retrieve the filename and line from an XML element.
        If 'elem' is given as a keyword argument and is not None, it is used to find the line.
        If 'elem' is given as None, no XML elements are looked at.
        If 'elem' is not supplied, the error context element is used.

        If using XML, the filename, if available, is retrieved from the Registry class.
        If using XML and python-lxml is installed, the source line is retrieved from whatever element is chosen."""
        fn = kwargs.get('filename')
        sourceline = None

        if fn is None:
            elem = kwargs.get('elem', self.elem)
            if elem is not None:
                sourceline = getattr(elem, 'sourceline', None)
                if self.reg.filename:
                    fn = self.reg.filename

        if fn is None and sourceline is None:
            return message

        if fn is None:
            return "Line {}: {}".format(sourceline, message)

        if sourceline is None:
            return "{}: {}".format(fn, message)

        return "{}:{}: {}".format(fn, sourceline, message)
def _prepend_sourceline_to_message ( self , message , * * kwargs ) : fn = kwargs . get ( 'filename' ) sourceline = None if fn is None : elem = kwargs . get ( 'elem' , self . elem ) if elem is not None : sourceline = getattr ( elem , 'sourceline' , None ) if self . reg . filename : fn = self . reg . filename if fn is None and sourceline is None : return message if fn is None : return "Line {}: {}" . format ( sourceline , message ) if sourceline is None : return "{}: {}" . format ( fn , message ) return "{}:{}: {}" . format ( fn , sourceline , message )