From c5e43fca40af832cc5cb870aa3a1cdee3942dc2b Mon Sep 17 00:00:00 2001
From: Samuel Gaist <samuel.gaist@idiap.ch>
Date: Fri, 17 Apr 2020 09:32:34 +0200
Subject: [PATCH] [common][utils] Move _cmp from ListCreateExperimentsView to
 py3_cmp

Some code still uses it in other parts so make it easier to re-use.
---
 beat/web/common/utils.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/beat/web/common/utils.py b/beat/web/common/utils.py
index 98ebfb76f..ffe47af7a 100644
--- a/beat/web/common/utils.py
+++ b/beat/web/common/utils.py
@@ -135,3 +135,13 @@ def ensure_string(data):
             return data.decode("utf-8")
         return data
     return ""
+
+
+def py3_cmp(a, b):
+    """
+    cmp is not available anymore in Python 3. This method is implemetend
+    as recommended in the documentation for this kind of use case.
+    Based on:
+      https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
+    """
+    return (a > b) - (a < b)
-- 
GitLab