]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python3: reuse cmp_fn defined in compat.py
authorJoe Guo <joeg@catalyst.net.nz>
Mon, 30 Jul 2018 02:13:14 +0000 (14:13 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 17 Aug 2018 00:58:26 +0000 (02:58 +0200)
This will also fix PEP8 E306:

    expected 1 blank line before a nested definition, found 0

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/upgradehelpers.py

index 5e5655d74a2b4d36d1ac26c7ed2ccd0cbed29814..7c0dbac2d56e85fa33f14805ad5f57c45108a6ad 100644 (file)
@@ -28,6 +28,7 @@ import re
 import shutil
 import samba
 
+from samba.compat import cmp_fn
 from samba import Ldb, version, ntacls
 from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE
 import ldb
@@ -283,9 +284,8 @@ def dn_sort(x, y):
     len1 = len(tab1)-1
     len2 = len(tab2)-1
     # Note: python range go up to upper limit but do not include it
-    cmp = lambda x, y:  (x > y) - (x < y)  # cmp is removed in py3
     for i in range(0, minimum):
-        ret = cmp(tab1[len1-i], tab2[len2-i])
+        ret = cmp_fn(tab1[len1-i], tab2[len2-i])
         if ret != 0:
             return ret
         else: