[Piglit] [PATCH 2/2] summary/html: Fix processing of Windows results.
Dylan Baker
baker.dylan.c at gmail.com
Thu Jun 5 13:37:37 PDT 2014
On Thursday, June 05, 2014 03:29:51 PM Ilia Mirkin wrote:
> On Thu, Jun 5, 2014 at 3:20 PM, <jfonseca at vmware.com> wrote:
> > From: José Fonseca <jfonseca at vmware.com>
> >
> > - Prevent the use of reserved characters in filenames (e.g., '>' and '<'
> >
> > which are used in several cases.)
> >
> > - Handle mixture of backward and forward slashes gracefuly.
> > ---
> >
> > framework/summary.py | 19 +++++++++++++++----
> > 1 file changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/framework/summary.py b/framework/summary.py
> > index d71fb53..9cb5646 100644
> > --- a/framework/summary.py
> > +++ b/framework/summary.py
> > @@ -40,6 +40,15 @@ __all__ = [
> >
> > ]
> >
> > +def escapeFilename(key):
> I believe the convention is lower_underscore, not lowerCamelCase.
> (Although a few of the methods in HTMLIndex seem to disagree...)
Please just go on pretending HTMLIndex doesn't exist :), please use
lower_underscore for variable names.
>
> > + """
> > + Avoid reserved characters in filenames.
> > + """
One line docstrings don't get new lines:
""" Avoid reserved characters in filenames """
> > + for c in '<>:"|?*':
> > + key = key.replace(c, '_')
> > + return key
>
> import re
>
> return re.sub(r'[<>:"|?*]', '_', key)
+1 for this solution
>
> > +
> > +
> >
> > class HTMLIndex(list):
> > """
> > Builds HTML output to be passed to the index mako template, which
> > will be
> >
> > @@ -122,7 +131,7 @@ class HTMLIndex(list):
> > # Split the group names and test names, then determine
> > # which groups to close and which to open
> >
> > - openList = key.split('/')
> > + openList = key.replace('\\', '/').split('/')
> >
> > test = openList.pop()
> > openList, closeList = returnList(openList, list(currentDir))
> >
> > @@ -172,6 +181,8 @@ class HTMLIndex(list):
> > except KeyError:
> > href = key
> >
> > + href = escapeFilename(href)
> > +
> >
> > try:
> > self._testResult(each.name, href,
> >
> > summary.status[each.name][key])
> >
> > @@ -454,7 +465,8 @@ class Summary:
> > # Then build the individual test results
> >
> > for key, value in each.tests.iteritems():
> > - temp_path = path.join(destination, each.name,
> > path.dirname(key)) + html_path = path.join(destination,
> > each.name, escapeFilename(key + ".html")) + temp_path =
> > path.dirname(html_path)
> >
> > if value['result'] not in exclude:
> > # os.makedirs is very annoying, it throws an OSError
> > if
> >
> > @@ -469,8 +481,7 @@ class Summary:
> > if value.get('time') is not None:
> > value['time'] = datetime.timedelta(0,
> > value['time'])
> >
> > - with open(path.join(destination, each.name, key +
> > ".html"), - 'w') as out:
>
> > + with open(path.join(html_path), 'w') as out:
> Does path.join do anything useful here?
>
> > out.write(testfile.render(
> >
> > testname=key,
> > value=value,
> >
> > --
> > 1.9.1
> >
> > _______________________________________________
> > Piglit mailing list
> > Piglit at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/piglit
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140605/30da9320/attachment.sig>
More information about the Piglit
mailing list