human
I wrote the below code

    def _execute(pkg):
        constraint = (pkg.name if (when is None) else when)
        when_spec = parse_anonymous_spec(constraint, pkg.name)
        cur_patches = pkg.patches.setdefault(when_spec, [])
        cur_patches.append(Patch.create(pkg, url_or_filename, level, **kwargs))
    return _execute

What's a good function header?
assistant
#Here's a good function header.

@directive('patches')
def patch(url_or_filename, level=1, when=None, **kwargs):