@@ -530,6 +530,17 @@ def dbTableValues(self, tableValues):
530530 else :
531531 count += 1
532532
533+ # Note: appending to HTML means adding rows to the existing table (i.e. not appending a whole new document)
534+ if appendToFile and conf .dumpFormat == DUMP_FORMAT .HTML :
535+ with openFile (dumpFileName , "r" ) as f :
536+ content = f .read ()
537+
538+ if "</tbody>" in content :
539+ with openFile (dumpFileName , "w+" ) as f :
540+ f .write (content [:content .rindex ("</tbody>" )])
541+ else :
542+ appendToFile = False
543+
533544 self ._dumpFiles [dumpFileName ] = table
534545 dumpFP = openFile (dumpFileName , 'w' if not appendToFile else 'a' , buffering = DUMP_FILE_BUFFER_SIZE )
535546
@@ -603,7 +614,7 @@ def dbTableValues(self, tableValues):
603614 cols .append ((unsafeSQLIdentificatorNaming (column ), colType if colType else Replication .TEXT ))
604615
605616 rtable = replication .createTable (table , cols )
606- elif conf .dumpFormat == DUMP_FORMAT .HTML :
617+ elif conf .dumpFormat == DUMP_FORMAT .HTML and not appendToFile :
607618 dataToDumpFile (dumpFP , "<!DOCTYPE html>\n <html>\n <head>\n " )
608619 dataToDumpFile (dumpFP , "<meta http-equiv=\" Content-type\" content=\" text/html;charset=%s\" >\n " % UNICODE_ENCODING )
609620 dataToDumpFile (dumpFP , "<meta name=\" generator\" content=\" %s\" />\n " % VERSION_STRING )
@@ -639,7 +650,7 @@ def dbTableValues(self, tableValues):
639650
640651 field += 1
641652
642- if conf .dumpFormat == DUMP_FORMAT .HTML :
653+ if conf .dumpFormat == DUMP_FORMAT .HTML and not appendToFile :
643654 dataToDumpFile (dumpFP , "\n </tr>\n </thead>\n <tbody>\n " )
644655
645656 self ._write ("|\n %s" % separator )
0 commit comments