View Single Post
Old 01-05-2014, 10:46 AM   #1
ShellShock
Wizard
ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.ShellShock ought to be getting tired of karma fortunes by now.
 
ShellShock's Avatar
 
Posts: 1,178
Karma: 2431850
Join Date: Sep 2008
Device: IPad Mini 2 Retina
Calling smarten_punctuation from edit book

Re: https://www.mobileread.com/forums/sho...d.php?t=230684.

I have enhanced ebook-polish to add a new command line parameter:

Code:
-s SMARTEN_PUNCTUATION_OPT, --smarten-punctuation-opt=SMARTEN_PUNCTUATION_OPT
SMARTEN_PUNCTUATION_OPT gets passed to smartyPants as the attr (the options which control which conversions are done). I have also added additional conversions (for space+hyphen to em-dash etc) to smartyPants.

This all works fine.

But I am not clear on exactly how edit-book can call my new smarten_punctuation_opt command (in ebooks\oeb\polish\main.py) with parameters:

So in gui2\tweak_book\ui.py I have

Code:
self.action_smarten_punctuation = reg(
    'smarten-punctuation.png', _('&Smarten punctuation'), partial(
        self.boss.polish, 'smarten_punctuation_opt', _('Smarten punctuation')), 'smarten-punctuation', (), _('Smarten punctuation'))
smarten_punctuation_opt is my new smarten punctuation in ebooks\oeb\polish\main.py:

Code:
if opts.smarten_punctuation_opt:
    rt(_('Smartening punctuation'))
    smarten_punctuation(ebook, opts.smarten_punctuation_opt, report)
    #smarten_punctuation(ebook, "H", report)
    report('')
(If I use the commented out line I get the "H" conversion, so I know this call works when the smarten_punctuation options are hard coded).

I need to able to set opts.smarten_punctuation_opt when I call this from edit-book (obviously edit book is also going to need a UI to specify the smarten punctuation options but I will worry about that later).
ShellShock is offline   Reply With Quote