Skip to content

Commit

Permalink
Fixes #104 - Replace None with "" when sorting
Browse files Browse the repository at this point in the history
Without this Python3 will raise a `TypeError` exception.
  • Loading branch information
sean797 committed Apr 19, 2018
1 parent aca8d5c commit d7f6586
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tracer/resources/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@

class Collection(list):

def replace_values(self, attribute, source_value, required_value):
for app in self:
if getattr(app, attribute) == source_value:
app.update(attribute, required_value)


def sorted(self, attribute):
self.replace_values(attribute, None, "")
try:
return sorted(self, key=methodcaller(attribute))
except TypeError:
Expand Down

0 comments on commit d7f6586

Please sign in to comment.