From c583cbf9b25a8747b7eb2317c970acaecb9484f3 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Wed, 18 Jul 2018 16:33:41 -0400 Subject: [PATCH] Python3: Don't use cmp() function The built-in cmp() function has been removed in Python 3, so don't try to use it. Change-Id: Ic62b7032ec6fd555974fc0d818327879d53a8ff2 --- heat_cfntools/cfntools/cfn_helper.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/heat_cfntools/cfntools/cfn_helper.py b/heat_cfntools/cfntools/cfn_helper.py index f2b9f90..e68d8fe 100644 --- a/heat_cfntools/cfntools/cfn_helper.py +++ b/heat_cfntools/cfntools/cfn_helper.py @@ -457,13 +457,17 @@ class PackagesHandler(object): p1_name = pkg1[0] p2_name = pkg2[0] if p1_name in order and p2_name in order: - return cmp(order.index(p1_name), order.index(p2_name)) + i1 = order.index(p1_name) + i2 = order.index(p2_name) + return (i1 > i2) - (i1 < i2) elif p1_name in order: return -1 elif p2_name in order: return 1 else: - return cmp(p1_name.lower(), p2_name.lower()) + n1 = p1_name.lower() + n2 = p2_name.lower() + return (n1 > n2) - (n1 < n2) def __init__(self, packages): self._packages = packages