View Single Post
Old 09-12-2019, 10:53 PM   #27
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
So I've imported ScrambleEbook into a git repository here: https://github.com/eli-schwartz/ScrambleEbook

And this patch implements the CLI interface: https://github.com/eli-schwartz/Scra...775c440f515b85

Notice it's pretty simple to do. The heart of it is in __init__.py, where ScrambleEbookActionBase needs to be extended with a new method: cli_main(), which is responsible for initializing a new application and doing all that good stuff.

The thing that cli_main does is the same thing that running scrambleebook.py on its own needs to do: call a QApplication, set up the EbookScramble(QDialog), and exec the QApplication. Luckily, all that is already in a
Code:
if __name__ == '__main__'
, so I could simply shift the lines around, turn it into a main() function that is then called by if __name__ ..., and rewire it to pass sys.argv around sliiiiiightly different, so that I can pass my own array into main() if I really want to.

And then cli_main() runs calibre_plugins.scrambleebook_plugin.scrambleebook .main -- that's all.
eschwartz is offline   Reply With Quote