It is written raw, not via write_template, so it was never added to the
manifest. Therefore, it would remain behind when uninstalling calibre.
Also change the order in which steps are executed, in order to write the
env module -- and add it to the manifest -- before the uninstaller is
created, rather than after (which would be too late).
In order to prevent bloating the shell with thousands of bash completion
specs, bash completions are lazy-loaded as soon as the command is first
tab-completed. This only works when the completionsdir contains a
filename with the same name as the command being completed; as a result,
calibre commands were able to be tab-completed only after 'calibre' was
first completed.
(This is unlike the zsh completions, which work when installed as a
single unified file because zsh builds a cache of all known compdefs,
and can load a completion on demand by reading from the file which
contains it.)
One common solution for programs which install several completions that
share common helper functions is to install the completions in one file,
and symlink all other command names to ensure the file is loaded by any
name. I've opted for the other solution, which is to install each
completion separately, since there is no common helper function to load
once and use everywhere. As a result, there are some small speedups to
be gained from only loading the completions being used.
The main change is reindenting a lot of code to no longer be in a global
context manager, but instead get written inside o_and_e/o_and_w.
It's also necessary to write each individual completion file to the
uninstaller, so do that.
This gets us closer to a state where polyglot hacks can be dropped, and
is necessary to make per-command completion files not require even more
hacks to proxy through polyglot_write.
Some of these files no longer exist due to being devendored.
BeautifulSoup.py is now something else entirely which is
calibre-specific code and deserves the right to be linted.