mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-25 19:13:48 +03:00
Couple of patches for Travis
This commit is contained in:
parent
7ddb8f7cbe
commit
a286734c57
|
@ -2265,8 +2265,8 @@ def average(values):
|
|||
"""
|
||||
Computes the arithmetic mean of a list of numbers.
|
||||
|
||||
>>> round(average([0.9, 0.9, 0.9, 1.0, 0.8, 0.9]), 1)
|
||||
0.9
|
||||
>>> "%.1f" % average([0.9, 0.9, 0.9, 1.0, 0.8, 0.9])
|
||||
'0.9'
|
||||
"""
|
||||
|
||||
return (1.0 * sum(values) / len(values)) if values else None
|
||||
|
@ -2278,8 +2278,8 @@ def stdev(values):
|
|||
|
||||
# Reference: http://www.goldb.org/corestats.html
|
||||
|
||||
>>> round(stdev([0.9, 0.9, 0.9, 1.0, 0.8, 0.9]), 3)
|
||||
0.063
|
||||
>>> "%.3f" % stdev([0.9, 0.9, 0.9, 1.0, 0.8, 0.9])
|
||||
'0.063'
|
||||
"""
|
||||
|
||||
if not values or len(values) < 2:
|
||||
|
@ -4701,9 +4701,6 @@ def prioritySortColumns(columns):
|
|||
def _(column):
|
||||
return column and "id" in column.lower()
|
||||
|
||||
if six.PY2:
|
||||
return sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)
|
||||
else:
|
||||
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))
|
||||
|
||||
def getRequestHeader(request, name):
|
||||
|
|
|
@ -6,6 +6,7 @@ See the file 'LICENSE' for copying permission
|
|||
"""
|
||||
|
||||
import binascii
|
||||
import functools
|
||||
import math
|
||||
import os
|
||||
import random
|
||||
|
@ -201,6 +202,31 @@ def round(x, d=0):
|
|||
else:
|
||||
return float(math.ceil((x * p) - 0.5))/p
|
||||
|
||||
def cmp_to_key(mycmp):
|
||||
"""Convert a cmp= function into a key= function"""
|
||||
class K(object):
|
||||
__slots__ = ['obj']
|
||||
def __init__(self, obj, *args):
|
||||
self.obj = obj
|
||||
def __lt__(self, other):
|
||||
return mycmp(self.obj, other.obj) < 0
|
||||
def __gt__(self, other):
|
||||
return mycmp(self.obj, other.obj) > 0
|
||||
def __eq__(self, other):
|
||||
return mycmp(self.obj, other.obj) == 0
|
||||
def __le__(self, other):
|
||||
return mycmp(self.obj, other.obj) <= 0
|
||||
def __ge__(self, other):
|
||||
return mycmp(self.obj, other.obj) >= 0
|
||||
def __ne__(self, other):
|
||||
return mycmp(self.obj, other.obj) != 0
|
||||
def __hash__(self):
|
||||
raise TypeError('hash not implemented')
|
||||
return K
|
||||
|
||||
# Note: patch for Python 2.6
|
||||
if not hasattr(functools, "cmp_to_key"):
|
||||
functools.cmp_to_key = cmp_to_key
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
xrange = range
|
||||
|
|
|
@ -18,7 +18,7 @@ from lib.core.enums import OS
|
|||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.3.5.68"
|
||||
VERSION = "1.3.5.69"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
|
|
@ -68,9 +68,6 @@ def purge(directory):
|
|||
except:
|
||||
pass
|
||||
|
||||
if six.PY2:
|
||||
dirpaths.sort(cmp=lambda x, y: y.count(os.path.sep) - x.count(os.path.sep))
|
||||
else:
|
||||
dirpaths.sort(key=functools.cmp_to_key(lambda x, y: y.count(os.path.sep) - x.count(os.path.sep)))
|
||||
|
||||
logger.debug("renaming directory names to random values")
|
||||
|
|
Loading…
Reference in New Issue
Block a user