Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a286734

Browse files
committed
Couple of patches for Travis
1 parent 7ddb8f7 commit a286734

4 files changed

Lines changed: 33 additions & 13 deletions

File tree

lib/core/common.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,8 +2265,8 @@ def average(values):
22652265
"""
22662266
Computes the arithmetic mean of a list of numbers.
22672267
2268-
>>> round(average([0.9, 0.9, 0.9, 1.0, 0.8, 0.9]), 1)
2269-
0.9
2268+
>>> "%.1f" % average([0.9, 0.9, 0.9, 1.0, 0.8, 0.9])
2269+
'0.9'
22702270
"""
22712271

22722272
return (1.0 * sum(values) / len(values)) if values else None
@@ -2278,8 +2278,8 @@ def stdev(values):
22782278
22792279
# Reference: http://www.goldb.org/corestats.html
22802280
2281-
>>> round(stdev([0.9, 0.9, 0.9, 1.0, 0.8, 0.9]), 3)
2282-
0.063
2281+
>>> "%.3f" % stdev([0.9, 0.9, 0.9, 1.0, 0.8, 0.9])
2282+
'0.063'
22832283
"""
22842284

22852285
if not values or len(values) < 2:
@@ -4701,10 +4701,7 @@ def prioritySortColumns(columns):
47014701
def _(column):
47024702
return column and "id" in column.lower()
47034703

4704-
if six.PY2:
4705-
return sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)
4706-
else:
4707-
return sorted(sorted(columns, key=len), key=functools.cmp_to_key(lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0))
4704+
return sorted(sorted(columns, key=len), key=functools.cmp_to_key(lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0))
47084705

47094706
def getRequestHeader(request, name):
47104707
"""

lib/core/compat.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
import binascii
9+
import functools
910
import math
1011
import os
1112
import random
@@ -201,6 +202,31 @@ def round(x, d=0):
201202
else:
202203
return float(math.ceil((x * p) - 0.5))/p
203204

205+
def cmp_to_key(mycmp):
206+
"""Convert a cmp= function into a key= function"""
207+
class K(object):
208+
__slots__ = ['obj']
209+
def __init__(self, obj, *args):
210+
self.obj = obj
211+
def __lt__(self, other):
212+
return mycmp(self.obj, other.obj) < 0
213+
def __gt__(self, other):
214+
return mycmp(self.obj, other.obj) > 0
215+
def __eq__(self, other):
216+
return mycmp(self.obj, other.obj) == 0
217+
def __le__(self, other):
218+
return mycmp(self.obj, other.obj) <= 0
219+
def __ge__(self, other):
220+
return mycmp(self.obj, other.obj) >= 0
221+
def __ne__(self, other):
222+
return mycmp(self.obj, other.obj) != 0
223+
def __hash__(self):
224+
raise TypeError('hash not implemented')
225+
return K
226+
227+
# Note: patch for Python 2.6
228+
if not hasattr(functools, "cmp_to_key"):
229+
functools.cmp_to_key = cmp_to_key
204230

205231
if sys.version_info >= (3, 0):
206232
xrange = range

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty import six
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.5.68"
21+
VERSION = "1.3.5.69"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/utils/purge.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ def purge(directory):
6868
except:
6969
pass
7070

71-
if six.PY2:
72-
dirpaths.sort(cmp=lambda x, y: y.count(os.path.sep) - x.count(os.path.sep))
73-
else:
74-
dirpaths.sort(key=functools.cmp_to_key(lambda x, y: y.count(os.path.sep) - x.count(os.path.sep)))
71+
dirpaths.sort(key=functools.cmp_to_key(lambda x, y: y.count(os.path.sep) - x.count(os.path.sep)))
7572

7673
logger.debug("renaming directory names to random values")
7774
for dirpath in dirpaths:

0 commit comments

Comments
 (0)