mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-28 03:05:47 +03:00
Minor improvement of AttribDict logic
This commit is contained in:
parent
51b56820f7
commit
72fcb66fe8
|
|
@ -172,7 +172,7 @@ af24159b8ca5b8fe5e13cdfdedc2a758a2f4883361a601e0a550127cff368b3a lib/core/commo
|
||||||
a6397b10de7ae7c56ed6b0fa3b3c58eb7a9dbede61bf93d786e73258175c981e lib/core/compat.py
|
a6397b10de7ae7c56ed6b0fa3b3c58eb7a9dbede61bf93d786e73258175c981e lib/core/compat.py
|
||||||
a9997e97ebe88e0bf7efcf21e878bc5f62c72348e5aba18f64d6861390a4dcf2 lib/core/convert.py
|
a9997e97ebe88e0bf7efcf21e878bc5f62c72348e5aba18f64d6861390a4dcf2 lib/core/convert.py
|
||||||
c03dc585f89642cfd81b087ac2723e3e1bb3bfa8c60e6f5fe58ef3b0113ebfe6 lib/core/data.py
|
c03dc585f89642cfd81b087ac2723e3e1bb3bfa8c60e6f5fe58ef3b0113ebfe6 lib/core/data.py
|
||||||
e396b7971d38896e0e20b973a3a6a3fbc3171d080a21bc6e66a65bee452fd69c lib/core/datatype.py
|
ca06a0e9d66a58e74ef994d53f9b3cd2ebaed98735bbab99854054235a8083d6 lib/core/datatype.py
|
||||||
e18c0c2c5a57924a623792a48bfd36e98d9bc085f6db61a95fc0dc8a3bcedc0c lib/core/decorators.py
|
e18c0c2c5a57924a623792a48bfd36e98d9bc085f6db61a95fc0dc8a3bcedc0c lib/core/decorators.py
|
||||||
147823c37596bd6a56d677697781f34b8d1d1671d5a2518fbc9468d623c6d07d lib/core/defaults.py
|
147823c37596bd6a56d677697781f34b8d1d1671d5a2518fbc9468d623c6d07d lib/core/defaults.py
|
||||||
6b366f897e66b9df39df2ee45fef77d46efb7a2d4e294440d3aa7dc1b2f4cedf lib/core/dicts.py
|
6b366f897e66b9df39df2ee45fef77d46efb7a2d4e294440d3aa7dc1b2f4cedf lib/core/dicts.py
|
||||||
|
|
@ -189,7 +189,7 @@ a033f92d136c707a25927c2383125ddb004d4283db62c004dcd67c3fc242bb1c lib/core/dump.
|
||||||
48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py
|
48797d6c34dd9bb8a53f7f3794c85f4288d82a9a1d6be7fcf317d388cb20d4b3 lib/core/replication.py
|
||||||
0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py
|
0b8c38a01bb01f843d94a6c5f2075ee47520d0c4aa799cecea9c3e2c5a4a23a6 lib/core/revision.py
|
||||||
888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py
|
888daba83fd4a34e9503fe21f01fef4cc730e5cde871b1d40e15d4cbc847d56c lib/core/session.py
|
||||||
7f08f592c49c3534afc931a7fb9e1915ffa7425e66ada1d58e56e3383758440f lib/core/settings.py
|
d6577e20ed58d058dcde4341010e3ea26240cc959185ce9471eda0fab17a21cf lib/core/settings.py
|
||||||
cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py
|
cd5a66deee8963ba8e7e9af3dd36eb5e8127d4d68698811c29e789655f507f82 lib/core/shell.py
|
||||||
bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py
|
bcb5d8090d5e3e0ef2a586ba09ba80eef0c6d51feb0f611ed25299fbb254f725 lib/core/subprocessng.py
|
||||||
d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py
|
d35650179816193164a5f177102f18379dfbe6bb6d40fbb67b78d907b41c8038 lib/core/target.py
|
||||||
|
|
|
||||||
|
|
@ -20,21 +20,18 @@ class AttribDict(dict):
|
||||||
>>> foo.bar = 1
|
>>> foo.bar = 1
|
||||||
>>> foo.bar
|
>>> foo.bar
|
||||||
1
|
1
|
||||||
|
>>> import copy; copy.deepcopy(foo).bar
|
||||||
|
1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, indict=None, attribute=None, keycheck=True):
|
def __init__(self, indict=None, attribute=None, keycheck=True):
|
||||||
if indict is None:
|
if indict is None:
|
||||||
indict = {}
|
indict = {}
|
||||||
|
|
||||||
# Set any attributes here - before initialisation
|
|
||||||
# these remain as normal attributes
|
|
||||||
self.attribute = attribute
|
|
||||||
self.keycheck = keycheck
|
|
||||||
dict.__init__(self, indict)
|
dict.__init__(self, indict)
|
||||||
self.__initialised = True
|
self.__dict__["_attribute"] = attribute
|
||||||
|
self.__dict__["_keycheck"] = keycheck
|
||||||
# After initialisation, setting attributes
|
self.__dict__["_initialized"] = True
|
||||||
# is the same as setting an item
|
|
||||||
|
|
||||||
def __getattr__(self, item):
|
def __getattr__(self, item):
|
||||||
"""
|
"""
|
||||||
|
|
@ -45,7 +42,7 @@ class AttribDict(dict):
|
||||||
try:
|
try:
|
||||||
return self.__getitem__(item)
|
return self.__getitem__(item)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if self.keycheck:
|
if self.__dict__.get("_keycheck"):
|
||||||
raise AttributeError("unable to access item '%s'" % item)
|
raise AttributeError("unable to access item '%s'" % item)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
@ -58,7 +55,7 @@ class AttribDict(dict):
|
||||||
try:
|
try:
|
||||||
return self.pop(item)
|
return self.pop(item)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if self.keycheck:
|
if self.__dict__.get("_keycheck"):
|
||||||
raise AttributeError("unable to access item '%s'" % item)
|
raise AttributeError("unable to access item '%s'" % item)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
@ -69,14 +66,8 @@ class AttribDict(dict):
|
||||||
Only if we are initialised
|
Only if we are initialised
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This test allows attributes to be set in the __init__ method
|
if "_initialized" not in self.__dict__ or item in self.__dict__:
|
||||||
if "_AttribDict__initialised" not in self.__dict__:
|
self.__dict__[item] = value
|
||||||
return dict.__setattr__(self, item, value)
|
|
||||||
|
|
||||||
# Any normal attributes are handled normally
|
|
||||||
elif item in self.__dict__:
|
|
||||||
dict.__setattr__(self, item, value)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.__setitem__(item, value)
|
self.__setitem__(item, value)
|
||||||
|
|
||||||
|
|
@ -87,14 +78,12 @@ class AttribDict(dict):
|
||||||
self.__dict__ = dict
|
self.__dict__ = dict
|
||||||
|
|
||||||
def __deepcopy__(self, memo):
|
def __deepcopy__(self, memo):
|
||||||
retVal = self.__class__(keycheck=self.keycheck)
|
retVal = self.__class__(keycheck=self.__dict__.get("_keycheck"))
|
||||||
memo[id(self)] = retVal
|
memo[id(self)] = retVal
|
||||||
|
|
||||||
for attr in dir(self):
|
for attr, value in self.__dict__.items():
|
||||||
if not attr.startswith('_'):
|
if attr not in ('_attribute', '_keycheck', '_initialized'):
|
||||||
value = getattr(self, attr)
|
setattr(retVal, attr, copy.deepcopy(value, memo))
|
||||||
if not isinstance(value, (types.BuiltinFunctionType, types.FunctionType, types.MethodType)):
|
|
||||||
setattr(retVal, attr, copy.deepcopy(value, memo))
|
|
||||||
|
|
||||||
for key, value in self.items():
|
for key, value in self.items():
|
||||||
retVal.__setitem__(key, copy.deepcopy(value, memo))
|
retVal.__setitem__(key, copy.deepcopy(value, memo))
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ from lib.core.enums import OS
|
||||||
from thirdparty import six
|
from thirdparty import six
|
||||||
|
|
||||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||||
VERSION = "1.10.1.59"
|
VERSION = "1.10.1.60"
|
||||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
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)
|
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user