summaryrefslogtreecommitdiffstats
path: root/scripts/tiny
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-06-02 13:12:59 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-03 13:13:29 +0100
commitf1e85d476030b83a748f0d70da5570e28dd8ac0d (patch)
tree3476c1bd27491aa752fa2419af6630d55d3e5ef3 /scripts/tiny
parenta4045424afbb0634bce0e1d22d73839128020983 (diff)
downloadpoky-f1e85d476030b83a748f0d70da5570e28dd8ac0d.tar.gz
dirsize: python3: fix TypeError: unorderable types
Python 3 ignores the __cmp__() method and doesn't have cmp() builtin function. This caused sorted() call to raise TypeError: unorderable types: Record() < Record() Removing __cmp__ method and implementing __lt__ should solve the problem as __lt__ is the only method needed for sort[ed] to work. (From OE-Core rev: 391cd33720e7d7e8e261193199272739293ad881) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/tiny')
-rwxr-xr-xscripts/tiny/dirsize.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/scripts/tiny/dirsize.py b/scripts/tiny/dirsize.py
index 5329b86f75..0b4fbd1fa7 100755
--- a/scripts/tiny/dirsize.py
+++ b/scripts/tiny/dirsize.py
@@ -52,20 +52,16 @@ class Record:
52 self.size = 0 52 self.size = 0
53 self.records = [] 53 self.records = []
54 54
55 def __cmp__(this, that): 55 def __lt__(this, that):
56 if that is None: 56 if that is None:
57 return 1 57 return False
58 if not isinstance(that, Record): 58 if not isinstance(that, Record):
59 raise TypeError 59 raise TypeError
60 if len(this.records) > 0 and len(that.records) == 0: 60 if len(this.records) > 0 and len(that.records) == 0:
61 return -1 61 return False
62 if len(this.records) == 0 and len(that.records) > 0:
63 return 1
64 if this.size < that.size:
65 return -1
66 if this.size > that.size: 62 if this.size > that.size:
67 return 1 63 return False
68 return 0 64 return True
69 65
70 def show(self, minsize): 66 def show(self, minsize):
71 total = 0 67 total = 0