More refactoring for an Issue #254

This commit is contained in:
Miroslav Stampar 2012-11-28 11:16:00 +01:00
parent 87a92ab330
commit 5bf5b95588

View File

@ -333,7 +333,7 @@ class Dump:
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
replication = Replication("%s%s%s.sqlite3" % (conf.dumpPath, os.sep, unsafeSQLIdentificatorNaming(db)))
else:
elif conf.dumpFormat == DUMP_FORMAT.CSV:
dumpDbPath = "%s%s%s" % (conf.dumpPath, os.sep, unsafeSQLIdentificatorNaming(db))
if not os.path.isdir(dumpDbPath):
@ -407,7 +407,7 @@ class Dump:
self._write("| %s%s" % (column, blank), newline=False)
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
if conf.dumpFormat == DUMP_FORMAT.CSV:
if field == fields:
dataToDumpFile(dumpFP, "%s" % safeCSValue(column))
else:
@ -417,10 +417,10 @@ class Dump:
self._write("|\n%s" % separator)
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
if conf.dumpFormat == DUMP_FORMAT.CSV:
dataToDumpFile(dumpFP, "\n")
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
elif conf.dumpFormat == DUMP_FORMAT.SQLITE:
rtable.beginTransaction()
if count > TRIM_STDOUT_DUMP_SIZE:
@ -452,7 +452,7 @@ class Dump:
blank = " " * (maxlength - len(value))
self._write("| %s%s" % (value, blank), newline=False, console=console)
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
if conf.dumpFormat == DUMP_FORMAT.CSV:
if field == fields:
dataToDumpFile(dumpFP, "%s" % safeCSValue(value))
else:
@ -465,19 +465,18 @@ class Dump:
rtable.insert(values)
except sqlmapValueException:
pass
elif conf.dumpFormat == DUMP_FORMAT.CSV:
dataToDumpFile(dumpFP, "\n")
self._write("|", console=console)
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
dataToDumpFile(dumpFP, "\n")
self._write("%s\n" % separator)
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
rtable.endTransaction()
logger.info("table '%s.%s' dumped to sqlite3 database '%s'" % (db, table, replication.dbpath))
else:
elif conf.dumpFormat == DUMP_FORMAT.CSV:
dataToDumpFile(dumpFP, "\n")
dumpFP.close()
logger.info("table '%s.%s' dumped to CSV file '%s'" % (db, table, dumpFileName))