On 10/01/2015 12:12 AM, Markus Armbruster wrote: >> >>> We can always add an indirection: instead of parameterizing a fixed >>> predicate (ignore and isinstance(entity, ignore)) with a type ignore, we >>> could pass a predicate, i.e. a function mapping entity to bool. >> >> Like this? Generates the same code before and after the >> patch. I'm open to suggestions on any way to make it more >> idiomatic python, althouth it at least passed pep8. In >> particular, I'm wondering if the predicate should have its >> sense reversed (pass False to skip, True to visit). >> >> I'll probably drop the 'assert info' lines in the two >> visit_object_type() calls (I put it there to make sure the >> predicate was working). > > Yes, please.
Returning True to visit and False to skip was easier to rationalize about, so I've made that change in my local tree. > > I think this turned out rather nicely. > > Can we go one step further? Unconditionally call visitor.visit_filter() > here, define the pass-everything filter in QAPISchemaVisitor, override > it as needed. > > Name it visit_filter_out() to make the sense of the return value > obvious? Oh, nice idea. Then we don't even have to return it during visit_begin() - we just blindly call it. Will work that into my local tree, and it will be ready when I post (the next subset) of v6. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature