How to use the leo.core.leoGlobals.trace 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 / plugins / screencast.py View on Github external
def caption(self, s, pane): # To do: center option.
        '''Pop up a QPlainTextEdit in the indicated pane.'''
        m = self
        parent = m.pane_widget(pane)
        if not parent:
            g.trace('bad pane: %s' % (pane))
            return None
        s = s.rstrip()
        if s and s[-1].isalpha():
            s = s + '.'
        w = QtWidgets.QPlainTextEdit(s, parent)
        w.setObjectName('screencastcaption')
        m.widgets.append(w)
        w2 = m.pane_widget(pane)
        geom = w2.geometry()
        w.resize(geom.width(), min(150, geom.height() / 2))
        off = QtCore.Qt.ScrollBarAlwaysOff
        w.setHorizontalScrollBarPolicy(off)
        w.setVerticalScrollBarPolicy(off)
        w.show()
        return w
github leo-editor / leo-editor / leo / core / leoTkinterFind.py View on Github external
def setOption (self,ivar,val):

        if ivar in self.intKeys:
            if val is not None:
                var = self.svarDict.get(ivar)
                var.set(val)
                # g.trace('%s = %s' % (ivar,val))

        elif not g.app.unitTesting:
            g.trace('oops: bad find ivar %s' % ivar)
    #@-node:ekr.20070212092525:setOption
github leo-editor / leo-editor / leo / core / leoFileCommands.py View on Github external
g.es_print('unexpected exception converting hexlified string to string')
            g.es_exception()
            return None
        # Leave string attributes starting with 'str_' alone.
        if attr.startswith('str_'):
            if isinstance(val, (str, bytes)):
                return g.toUnicode(val)
        try:
            binString = binascii.unhexlify(val)
                # Throws a TypeError if val is not a hex string.
        except Exception:
            # Assume that Leo 4.1 or above wrote the attribute.
            if g.unitTesting:
                assert kind == 'raw', f"unit test failed: kind={kind}"
            else:
                g.trace(f"can not unhexlify {attr}={val}")
            return val
        try:
            # No change needed to support protocols.
            val2 = pickle.loads(binString)
            return val2
        except Exception:
            try:
                val2 = pickle.loads(binString, encoding='bytes')
                val2 = self.bytesToUnicode(val2)
                return val2
            except Exception:
                g.trace(f"can not unpickle {attr}={val}")
                return val
    #@+node:ekr.20180606044154.1: *6* fast.bytesToUnicode
github leo-editor / leo-editor / leo / core / leoCompare.py View on Github external
def diff_list_of_files(self, aList, visible=True):
        """The main entry point for scripts."""
        if len(aList) < 2:
            g.trace('Not enough files in', repr(aList))
            return
        self.root = self.create_root(aList)
        self.visible = visible
        while len(aList) > 1:
            path1 = aList[0]
            aList = aList[1:]
            for path2 in aList:
                self.diff_two_files(path1, path2)
        self.finish()
    #@+node:ekr.20180211170333.3: *3* loc.diff_two_files
github leo-editor / leo-editor / leo / core / leoTkinterTree.py View on Github external
data = self.iconIds.get(theId[0])
        except:
            data = self.iconIds.get(theId)

        if data:
            p,generation = data
            if generation==self.generation:
                if self.trace and self.verbose:
                    g.trace(theId,p.headString())
                return p
            else:
                if self.trace and self.verbose:
                    g.trace("*** wrong generation: %d ***" % theId)
                return None
        else:
            if self.trace and self.verbose: g.trace(theId,None)
            return None
    #@-node:ekr.20040803072955.109:findVnodeWithIconId
github leo-editor / leo-editor / leo / core / leoConfig.py View on Github external
def typesMatch(self, type1, type2):
        '''
        Return True if type1, the actual type, matches type2, the requeseted type.

        The following equivalences are allowed:

        - None matches anything.
        - An actual type of string or strings matches anything *except* shortcuts.
        - Shortcut matches shortcuts.
        '''
        # The shortcuts logic no longer uses the get/set code.
        shortcuts = ('shortcut', 'shortcuts',)
        if type1 in shortcuts or type2 in shortcuts:
            g.trace('oops: type in shortcuts')
        return (
            type1 is None or type2 is None or
            type1.startswith('string') and type2 not in shortcuts or
            type1 == 'int' and type2 == 'size' or
            (type1 in shortcuts and type2 in shortcuts) or
            type1 == type2
        )
github leo-editor / leo-editor / leo / plugins / importers / basescanner.py View on Github external
return s # Never unindent rst code.
        tag = self.c.atFileCommands.underindentEscapeString
        result = []; tab_width = self.tab_width
        for line in g.splitlines(s):
            lws_s = g.get_leading_ws(line)
            lws = g.computeWidth(lws_s, tab_width)
            s = g.removeLeadingWhitespace(line, undentVal, tab_width)
            # 2011/10/29: Add underindentEscapeString only for strict languages.
            if self.strict and s.strip() and lws < undentVal:
                if trace: g.trace('undentVal: %s, lws: %s, %s' % (
                    undentVal, lws, repr(line)))
                # Bug fix 2012/06/05: end the underindent count with a period,
                # to protect against lines that start with a digit!
                result.append("%s%s.%s" % (tag, undentVal - lws, s.lstrip()))
            else:
                if trace: g.trace(repr(s))
                result.append(s)
        return ''.join(result)
    #@+node:ekr.20140727075002.18227: *4* BaseScanner.underindentedComment & underindentedLine
github leo-editor / leo-editor / leo / core / leoViews.py View on Github external
if trace: # A highly useful trace!
            g.trace('\n\nunsorted_list...\n%s' % (
                '\n'.join(['%40s ==> %s' % (parent.h,p.h)
                    for parent,p in vc.work_list])))
        # Create a dictionary of each organizers children.
        d = {}
        for parent,p in vc.work_list:
            # This key must remain stable if parent moves.
            key = parent
            aList = d.get(key,[])
            aList.append(p)
            # g.trace(key,[z.h for z in aList])
            d[key] = aList
        if trace and trace_dict:
            # g.trace('d...',sorted([z.h for z in d.keys()]))
            g.trace('d{}...')
            for key in sorted(d.keys()):
                aList = [z.h for z in d.get(key)]
                g.trace('%s %-20s %s' % (id(key),key.h,vc.dump_list(aList,indent=29)))
        # Move *copies* of non-organizer nodes to each organizer.
        organizers = list(d.keys())
        existing_organizers = [z.p.copy() for z in vc.existing_ods]
        moved_existing_organizers = {} # Keys are vnodes, values are positions.
        for parent in organizers:
            aList = d.get(parent,[])
            if trace and trace_moves:
                g.trace('===== moving/copying:',parent.h,
                    'with %s children:' % (len(aList)),
                    '\n  '+'\n  '.join([z.h for z in aList]))
            for p in aList:
                if p in existing_organizers:
                    if trace and trace_moves:
github leo-editor / leo-editor / leo / core / leoTkinterTree.py View on Github external
def newClickBox (self,p,x1,y1,x2,y2):

        canvas = self.canvas ; defaultColor = ""
        tag = g.choose(p.hasChildren(),'clickBox','selectBox')

        if self.freeClickBoxes:
            # theId = self.freeClickBoxes.pop(0)
            d = self.freeClickBoxes ; theId = d.keys()[0] ; del d[theId]
            canvas.coords(theId,x1,y1,x2,y2)
            canvas.itemconfig(theId,tag=tag)
        else:
            theId = self.canvas.create_rectangle(x1,y1,x2,y2,tag=tag)
            canvas.itemconfig(theId,fill=defaultColor,outline=defaultColor)
            if self.trace_alloc: g.trace("%3d %s" % (theId,p and p.headString()),align=-20)

        if theId not in self.visibleClickBoxes:
            self.visibleClickBoxes.append(theId)
        if p:
            self.ids[theId] = p

        return theId
    #@-node:ekr.20040803072955.8:newClickBox