[rfc] UIFactory.is_interactive()
Martin Pool
mbp at canonical.com
Tue Nov 24 22:48:46 GMT 2009
2009/11/25 Gordon Tyler <gordon at doxxx.net>:
> Andrew Bennetts wrote:
>>>
>>> This somewhat violates "don't look before you leap" but it's probably
>>> worthwhile to avoid thinking about interactive stuff before you do it.
>>
>> Maybe a less LBYL solution would be:
>>
>> if not ui_factory.get_boolean("really delete everything?",
>> default=True):
>> return
>> delete_everything()
>>
>> Although perhaps “default choice” is not precisely the same concept as
>> “choice
>> to take when non-interactive”, it's probably close enough.
Another option is to make them all raise some exception indicating
that no user interaction is possible.
get_boolean was perhaps not a good example to use because it's likely
in all those cases that you can just assume 'yes' or 'no' as the case
may be. For something like asking for a password or username, you
actually want it to take a totally different path. (But this could
still potentially be accomodated by returning None.)
Anyhow I think I convinced myself it's worth at least adding the patch.
--
Martin <http://launchpad.net/~mbp/>
More information about the bazaar
mailing list