Ejemplo n.º 1
0
    def print_html(html_str):
        """Add the html code to the output window.

        Example:
            >>> output = pyrevit.output.get_output()
            >>> output.print_html('<strong>Title</strong>')
        """
        print(coreutils.prepare_html_str(emoji.emojize(html_str)), end="")
Ejemplo n.º 2
0
    def emojize(md_str):
        """Replace emoji codes with emoji images and print.

        Args:
            md_str (str): string containing emoji code

        Example:
            >>> output = pyrevit.output.get_output()
            >>> output.emojize('Process completed. :thumbs_up:')
        """
        print(emoji.emojize(md_str), end="")
Ejemplo n.º 3
0
    def print_md(md_str):
        """Process markdown code and print to output window.

        Example:
            >>> output = pyrevit.output.get_output()
            >>> output.print_md('### Title')
        """
        tables_ext = 'pyrevit.coreutils.markdown.extensions.tables'
        markdown_html = markdown.markdown(md_str, extensions=[tables_ext])
        markdown_html = markdown_html.replace('\n', '').replace('\r', '')
        html_code = emoji.emojize(coreutils.prepare_html_str(markdown_html))
        print(html_code, end="")
Ejemplo n.º 4
0
 def _log(self, level, msg, args, exc_info=None, extra=None):
     # any report other than logging.INFO level reports, need to cleanup < and > character to avoid html conflict
     msg_str = ''
     if not isinstance(msg, str):
         msg_str = str(msg)
     else:
         msg_str = msg
     # get rid of unicode characters
     msg_str = msg_str.encode('ascii', 'ignore')
     msg_str = msg_str.replace(os.path.sep, '/')
     msg_str = emojize(msg_str)
     if level == logging.INFO:
         msg_str = prepare_html_str(msg_str)
     logging.Logger._log(self,
                         level,
                         msg_str,
                         args,
                         exc_info=None,
                         extra=None)
Ejemplo n.º 5
0
    def _log(self, level, msg, args, exc_info=None, extra=None):
        self._has_errors = (self._has_errors or level >= logging.ERROR)

        # any report other than logging.INFO level,
        # needs to cleanup < and > character to avoid html conflict
        if not isinstance(msg, str):
            msg_str = safe_strtype(msg)
        else:
            msg_str = msg
        # get rid of unicode characters
        msg_str = msg_str.encode('ascii', 'ignore')
        msg_str = msg_str.replace(os.path.sep, '/')
        msg_str = emojize(msg_str)
        if level == logging.INFO:
            msg_str = prepare_html_str(msg_str)

        logging.Logger._log(self,
                            level,
                            msg_str,
                            args,
                            exc_info=exc_info,
                            extra=extra)