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 252952d4759c0f871f61ab760be1dd6dd61a1a99..3597ac11cd1d2310d1678f398320b8ee695410a7 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 |
@@ -17,7 +17,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' |
_FORMAT_NAME = lambda _, name: re.sub(r'[_\-]', ' ', name) |
@@ -49,7 +53,7 @@ class HtmlExport(object): |
html = ( |
'<html>' + |
self._build_header() + |
- '<body>' + |
+ '<body onload="initialize()">' + |
'<h1>Results from {}</h1>'.format(output_filepath) + |
self._NEW_LINE.join(tables) + |
'</body>' + |
@@ -65,19 +69,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) |