Minor refactoring of some revisited code

This commit is contained in:
Miroslav Stampar 2015-12-29 14:32:13 +01:00
parent fc5802f461
commit dd8fcaeb43
2 changed files with 16 additions and 16 deletions

View File

@ -801,10 +801,10 @@ def cmdLineParser(argv=None):
# Dirty hack to display longer options without breaking into two lines # Dirty hack to display longer options without breaking into two lines
def _(self, *args): def _(self, *args):
_ = parser.formatter._format_option_strings(*args) retVal = parser.formatter._format_option_strings(*args)
if len(_) > MAX_HELP_OPTION_LENGTH: if len(retVal) > MAX_HELP_OPTION_LENGTH:
_ = ("%%.%ds.." % (MAX_HELP_OPTION_LENGTH - parser.formatter.indent_increment)) % _ retVal = ("%%.%ds.." % (MAX_HELP_OPTION_LENGTH - parser.formatter.indent_increment)) % retVal
return _ return retVal
parser.formatter._format_option_strings = parser.formatter.format_option_strings parser.formatter._format_option_strings = parser.formatter.format_option_strings
parser.formatter.format_option_strings = type(parser.formatter.format_option_strings)(_, parser, type(parser)) parser.formatter.format_option_strings = type(parser.formatter.format_option_strings)(_, parser, type(parser))

View File

@ -116,29 +116,29 @@ def pivotDumpTable(table, colList, count=None, blind=True):
pivotValue = " " pivotValue = " "
breakRetrieval = False breakRetrieval = False
def _(column, pivotValue):
if column == colList[0]:
query = dumpNode.query.replace("'%s'", "%s") % (agent.preprocessField(table, column), table, agent.preprocessField(table, column), unescaper.escape(pivotValue, False))
else:
query = dumpNode.query2.replace("'%s'", "%s") % (agent.preprocessField(table, column), table, agent.preprocessField(table, colList[0]), unescaper.escape(pivotValue, False))
query = whereQuery(query)
return unArrayizeValue(inject.getValue(query, blind=blind, time=blind, union=not blind, error=not blind))
try: try:
for i in xrange(count): for i in xrange(count):
if breakRetrieval: if breakRetrieval:
break break
for column in colList: for column in colList:
def _(pivotValue): value = _(column, pivotValue)
if column == colList[0]:
query = dumpNode.query.replace("'%s'", "%s") % (agent.preprocessField(table, column), table, agent.preprocessField(table, column), unescaper.escape(pivotValue, False))
else:
query = dumpNode.query2.replace("'%s'", "%s") % (agent.preprocessField(table, column), table, agent.preprocessField(table, colList[0]), unescaper.escape(pivotValue, False))
query = whereQuery(query)
return unArrayizeValue(inject.getValue(query, blind=blind, time=blind, union=not blind, error=not blind))
value = _(pivotValue)
if column == colList[0]: if column == colList[0]:
if isNoneValue(value): if isNoneValue(value):
for pivotValue in filter(None, (" " if pivotValue == " " else None, "%s%s" % (pivotValue[0], unichr(ord(pivotValue[1]) + 1)) if len(pivotValue) > 1 else None, unichr(ord(pivotValue[0]) + 1))): for pivotValue in filter(None, (" " if pivotValue == " " else None, "%s%s" % (pivotValue[0], unichr(ord(pivotValue[1]) + 1)) if len(pivotValue) > 1 else None, unichr(ord(pivotValue[0]) + 1))):
value = _(pivotValue) value = _(column, pivotValue)
if not isNoneValue(value): if not isNoneValue(value):
break break
if isNoneValue(value): if isNoneValue(value):
breakRetrieval = True breakRetrieval = True
break break