On Thursday, 9 February 2017 08:52:24 EET Dylan Baker wrote:
> Quoting Tomi Sarvela (2017-02-09 03:07:05)
> 
> > New helper function numericlistdir() arranges the os.listdir()
> > in numerical order and deduplicates the code: reading in is done
> > in two places, finalize and _resume.
> > 
> > Use OrderedDict when reading data in.
> > +def numericlistdir(path):
> This name isn't very descriptive. how about: numeric_sorted_listdir?
> > +        lambda x: (-1, x) if not re.match(r'^\d+', x)
> > +        else (int(re.findall(r'^\d+', x)[0]), x) )
> 
> This seems a little complex for what you're actually trying to do, I
> think this does the same thing (but in less code):
> lambda p: int(os.path.splitext(p)[0])
> 
> If that does work, for the two places it's used it's probably just
> easier to call sorted inline.

This is easier to read, and my generalized version doesn't give 
anything extra in this case. Going with the inline version.

> > -                        s.iterwrite(six.iteritems(json.load(n)))
> > +                        s.iterwrite(six.iteritems(json.load(n),
> > object_pairs_hook=OrderedDict))
> you've passed object_pairs_hook to the wrong function, it needs to
> be passed to json.load
> 
> this specifically causes piglit with jsonstreams to fail. You can
> test it using tox:
> tox -e 'py{27,36}-streams'

Right, fixed.

All of the other proposed changes are also improvements to my code. 
Sending patch v2 soon.
_______________________________________________
Piglit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to