Use decoded content-type
authorThierry Florac <thierry.florac@onf.fr>
Wed, 20 Sep 2017 14:05:34 +0200
changeset 55 3bff9e2b8533
parent 54 9ebc186dc5ff
child 56 44f79a6a9033
Use decoded content-type
src/pyams_media/media.py
--- a/src/pyams_media/media.py	Wed Sep 20 14:04:57 2017 +0200
+++ b/src/pyams_media/media.py	Wed Sep 20 14:05:34 2017 +0200
@@ -103,7 +103,7 @@
             result.append(self.__parent__)
         result.extend(list(self.values()))
         if order:
-            order = tuple(map(lambda x: x.encode(), order))
+            order = tuple(map(lambda x: x.decode() if isinstance(x, bytes) else x, order))
             result.sort(key=lambda x: (order.index(x.content_type) if x.content_type in order else 999,
                                        self.get_conversion_width(x.filename) or 9999))
         return result