![]() |
#601 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,761
Karma: 24088559
Join Date: Dec 2010
Device: Kindle PW2
|
I'd strongly recommend Automate the Boring Stuff with Python by Al Sweigart, which is available for free online.
You'll also need to download the Sigil Framework Guide. You also might find the Sigil test plugin helpful because it demonstrates most Sigil-specific Python functions. Here's a minimal proof-of-concept edit plugin that will wrap "the" in all html files in <b> tags: Code:
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys, os # main routine def run(bk): # iterate over all html files for html_id, href in bk.text_iter(): # read orignal html code from file original_html = bk.readfile(html_id) # modify html code modified_html = original_html.replace('the', '<b>the</b>') if modified_html != original_html: # write modified html code to file bk.writefile(html_id, modified_html) print(os.path.basename(href) + ' updated') return 0 def main(): print('I reached main when I should not have\n') return -1 if __name__ == "__main__": sys.exit(main()) Code:
from sigil_bs4 import BeautifulSoup
|
![]() |
![]() |
![]() |
#602 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,062
Karma: 6361556
Join Date: Nov 2009
Device: many
|
Just to be clear ...
Sigil plugins only allow batch processing of files inside a single loaded epub. If you want to batch process a number of epubs without having to load them in Sigil, python is the way to go but not Sigil Plugins. That said the python modules in Sigil could be extracted and used in a standalone python program with only low to moderate effort. Last edited by KevinH; Yesterday at 08:06 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#603 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 31,235
Karma: 60807154
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
This is one of the reasons I use Sigil for some tasks and Calibre Editor for others. They fit MY workflow (please keep doing Sigil things, the Sigil way), and Calibre does others. All we need to do is learn to use the tools we have without making those other folk that want the other way (either editor) use OUR way. Only if it is broken, does it need fixin' ![]() |
|
![]() |
![]() |
![]() |
#604 | |
Belgian Pommes Frites
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 131
Karma: 35038
Join Date: Jan 2012
Device: Pocketbook Touch HD
|
Tools
Quote:
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Loading Plugin in development | Sladd | Development | 6 | 06-17-2014 06:57 PM |
Question for plugin development gurus | DiapDealer | Plugins | 2 | 02-04-2012 11:33 PM |
DR800 Plugin development for DR800/DR1000 | yuri_b | iRex Developer's Corner | 0 | 09-18-2010 09:46 AM |
Device plugin development | reader42 | Plugins | 10 | 03-29-2010 12:39 PM |
Calibre plugin development - Newbie problems | minstrel | Plugins | 5 | 04-12-2009 12:44 PM |