Ejemplo n.º 1
0
 def bind(self, name, object_):
     '''Add the name:object binding to self.namespace.'''
     if name in self.namespace:
         g.trace('redefining', name)
         g.printDict(self.namespace)
     self.namespace [name] = object_
     return object_
Ejemplo n.º 2
0
 def bind(self, name, object_):
     '''Add the name:object binding to self.namespace.'''
     if name in self.namespace:
         g.trace('redefining', name)
         g.printDict(self.namespace)
     self.namespace [name] = object_
     return object_
Ejemplo n.º 3
0
 def dumpNode(self, event=None):
     """Dump c.p.v, including gnx, uA's, etc."""
     p = self.c.p
     if p:
         g.es_print(f"gnx: {p.v.gnx} {p.v.h}")
         if p.v.u:
             g.es_print('uAs')
             g.printDict(p.v.u)
         else:
             g.es_print('no uAs')
Ejemplo n.º 4
0
 def dumpNode(self, event=None):
     '''Dump c.p.v, including gnx, uA's, etc.'''
     p = self.c.p
     if p:
         g.es_print('gnx: %s %s' % (p.v.gnx, p.v.h))
         if p.v.u:
             g.es_print('uAs')
             g.printDict(p.v.u)
         else:
             g.es_print('no uAs')
Ejemplo n.º 5
0
 def dumpNode(self, event=None):
     '''Dump c.p.v, including gnx, uA's, etc.'''
     p = self.c.p
     if p:
         g.es_print('gnx: %s %s' % (p.v.gnx, p.v.h))
         if p.v.u:
             g.es_print('uAs')
             g.printDict(p.v.u)
         else:
             g.es_print('no uAs')
Ejemplo n.º 6
0
 def update_before_write_foreign_file(self, root):
     '''
     Update the @data node for root, a foreign node.
     Create @gnxs nodes and @uas trees as needed.
     '''
     # Delete all children of the @data node.
     trace = False and not g.unitTesting
     if trace:
         g.trace(root and root.h)
         g.printDict(root.v.u)
     self.at_persistence = self.find_at_persistence_node()
     if not self.at_persistence:
         if trace: g.trace('no @persistence node')
         return None
         # was return at_data # for at-file-to-at-auto command.
     at_data = self.find_at_data_node(root)
     self.delete_at_data_children(at_data, root)
     # Create the data for the @gnxs and @uas trees.
     aList, seen = [], []
     for p in root.subtree():
         gnx = p.v.gnx
         assert gnx
         if gnx not in seen:
             seen.append(gnx)
             aList.append(p.copy())
     # Create the @gnxs node
     at_gnxs = self.find_at_gnxs_node(root)
     at_gnxs.b = ''.join([
         'gnx: %s\nunl: %s\n' % (p.v.gnx, self.relative_unl(p, root))
         for p in aList
     ])
     # Create the @uas tree.
     uas = [p for p in aList if p.v.u]
     if uas:
         at_uas = self.find_at_uas_node(root)
         if at_uas.hasChildren():
             at_uas.deleteAllChildren()
         for p in uas:
             p2 = at_uas.insertAsLastChild()
             p2.h = '@ua:' + p.v.gnx
             p2.b = 'unl:%s\nua:%s' % (self.relative_unl(
                 p, root), self.pickle(p))
             if trace: g.trace('created:', p2.h)
     # This is no longer necessary because of at.saveOutlineIfPossible.
     if False and not g.app.initing and not g.unitTesting:
         # Explain why the .leo file has become dirty.
         g.es_print('updated: @data:%s ' % (root.h))
     return at_data  # For at-file-to-at-auto command.
Ejemplo n.º 7
0
 def update_before_write_foreign_file(self, root):
     '''
     Update the @data node for root, a foreign node.
     Create @gnxs nodes and @uas trees as needed.
     '''
     # Delete all children of the @data node.
     trace = False and not g.unitTesting
     if trace:
         g.trace(root and root.h)
         g.printDict(root.v.u)
     self.at_persistence = self.find_at_persistence_node()
     if not self.at_persistence:
         if trace: g.trace('no @persistence node')
         return None
         # was return at_data # for at-file-to-at-auto command.
     at_data = self.find_at_data_node(root)
     self.delete_at_data_children(at_data, root)
     # Create the data for the @gnxs and @uas trees.
     aList, seen = [], []
     for p in root.subtree():
         gnx = p.v.gnx
         assert gnx
         if gnx not in seen:
             seen.append(gnx)
             aList.append(p.copy())
     # Create the @gnxs node
     at_gnxs = self.find_at_gnxs_node(root)
     at_gnxs.b = ''.join(
         ['gnx: %s\nunl: %s\n' % (p.v.gnx, self.relative_unl(p, root))
             for p in aList])
     # Create the @uas tree.
     uas = [p for p in aList if p.v.u]
     if uas:
         at_uas = self.find_at_uas_node(root)
         if at_uas.hasChildren():
             at_uas.deleteAllChildren()
         for p in uas:
             p2 = at_uas.insertAsLastChild()
             p2.h = '@ua:' + p.v.gnx
             p2.b = 'unl:%s\nua:%s' % (
                 self.relative_unl(p, root), self.pickle(p))
             if trace: g.trace('created:', p2.h)
     # This is no longer necessary because of at.saveOutlineIfPossible.
     if False and not g.app.initing and not g.unitTesting:
         # Explain why the .leo file has become dirty.
         g.es_print('updated: @data:%s ' % (root.h))
     return at_data # For at-file-to-at-auto command.
Ejemplo n.º 8
0
 def handle_exiting_widgets(self, condition):
     trace = False and not g.unitTesting
     trace_handlers = False
     func = self.how_exited_handers[condition]
     if trace:
         g.pr('-' * 70)
         g.trace('(_FormBase:%s) how_exited: %r %s.%s' % (
             self.__class__.__name__,
             condition,
             func.__self__.__class__.__name__ if hasattr(func, '__self__') else 'function',
             func.__name__,
         ))
         if trace_handlers:
             g.trace('_FormBase.how_exited_handlers...')
             d = self.how_exited_handers
             g.printDict({key: d.get(key).__name__ for key in d})
             # g.printDict(d)
     func()
Ejemplo n.º 9
0
 def handle_exiting_widgets(self, condition):
     trace = False and not g.unitTesting
     trace_handlers = False
     func = self.how_exited_handers[condition]
     if trace:
         g.pr('-'*70)
         g.trace('(_FormBase:%s) how_exited: %r %s.%s' % (
             self.__class__.__name__,
             condition,
             func.__self__.__class__.__name__ if hasattr(func, '__self__') else 'function',
             func.__name__,
         ))
         if trace_handlers:
             g.trace('_FormBase.how_exited_handlers...')
             d = self.how_exited_handers
             g.printDict({key: d.get(key).__name__ for key in d})
             # g.printDict(d)
     func()
Ejemplo n.º 10
0
 def update(self, tag, keywords):
     '''Update the vr pane.'''
     verbose = True
     pc = self
     p = pc.c.p
     if pc.must_update(keywords):
         if trace and verbose:
             g.trace('===== updating')
             g.printDict(keywords)
         # Suppress updates until we change nodes.
         pc.node_changed = pc.gnx != p.v.gnx
         pc.gnx = p.v.gnx
         pc.length = len(p.b)  # not s
         # Remove Leo directives.
         s = keywords.get('s') if 's' in keywords else p.b
         s = pc.remove_directives(s)
         # Dispatch based on the computed kind.
         kind = keywords.get(
             'flags') if 'flags' in keywords else pc.get_kind(p)
         f = pc.dispatch_dict.get(kind)
         if f:
             if trace and verbose: g.trace(p.h, f.__name__)
         else:
             g.trace('no handler for kind: %s' % kind)
             f = pc.update_rst
         f(s, keywords)
     else:
         # Save the scroll position.
         w = pc.w
         if w.__class__ == QtWidgets.QTextBrowser:
             # 2011/07/30: The widget may no longer exist.
             try:
                 sb = w.verticalScrollBar()
                 pc.scrollbar_pos_dict[p.v] = sb.sliderPosition()
             except Exception:
                 g.es_exception()
                 pc.deactivate()