If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Ability to define multiple patterns in Files contexts

NEW
Unassigned

Status

()

Core
Build Config
3 years ago
3 years ago

People

(Reporter: gps, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
Currently, Files contexts accept a single pattern as their argument. There are places where we want to cherry-pick individual files. I think it makes sense to support passing multiple files to Files.__init__.
So, one thing that I was thinking would be useful for templates is some magic around the syntax:

with Template(...), Template(...):
    stuff

such that two sub contexts are emitted, and stuff is applied to both. This would involve a proxy context that dispatches to both sub contexts.

The problem is that it's hard to distinguish that form and:

with Template(...):
    with Template(...):
        stuff

Maybe looking at frame data?
(Reporter)

Comment 2

3 years ago
I'd rather not depart too far from the Python language because it breaks understanding.

For this feature, I was thinking of using either *args or detecting an iterable as the argument and emitting multiple Files instances (rather than a single Files that has multiple patterns).

If you want to have a go at using the multiple context manager syntax and magic, I won't stop you. But I have a feeling people will want this feature soonish, which is why I'm inclined to go the easy route.
Immediate options:

with Files('{a,b}'):
with Files('a', 'b'):
with Files('a'), Files('b'):

I prefer the middle one. It still allows future extension possibilities:

with Files('a/**', 'b/**', exclude='*.js'):
You need to log in before you can comment on or make changes to this bug.