Some code refactoring

This commit is contained in:
Miroslav Stampar
2017-04-18 15:48:05 +02:00
parent 65b02d4ab0
commit 5f2bb88037
32 changed files with 233 additions and 261 deletions

View File

@@ -422,9 +422,8 @@ class Entries:
def dumpFoundColumn(self, dbs, foundCols, colConsider):
message = "do you want to dump entries? [Y/n] "
output = readInput(message, default="Y")
if output and output[0] not in ("y", "Y"):
if not readInput(message, default='Y', boolean=True):
return
dumpFromDbs = []
@@ -435,14 +434,14 @@ class Entries:
message += "[%s]\n" % unsafeSQLIdentificatorNaming(db)
message += "[q]uit"
test = readInput(message, default="a")
choice = readInput(message, default='a')
if not test or test in ("a", "A"):
if not choice or choice in ('a', 'A'):
dumpFromDbs = dbs.keys()
elif test in ("q", "Q"):
elif choice in ('q', 'Q'):
return
else:
dumpFromDbs = test.replace(" ", "").split(",")
dumpFromDbs = choice.replace(" ", "").split(",")
for db, tblData in dbs.items():
if db not in dumpFromDbs or not tblData:
@@ -458,16 +457,16 @@ class Entries:
message += "[s]kip\n"
message += "[q]uit"
test = readInput(message, default="a")
choice = readInput(message, default='a')
if not test or test in ("a", "A"):
if not choice or choice in ('a', 'A'):
dumpFromTbls = tblData
elif test in ("s", "S"):
elif choice in ('s', 'S'):
continue
elif test in ("q", "Q"):
elif choice in ('q', 'Q'):
return
else:
dumpFromTbls = test.replace(" ", "").split(",")
dumpFromTbls = choice.replace(" ", "").split(",")
for table, columns in tblData.items():
if table not in dumpFromTbls:
@@ -479,7 +478,7 @@ class Entries:
if conf.excludeCol:
colList = [_ for _ in colList if _ not in conf.excludeCol.split(',')]
conf.col = ",".join(colList)
conf.col = ','.join(colList)
kb.data.cachedColumns = {}
kb.data.dumpedTable = {}
@@ -490,9 +489,8 @@ class Entries:
def dumpFoundTables(self, tables):
message = "do you want to dump tables' entries? [Y/n] "
output = readInput(message, default="Y")
if output and output[0].lower() != "y":
if not readInput(message, default='Y', boolean=True):
return
dumpFromDbs = []
@@ -503,14 +501,14 @@ class Entries:
message += "[%s]\n" % unsafeSQLIdentificatorNaming(db)
message += "[q]uit"
test = readInput(message, default="a")
choice = readInput(message, default='a')
if not test or test.lower() == "a":
if not choice or choice.lower() == 'a':
dumpFromDbs = tables.keys()
elif test.lower() == "q":
elif choice.lower() == 'q':
return
else:
dumpFromDbs = test.replace(" ", "").split(",")
dumpFromDbs = choice.replace(" ", "").split(',')
for db, tablesList in tables.items():
if db not in dumpFromDbs or not tablesList:
@@ -526,16 +524,16 @@ class Entries:
message += "[s]kip\n"
message += "[q]uit"
test = readInput(message, default="a")
choice = readInput(message, default='a')
if not test or test.lower() == "a":
if not choice or choice.lower() == 'a':
dumpFromTbls = tablesList
elif test.lower() == "s":
elif choice.lower() == 's':
continue
elif test.lower() == "q":
elif choice.lower() == 'q':
return
else:
dumpFromTbls = test.replace(" ", "").split(",")
dumpFromTbls = choice.replace(" ", "").split(',')
for table in dumpFromTbls:
conf.tbl = table