How to use the leo.core.leoGlobals.es_exception function in leo

To help you get started, we’ve selected a few leo 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 leo-editor / leo-editor / leo / core / leoMarkup.py View on Github external
# Write each root to a file.
        i_paths = []
        for p in roots:
            try:
                i_path = self.filename(p)
                # #1398.
                i_path = c.expand_path_expression(i_path)
                i_path = g.os_path_finalize(i_path)
                with open(i_path, 'w', encoding='utf-8', errors='replace') as self.output_file:
                    self.write_root(p)
                    i_paths.append(i_path)
            except IOError:
                g.es_print(f"Can not open {i_path!r}")
            except Exception:
                g.es_print(f"Unexpected exception opening {i_path!r}")
                g.es_exception()
        # Convert each file to html.
        o_paths = []
        for i_path in i_paths:
            o_path = self.compute_opath(i_path)
            o_paths.append(o_path)
            if kind == 'adoc':
                self.run_asciidoctor(i_path, o_path)
            elif kind == 'pandoc':
                self.run_pandoc(i_path, o_path)
            elif kind == 'sphinx':
                self.run_sphinx(i_path, o_path)
            else:
                g.trace('BAD KIND')
                return None
            if kind != 'sphinx':
                print(f"{kind}: wrote {o_path}")
github leo-editor / leo-editor / leo / plugins / rst3.py View on Github external
# if not os.access(theDir,os.F_OK):
                # os.mkdir(theDir)

            if self.getOption('write_intermediate_file'):
                name = self.outputFileName + '.txt'
                f = open(name,'w')
                f.write(self.source)
                f.close()
                self.report(name)

        try:
            output = self.writeToDocutils(self.source)
            ok = True
        except Exception:
            g.pr('Exception in docutils')
            g.es_exception()
            ok = False

        if ok:
            if isHtml:
                import re
                idxTitle = output.find('<title></title>')
                if idxTitle &gt; -1:
                    m = re.search('<h1>([^&lt;]*)</h1>', output)
                    if not m:
                        m = re.search('<h1>&lt;[^&gt;]+&gt;([^&lt;]*)</h1>', output)
                    if m:
                        output = output.replace(
                            '<title></title>',
                            '<title>%s</title>' % m.group(1)
                        )
github leo-editor / leo-editor / leo / core / leoTkinterFrame.py View on Github external
def setCanvasColorFromConfig (self,canvas):

        c = self.c

        bg = c.config.getColor("outline_pane_background_color") or 'white'

        try:
            canvas.configure(bg=bg)
        except:
            g.es("exception setting outline pane background color")
            g.es_exception()
    #@-node:ekr.20070327094252:f.setCanvasColorFromConfig
github leo-editor / leo-editor / leo / plugins / color_markup.py View on Github external
# it won't allow copies of the picture.
            pass
            # g.trace('**picture exists',filename)
        else:
            index = colorer.index(i)
            # g.trace('**inserting picture',i,index)
            image = c.frame.body.bodyCtrl.image_create(index,image=photo,padx=0)
            w.mark_set(filename,index)
            # Keep references so images stay on the canvas.
            # The reference to photo must appear, even though it is not used.
            colorer.image_references.append((photo,image,index),)
    except:
        if not PIL:
            g.es_print('PIL not loaded: wiki images must be .gif or .pgm files.',color='blue')
        else:
            g.es_exception()
#@+node:edream.110403140857.19: ** Menu commands
github leo-editor / leo-editor / leo / plugins / leoOPML.py View on Github external
parser = xml.sax.make_parser()
            parser.setFeature(xml.sax.handler.feature_external_ges, 1)
            # Do not include external general entities.
            # The actual feature name is "http://xml.org/sax/features/external-general-entities"
            parser.setFeature(xml.sax.handler.feature_external_pes, 0)
            handler = SaxContentHandler(c, fn)
            parser.setContentHandler(handler)
            parser.parse(theFile) # expat does not support parseString
            sax_node = handler.getNode()
        except xml.sax.SAXParseException:
            g.error('error parsing', fn)
            g.es_exception()
            sax_node = None
        except Exception:
            g.error('unexpected exception parsing', fn)
            g.es_exception()
            sax_node = None
        return sax_node
    #@+node:ekr.20111003220434.15490: *4* oc.cleanSaxInputString
github leo-editor / leo-editor / leo / core / leoFileCommands.py View on Github external
def createActualFile(self, fileName, toOPML, toZip):
        if toZip:
            self.toString = True
            theActualFile = None
        else:
            try:
                # 2010/01/21: always write in binary mode.
                theActualFile = open(fileName, 'wb')
            except Exception:
                g.es(f"can not create {fileName}")
                g.es_exception()
                theActualFile = None
        return fileName, theActualFile
    #@+node:ekr.20031218072017.3047: *6* fc.createBackupFile
github leo-editor / leo-editor / leo / core / leoTkinterFrame.py View on Github external
def setColorFromConfig (self):

        c = self.c

        bg = c.config.getColor("log_pane_background_color") or 'white'

        try:
            self.logCtrl.configure(bg=bg)
        except:
            g.es("exception setting log pane background color")
            g.es_exception()
    #@-node:ekr.20041217135735.2:tkLog.setColorFromConfig
github leo-editor / leo-editor / leo / core / leoPersistence.py View on Github external
def pickle(self, p):
        """Pickle val and return the hexlified result."""
        try:
            ua = p.v.u
            s = pickle.dumps(ua, protocol=1)
            s2 = binascii.hexlify(s)
            s3 = g.toUnicode(s2, 'utf-8')
            return s3
        except pickle.PicklingError:
            g.warning("ignoring non-pickleable value", ua, "in", p.h)
            return ''
        except Exception:
            g.error("pd.pickle: unexpected exception in", p.h)
            g.es_exception()
            return ''
    #@+node:ekr.20140713135856.17744: *5* pd.unpickle
github leo-editor / leo-editor / leo / core / leoColorizer.py View on Github external
c, wrapper = self.c, self.wrapper
        getColor = c.config.getColor
            # getColor puts the color name in standard form:
            # color = color.replace(' ', '').lower().strip()
        for key in sorted(self.default_colors_dict.keys()):
            option_name, default_color = self.default_colors_dict[key]
            color = (
                getColor(f"{self.language}_{option_name}") or
                getColor(option_name) or
                default_color
            )
            # Must use foreground, not fg.
            try:
                wrapper.tag_configure(key, foreground=color)
            except Exception:  # Recover after a user settings error.
                g.es_exception()
                wrapper.tag_configure(key, foreground=default_color)
github leo-editor / leo-editor / leo / core / leoGtkGui.py View on Github external
def replaceClipboardWith (self,s):

        # g.app.gui.win32clipboard is always None.
        wcb = g.app.gui.win32clipboard

        if wcb:
            try:
                wcb.OpenClipboard(0)
                wcb.EmptyClipboard()
                wcb.SetClipboardText(s)
                wcb.CloseClipboard()
            except:
                g.es_exception()
        else:
            self.root.clipboard_clear()
            self.root.clipboard_append(s)
    #@-node:ekr.20080112145409.452:replaceClipboardWith