FlagConstant objects should be iterable
|Reported by:||Wilfredo Sánchez Vega||Owned by:||Wilfredo Sánchez Vega|
branch-diff, diff-cov, branch-cov, buildbot
I have a method that takes a FlagConstant argument, and I want to iterate through the flags to (a) flip the switches the flags should flip and (b) make sure there's no flag being sent that I don't know how to support.
For example, the caller starts by composing a FlagConstant from others:
flags = QueryFlags.NOT | QueryFlags.caseInsensitive
This is passed to my method. What I'd like to make work is:
for flag in flags: ... # I get (QueryFlags.NOT, QueryFlags.caseInsensitive)
The best I can do for now, appears to be:
for flag in (flags._container.lookupByName(name) for name in flags.names): ...
Note that I had to use the private
flags._container attribute above.
Change History (14)
comment:1 Changed 4 years ago by
|Summary:||FlagsConstant objects should be iterable → FlagConstant objects should be iterable|
comment:10 follow-up: 12 Changed 4 years ago by
|Owner:||set to Wilfredo Sánchez Vega|