update regarding Feature #61

This commit is contained in:
Miroslav Stampar 2010-09-24 13:34:46 +00:00
parent abe1289016
commit b6ff03690f

View File

@ -251,6 +251,9 @@ class Dump:
self.__write("+%s+\n" % lines1) self.__write("+%s+\n" % lines1)
def dbTableValues(self, tableValues): def dbTableValues(self, tableValues):
replication = None
rtable = None
if tableValues is None: if tableValues is None:
return return
@ -259,7 +262,9 @@ class Dump:
db = "All" db = "All"
table = tableValues["__infos__"]["table"] table = tableValues["__infos__"]["table"]
if not conf.multipleTargets: if conf.replicate:
replication = Replication("%s%s%s.sqlite" % (conf.dumpPath, os.sep, db))
elif not conf.multipleTargets:
dumpDbPath = "%s%s%s" % (conf.dumpPath, os.sep, db) dumpDbPath = "%s%s%s" % (conf.dumpPath, os.sep, db)
if not os.path.isdir(dumpDbPath): if not os.path.isdir(dumpDbPath):
@ -272,8 +277,6 @@ class Dump:
separator = str() separator = str()
field = 1 field = 1
fields = len(tableValues) - 1 fields = len(tableValues) - 1
replication = None
rtable = None
columns = tableValues.keys() columns = tableValues.keys()
columns.sort(key=lambda x: x.lower()) columns.sort(key=lambda x: x.lower())
@ -289,7 +292,6 @@ class Dump:
if conf.replicate: if conf.replicate:
replication = Replication("%s%s%s.sqlite" % (conf.outputPath, os.sep, db))
cols = list(columns) cols = list(columns)
if "__infos__" in cols: if "__infos__" in cols:
cols.remove("__infos__") cols.remove("__infos__")
@ -310,16 +312,17 @@ class Dump:
self.__write("| %s%s" % (column, blank), n=False) self.__write("| %s%s" % (column, blank), n=False)
if not conf.multipleTargets and field == fields: if not conf.replicate:
dataToDumpFile(dumpFP, "%s" % column) if not conf.multipleTargets and field == fields:
elif not conf.multipleTargets: dataToDumpFile(dumpFP, "%s" % column)
dataToDumpFile(dumpFP, "%s," % column) elif not conf.multipleTargets:
dataToDumpFile(dumpFP, "%s," % column)
field += 1 field += 1
self.__write("|\n%s" % separator) self.__write("|\n%s" % separator)
if not conf.multipleTargets: if not conf.multipleTargets and not conf.replicate:
dataToDumpFile(dumpFP, "\n") dataToDumpFile(dumpFP, "\n")
for i in range(count): for i in range(count):
@ -340,10 +343,11 @@ class Dump:
blank = " " * (maxlength - len(value)) blank = " " * (maxlength - len(value))
self.__write("| %s%s" % (value, blank), n=False) self.__write("| %s%s" % (value, blank), n=False)
if not conf.multipleTargets and field == fields: if not conf.replicate:
dataToDumpFile(dumpFP, "\"%s\"" % value) if not conf.multipleTargets and field == fields:
elif not conf.multipleTargets: dataToDumpFile(dumpFP, "\"%s\"" % value)
dataToDumpFile(dumpFP, "\"%s\"," % value) elif not conf.multipleTargets:
dataToDumpFile(dumpFP, "\"%s\"," % value)
field += 1 field += 1
@ -352,20 +356,19 @@ class Dump:
self.__write("|") self.__write("|")
if not conf.multipleTargets: if not conf.multipleTargets and not conf.replicate:
dataToDumpFile(dumpFP, "\n") dataToDumpFile(dumpFP, "\n")
self.__write("%s\n" % separator) self.__write("%s\n" % separator)
if not conf.multipleTargets: if conf.replicate:
logger.info("Table '%s.%s' dumped to sqlite3 file '%s'" % (db, table, replication.dbpath))
elif not conf.multipleTargets:
dataToDumpFile(dumpFP, "\n") dataToDumpFile(dumpFP, "\n")
dumpFP.close() dumpFP.close()
logger.info("Table '%s.%s' dumped to CSV file '%s'" % (db, table, dumpFileName)) logger.info("Table '%s.%s' dumped to CSV file '%s'" % (db, table, dumpFileName))
if conf.replicate:
logger.info("Table '%s.%s' dumped to sqlite3 file '%s'" % (db, table, replication.dbpath))
def dbColumns(self, dbColumns, colConsider, dbs): def dbColumns(self, dbColumns, colConsider, dbs):
for column in dbColumns.keys(): for column in dbColumns.keys():
if colConsider == "1": if colConsider == "1":