1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
From cf983d0a3902776f0a13d0d6fac0d7b606bdc4e0 Mon Sep 17 00:00:00 2001
From: Yaroslav Halchenko <debian@onerussian.com>
Date: Tue, 23 Mar 2010 11:49:58 -0400
Subject: [PATCH] ENH: Making sorting of calendars error resistant by placing
unknown keys last. Thanks Bill Gatliff for suggestion
---
gcalcli | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
--- a/gcalcli
+++ b/gcalcli
@@ -355,9 +355,15 @@ class gcalcli:
self.ACCESS_READ : 8,
self.ACCESS_NONE : 9 }
+ def order_resistant(k):
+ """Helper which would not puke but order last entries with
+ unknown keys
+ """
+ return order.get(k, order[self.ACCESS_NONE]+1)
+
self.allCals.entry.sort(lambda x, y:
- cmp(order[x.access_level.value],
- order[y.access_level.value]))
+ cmp(order_resistant(x.access_level.value),
+ order_resistant(y.access_level.value)))
for cal in self.allCals.entry:
|