Skip to content

Commit

Permalink
Remove invalid local-table entries and graphc preview links
Browse files Browse the repository at this point in the history
Charts saved from OpenOffice contain a copy of the data tables used to
generate them as well as a reference to the original sheet data.  Remove
these local-data tables because they're no longer valid after we replace
with new test results.

Also blow away links to the cached chart images as we've removed them
(again because they're no longer valid after we change sheet data).
  • Loading branch information
earlephilhower committed Aug 25, 2016
1 parent ad758e0 commit f847029
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ezfio.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -961,12 +961,20 @@ VNEBUEsFBgAAAAABAAEAWgAAAFQAAAAAAA==
$wr = New-Object System.IO.StreamWriter( $newentry.Open() )
$wr.Write( $xmltext )
$wr.Close()
} elseif ($entry.FullName -like "Object */content.xml") {
# Remove <table:table table:name="local-table"> table
$rd = New-Object System.IO.StreamReader( $entry.Open() )
$rdbytes = $rd.ReadToEnd()
$wr = New-Object System.IO.StreamWriter( $newentry.Open() )
$wrbytes = $rdbytes -replace "<table:table table:name=`"local-table`">.*</table:table>", ""
$wr.write( $wrbytes )
$wr.Close()
$rd.Close()
} elseif ($entry.FullName -eq "META-INF/manifest.xml") {
# Remove ObjectReplacements from the list
$rd = New-Object System.IO.StreamReader( $entry.Open() )
$wr = New-Object System.IO.StreamWriter( $newentry.Open() )
$rdbytes = $rd.ReadToEnd()
$rd.close()
$lines = $rdbytes.Split("`n")
foreach ($line in $lines) {
if ( -not ( ($line -contains "ObjectReplacement") -or ($line -contains "Thumbnails") ) ) {
Expand All @@ -975,6 +983,7 @@ VNEBUEsFBgAAAAABAAEAWgAAAFQAAAAAAA==
}
}
$wr.Close();
$rd.Close()
} else {
# Copying data for from the source ZIP
$wr = New-Object System.IO.StreamWriter( $newentry.Open() )
Expand All @@ -994,6 +1003,8 @@ VNEBUEsFBgAAAAABAAEAWgAAAFQAAAAAAA==
[string]$xmlsrc = GetContentXMLFromODS $global:odssrc
$xmlsrc = ReplaceSheetWithCSV_regex Timeseries $global:timeseriescsv $xmlsrc
$xmlsrc = ReplaceSheetWithCSV_regex Tests $global:testcsv $xmlsrc
# Remove draw:image references to deleted binary previews
$xmlsrc = $xmlsrc -replace "<draw:image.*?/>",""
$xmlsrc = $xmlsrc -replace "_DRIVE",$global:physDrive -replace "_TESTCAP",$global:testcapacity -replace "_MODEL",$global:model -replace "_SERIAL",$global:serial -replace "_OS",$global:os -replace "_FIO",$global:fioVerString
UpdateContentXMLToODS_text $global:odssrc $global:odsdest $xmlsrc
}
Expand Down
7 changes: 7 additions & 0 deletions ezfio.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,11 @@ def UpdateContentXMLToODS_text( odssrc, odsdest, xmltext ):
continue
elif entry == "content.xml":
zadst.writestr( "content.xml", xmltext)
elif ("Object" in entry) and ("content.xml" in entry):
# Remove <table:table table:name="local-table"> table
rdbytes = zasrc.read(entry)
outbytes = re.sub('<table:table table:name="local-table">.*</table:table>', "", rdbytes)
zadst.writestr(entry, outbytes)
elif entry == "META-INF/manifest.xml":
# Remove ObjectReplacements from the list
rdbytes = zasrc.read(entry)
Expand All @@ -830,6 +835,8 @@ def UpdateContentXMLToODS_text( odssrc, odsdest, xmltext ):
xmlsrc = GetContentXMLFromODS( odssrc )
xmlsrc = ReplaceSheetWithCSV_regex( "Timeseries", timeseriescsv, xmlsrc )
xmlsrc = ReplaceSheetWithCSV_regex( "Tests", testcsv, xmlsrc )
# Remove draw:image references to deleted binary previews
xmlsrc = re.sub("<draw:image.*?/>", "", xmlsrc)
# OpenOffice doesn't recalculate these cells on load?!
xmlsrc = xmlsrc.replace( "_DRIVE", str(physDrive) )
xmlsrc = xmlsrc.replace( "_TESTCAP", str(testcapacity) )
Expand Down

0 comments on commit f847029

Please sign in to comment.