How to use the lookatme.config.LOG function in lookatme

To help you get started, we’ve selected a few lookatme examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github d0c-s4vage / lookatme / lookatme / __main__.py View on Github external
input_files = [io.StringIO("")]
    pres = Presentation(input_files[0], theme, code_style, live_reload=live_reload)

    if dump_styles:
        print(StyleSchema().dumps(pres.styles))
        return 0

    try:
        pres.run()
    except Exception as e:
        number = pres.tui.curr_slide.number + 1
        click.echo(f"Error rendering slide {number}: {e}")
        if not debug:
            click.echo("Rerun with --debug to view the full traceback in logs")
        else:
            lookatme.config.LOG.exception(f"Error rendering slide {number}: {e}")
            click.echo(f"See {log_path} for traceback")
        raise click.Abort()
github d0c-s4vage / lookatme / lookatme / render / pygments.py View on Github external
def render_text(text, lang="text", style_name=None, plain=False):
    """Render the provided text with the pygments renderer
    """
    if style_name is None:
        style_name = config.STYLE["style"]

    lexer = get_lexer(lang)
    formatter, style_bg = get_formatter(style_name)

    start = time.time()
    code_tokens = lexer.get_tokens(text)
    config.LOG.debug(f"Took {time.time()-start}s to render {len(text)} bytes")

    markup = []
    for x in formatter.formatgenerator(code_tokens):
        if style_bg:
            x[0].background = style_bg
        markup.append(x)

    if markup[-1][1] == "\n":
        markup = markup[:-1]

    if len(markup) == 0:
        markup = [(None, "")]
    elif markup[-1][1].endswith("\n"):
        markup[-1] = (markup[-1][0], markup[-1][1][:-1])

    if plain:
github d0c-s4vage / lookatme / lookatme / __main__.py View on Github external
def main(debug, log_path, theme, code_style, dump_styles, input_files, live_reload):
    """lookatme - An interactive, terminal-based markdown presentation tool.
    """
    if debug:
        lookatme.config.LOG = lookatme.log.create_log(log_path)
    else:
        lookatme.config.LOG = lookatme.log.create_null_log()

    if len(input_files) == 0:
        input_files = [io.StringIO("")]
    pres = Presentation(input_files[0], theme, code_style, live_reload=live_reload)

    if dump_styles:
        print(StyleSchema().dumps(pres.styles))
        return 0

    try:
        pres.run()
    except Exception as e:
        number = pres.tui.curr_slide.number + 1
        click.echo(f"Error rendering slide {number}: {e}")
        if not debug:
            click.echo("Rerun with --debug to view the full traceback in logs")
github d0c-s4vage / lookatme / lookatme / tui.py View on Github external
def __init__(self, pres, start_idx=0):
        """
        """
        self.slide_body = urwid.Pile(urwid.SimpleListWalker([urwid.Text("test")]))
        self.slide_title = text("", "", "center")

        self.creation = text("", "")
        self.slide_num = text("", " test ", "right")
        self.slide_footer = urwid.Columns([self.creation, self.slide_num])

        self._log = lookatme.config.LOG

        urwid.set_encoding('utf8')
        screen = urwid.raw_display.Screen()
        screen.set_terminal_properties(colors=256)
        self.loop = urwid.MainLoop(
            urwid.Padding(self, left=2, right=2),
            screen=screen,
        )

        # used to track slides that are being rendered
        self.slide_renderer = SlideRenderer(self.loop)
        self.slide_renderer.start()

        self.pres = pres
        self.prep_pres(self.pres, start_idx)
github d0c-s4vage / lookatme / lookatme / tui.py View on Github external
def __init__(self, loop):
        threading.Thread.__init__(self)
        self.events = defaultdict(threading.Event)
        self.keep_running = threading.Event()
        self.queue = Queue()
        self.loop = loop
        self.cache = {}
        self._log = lookatme.config.LOG.getChild("RENDER")
github d0c-s4vage / lookatme / lookatme / __main__.py View on Github external
def main(debug, log_path, theme, code_style, dump_styles, input_files, live_reload):
    """lookatme - An interactive, terminal-based markdown presentation tool.
    """
    if debug:
        lookatme.config.LOG = lookatme.log.create_log(log_path)
    else:
        lookatme.config.LOG = lookatme.log.create_null_log()

    if len(input_files) == 0:
        input_files = [io.StringIO("")]
    pres = Presentation(input_files[0], theme, code_style, live_reload=live_reload)

    if dump_styles:
        print(StyleSchema().dumps(pres.styles))
        return 0

    try:
        pres.run()
    except Exception as e:
        number = pres.tui.curr_slide.number + 1
        click.echo(f"Error rendering slide {number}: {e}")