Now that I've freed myself from Pythons older than 3.6, I can use
f-strings for very clear and concise string formatting! That's now how
it's done everywhere except one place in the shell plugin where
str.format is really the right thing to do.
This one got a lot more verbose, but I like it more too. The caching
and formatting methods were moved to a base Handler class, and
individual commands subclass this using its methods as needed. The
"hoos your weather provider" command doesn't even update the cache
anymore, which is nice.
This gives the darksky plugin a temp_precision option, which allows
users to set the precision with which temperatures are read. It
defaults to 0, not the old hard-coded value of 1, because I decided that
it's not usually useful to hear that much information.
As described in issue #16, commands are now processed in two stages.
First, all plugins get to give a confidence with which they are the
right plugin to handle the command. Then, the one with the highest
confidence gets to run first, and if for some reason it can't handle the
command, other plugins try in turn.
The cache time is now configurable by the user. If no cache time is
set, the old default of half an hour is still used.
Temperature formatting has been factored out into its own function.
It has the same functionality as my old shell script, but now it's
written in Python. The code is far from the most elegant it could be,
but it's a decent example of how the new plugin API can be used for
something practical.