Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/webapp-config:master commit in: WebappConfig/
Date: Fri, 29 Jun 2012 13:01:42
Message-Id: 1340974225.2e80fd31bf94d67944af1bd44491cf67ef08bb06.blueness@gentoo
1 commit: 2e80fd31bf94d67944af1bd44491cf67ef08bb06
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
3 AuthorDate: Fri Jun 29 00:35:12 2012 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Fri Jun 29 12:50:25 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=2e80fd31
7
8 Do not use cmp() for compatibility with Python 3.
9
10 Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>
11
12 ---
13 WebappConfig/content.py | 13 +------------
14 WebappConfig/db.py | 2 +-
15 2 files changed, 2 insertions(+), 13 deletions(-)
16
17 diff --git a/WebappConfig/content.py b/WebappConfig/content.py
18 index 4e0462b..8e92622 100644
19 --- a/WebappConfig/content.py
20 +++ b/WebappConfig/content.py
21 @@ -548,19 +548,8 @@ class Contents:
22 ''' Get a list of files. This is returned as a list sorted according
23 to length, so that files lower in the hierarchy can be removed
24 first.'''
25 - def lencmp(x, y):
26 - zx = len(x)
27 - zy = len(y)
28 - if zx > zy:
29 - return -1
30 - if zy > zx:
31 - return 1
32 - return cmp(x, y)
33 -
34 installed = self.__content.keys()
35 - installed.sort(lencmp)
36 -
37 - return installed
38 + return sorted(installed, key=lambda x: (-len(x), x))
39
40 def get_directories(self):
41 ''' Get only the directories as a sorted list.'''
42
43 diff --git a/WebappConfig/db.py b/WebappConfig/db.py
44 index ccb7b0e..c925792 100644
45 --- a/WebappConfig/db.py
46 +++ b/WebappConfig/db.py
47 @@ -202,7 +202,7 @@ class WebappDB(AppHierarchy):
48 varies whith your code location)
49
50 >>> sb = [i[1] for i in b.list_locations().items()]
51 - >>> sb.sort(lambda x,y: cmp(x[0]+x[1]+x[2],y[0]+y[1]+y[2]))
52 + >>> sb.sort(key=lambda x: x[0]+x[1]+x[2])
53 >>> sb
54 [['', 'gallery', '1.4.4_p6'], ['', 'gallery', '2.0_rc2'], ['', 'horde', '3.0.5'], ['', 'phpldapadmin', '0.9.7_alpha4']]