Just to be clear, I think forward slash is / while backward slash is \.

-Brian

On 06/12/2014 06:22 AM, [email protected] wrote:
From: José Fonseca <[email protected]>

It's fine for URLs to have forward slash directory separators when viewing
the HTML on Windows.  But if one moves the HTML report to a Linux machine
or puts it on a web-server and accesses it from a Linux machine then URLs
with forward slashes become dead.

This change prevents this be replacing \ with /.

"by"



(There might be an easier way to achieve this than to have so many
instances of foo.replace('\\', '/').  For example, it might be easier to
do this replacement when loading the results.  On the other hand,
there are several places that use os.path, so it might not solve the
issue completely neither.)
---
  framework/summary.py | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/framework/summary.py b/framework/summary.py
index 7e8d480..e5eb156 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -22,6 +22,7 @@
  from __future__ import print_function
  import os
  import os.path as path
+import posixpath
  import itertools
  import shutil
  import collections
@@ -46,6 +47,11 @@ def escape_filename(key):
      return re.sub(r'[<>:"|?*]', '_', key)


+def normalize_href(href):
+    """Force backward slashes in URLs."""
+    return href.replace('\\', '/')
+
+
  class HTMLIndex(list):
      """
      Builds HTML output to be passed to the index mako template, which will be
@@ -107,12 +113,13 @@ class HTMLIndex(list):
          self._newRow()
          self.append({'type': 'other', 'text': '<td />'})
          for each in summary.results:
+            href = posixpath.join(each.name, "index.html")
+            href = normalize_href(href)
              self.append({'type': 'other',
                           'text': '<td class="head"><b>%(name)s</b><br />'
                                   '(<a href="%(href)s">info</a>)'
                                   '</td>' % {'name': each.name,
-                                            'href': path.join(each.name,
-                                                              "index.html")}})
+                                            'href': href}})
          self._endRow()

          # Add the toplevel 'all' group
@@ -247,7 +254,8 @@ class HTMLIndex(list):
              href = None
          else:
              css = text
-            href = path.join(group, href + ".html")
+            href = posixpath.join(group, href + ".html")
+            href = normalize_href(href)

          self.append({'type': 'testResult',
                       'class': css,


_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to