On Thu, 11 Feb 2010 17:23:49 -0600
Terry Brown <[email protected]> wrote:
> Do you want me to push those changes, or at least post the diff for
> inspection?
Dumb question, why wouldn't you want me to post the diff for inspection.
helpForCommand contains a stealth use of sort(cmp) BTW, might want to test that
in Python 3.
Here's the diff
=== modified file 'leo/core/leoCommands.py'
--- leo/core/leoCommands.py 2010-02-11 22:02:41 +0000
+++ leo/core/leoCommands.py 2010-02-11 23:31:57 +0000
@@ -3966,7 +3966,7 @@
return p
#...@-node:ekr.20080503055349.1:c.setPositionAfterSort
#...@+node:ekr.20050415134809:c.sortChildren
- def sortChildren (self,event=None,cmp=None,key=None):
+ def sortChildren (self,event=None,key=None):
'''Sort the children of a node.'''
@@ -3976,7 +3976,7 @@
c.sortSiblings(p=p.firstChild(),sortChildren=True,key=key)
#...@-node:ekr.20050415134809:c.sortChildren
#...@+node:ekr.20050415134809.1:c.sortSiblings
- def sortSiblings
(self,event=None,cmp=None,key=None,p=None,sortChildren=False):
+ def sortSiblings (self,event=None,key=None,p=None,sortChildren=False):
'''Sort the siblings of a node.'''
@@ -3997,8 +3997,7 @@
return (self.h.lower())
key = lowerKey
- if cmp: newChildren.sort(cmp,key=key)
- else: newChildren.sort(key=key)
+ newChildren.sort(key=key)
if oldChildren == newChildren:
return
=== modified file 'leo/plugins/cleo.py'
--- leo/plugins/cleo.py 2009-10-03 07:29:56 +0000
+++ leo/plugins/cleo.py 2010-02-11 23:28:43 +0000
@@ -990,25 +990,21 @@
#...@nonl
#...@-node:tbrown.20061020145804:left_priority_menu
#...@+node:tbrown.20060903121429.52:priority_menu
- def pricmp(self, a, b):
- """cmp function for sorting by priority, a and b are (headstring,v)"""
+ def prikey(self, v):
+ """key function for sorting by priority"""
# getat returns 9999 for nodes without priority, so you'll only get -1
# if a[1] is not a node. Or even an object.
try:
- pa = int(self.getat(a[1], 'priority'))
- except:
+ pa = int(self.getat(v, 'priority'))
+ except ValueError:
pa = -1
- try:
- pb = int(self.getat(b[1], 'priority'))
- except:
- pb = -1
- return cmp(pa,pb)
+ return pa
def priSort(self):
self.c.selectPosition(self.pickleP)
- self.c.sortSiblings(cmp=self.pricmp)
+ self.c.sortSiblings(key=self.prikey)
def childrenTodo(self):
for p in self.pickleP.children():
=== modified file 'leo/plugins/todo.py'
--- leo/plugins/todo.py 2009-12-21 16:47:27 +0000
+++ leo/plugins/todo.py 2010-02-11 23:28:42 +0000
@@ -754,24 +754,20 @@
return False
#...@-node:tbrown.20090119215428.42:find_todo
- #...@+node:tbrown.20090119215428.43:pricmp
- def pricmp(self, a, b):
- """cmp function for sorting by priority, a and b are (headstring,v)"""
+ #...@+node:tbrown.20090119215428.43:prikey
+ def prikey(self, v):
+ """key function for sorting by priority"""
# getat returns 9999 for nodes without priority, so you'll only get -1
# if a[1] is not a node. Or even an object.
try:
- pa = int(self.getat(a[1], 'priority'))
- except:
+ pa = int(self.getat(v, 'priority'))
+ except ValueError:
pa = -1
- try:
- pb = int(self.getat(b[1], 'priority'))
- except:
- pb = -1
- return cmp(pa,pb)
+ return pa
#...@nonl
- #...@-node:tbrown.20090119215428.43:pricmp
+ #...@-node:tbrown.20090119215428.43:prikey
#...@+node:tbrown.20090119215428.44:priority_clear
@redrawer
def priority_clear(self,v=None):
@@ -787,7 +783,7 @@
if p is None:
p = self.c.currentPosition()
self.c.selectPosition(p)
- self.c.sortSiblings(cmp=self.pricmp)
+ self.c.sortSiblings(key=self.prikey)
#...@nonl
#...@-node:tbrown.20090119215428.45:priSort
#...@+node:tbrown.20090119215428.46:reclassify
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.