Index: webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py |
diff --git a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py |
index 4b025023a3859d7ddafa38c864cf00653597f575..a0cb41148de31f0c2c87cce35acf1dabc80edf74 100644 |
--- a/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py |
+++ b/webrtc/modules/audio_processing/test/py_quality_assessment/quality_assessment/export.py |
@@ -18,7 +18,11 @@ class HtmlExport(object): |
# CSS file parameters. |
_CSS_FILEPATH = os.path.join(_PATH, 'results.css') |
- _INLINE_CSS = True |
+ _INLINE_CSS = False |
+ |
+ # JS file parameters. |
+ _JS_FILEPATH = os.path.join(_PATH, 'results.js') |
+ _INLINE_JS = False |
_NEW_LINE = '\n' |
@@ -43,7 +47,7 @@ class HtmlExport(object): |
html = ( |
'<html>' + |
self._build_header() + |
- '<body>' + |
+ '<body onload="initialize()">' + |
'<h1>Results from {}</h1>'.format(self._output_filepath) + |
self._NEW_LINE.join(tables) + |
'</body>' + |
@@ -58,19 +62,34 @@ class HtmlExport(object): |
""" |
html = ['<head>', '<title>Results</title>'] |
+ # Function to append the lines of a text file to html. |
+ def _embed_file(filepath): |
+ with open(filepath) as f: |
+ for l in f: |
+ html.append(l.strip()) |
+ |
# CSS. |
if self._INLINE_CSS: |
# Embed. |
html.append('<style>') |
- with open(self._CSS_FILEPATH) as f: |
- for l in f: |
- html.append(l.strip()) |
+ _embed_file(self._CSS_FILEPATH) |
html.append('</style>') |
else: |
# Link. |
html.append('<link rel="stylesheet" type="text/css" ' |
'href="file://{}?">'.format(self._CSS_FILEPATH)) |
+ # Javascript. |
+ if self._INLINE_JS: |
+ # Embed. |
+ html.append('<script>') |
+ _embed_file(self._JS_FILEPATH) |
+ html.append('</script>') |
+ else: |
+ # Link. |
+ html.append('<script src="file://{}?"></script>'.format( |
+ self._JS_FILEPATH)) |
+ |
html.append('</head>') |
return self._NEW_LINE.join(html) |