Factor out song retrieval and printing. Allow request() to benefit from '|' operator. #10
Merged
dsc
merged 1 commits from scoobybejesus/ircradio:master
into master
6 months ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'scoobybejesus/ircradio:master'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Request should now allow 2nd_needle
f51b523cd9
to2b9caab78b
7 months ago2b9caab78b
to88e03e1a22
7 months ago88e03e1a22
to662bfb0d68
7 months ago662bfb0d68
to14c3d5c163
7 months ago14c3d5c163
to47c7616cac
7 months ago47c7616cac
toe15b0e943e
7 months agoe15b0e943e
to8294cd4b8f
7 months ago8294cd4b8f
toc33b3ffd50
7 months agoIncorporate _search into request().to Factor out song retrieval and printing. Allow request() to benefit from '|' operator. 7 months agoc33b3ffd50
to4acddc9660
7 months ago4acddc9660
to238464b5d3
7 months ago238464b5d3
to06aebe691c
7 months ago06aebe691c
toa4930649fc
7 months agoOne thing that sticks out to me is that
_return_song_results()
is called in two places(search()
andrequest()
), and in both cases, there might be no songs as a result of the search, and both calling functions assume that_return_song_results()
will print the result of the search ("None found") in that case. Importantly,search()
andrequest()
will only call_print_song_results()
ifsongs != None
(andrequest()
only calls if there's more than one).But in the case where there are multiple songs, "Multiple found" is printed in
_print_song_results()
. "Multiple found" could just as easily be printed from_return_song_results()
. Or maybe you'd rather put the "None found" in_print_song_results()
.The main reason I didn't do the latter is because there are two versions "None found" (the other being "None found after '|' "), and I would rather not return a variable and then pass it to
_print_song_results()
in order to have the two versions of "None found", because that feels unnecessarily messy and possibly not pythonic.I can't think of a better way to architect this. Maybe it's somewhat a matter of taste. As mentioned above,
_print_song_results()
only gets called when there are results from a search. Perhaps if this "code invariant" were somehow made more clear, then the rest would make sense too. I don't think I like the idea of renaming_return_song_results()
as_return_song_results_and_or_print_none_found()
or renaming_print_song_results()
as_print_song_results_only_if_there_are_results()
. But maybe you do. Or maybe you like commenting code in a case like this.The diff isn't super pretty, but the code itself feel pretty good to me.
60f3b6c53b
into master 6 months agoThanks
👍 💯
60f3b6c53b
.