![]() |
#1 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Aug 2011
Device: Kindle 3
|
Extend PDB output format
Hi,
I am trying to write an output plugin to extend the PDB output formats. PDB itself is only a container. Currently Calibre supports the following three output formats inside PDB. They can be selected from the PDB output dialog page before converting a ebook. FORMAT_WRITERS = { 'doc': palmdoc_writer, 'ztxt': ztxt_writer, 'ereader': ereader_writer, } I have had the Writer and PDBOuput classes figured out for the plugin. class HaodooWriter(FormatWriter): class HaoDooPdbOutput(calibre.ebooks.pdb.output.PDBOutpu t): However, I am stuck at how to add this extra writer to the dialog page. I assumed that I need to make the above dictionary to become: FORMAT_WRITERS = { 'doc': palmdoc_writer, 'ztxt': ztxt_writer, 'ereader': ereader_writer, 'haodoo': haodoo_writer, } and also make it to be loaded by Calibre UI. How can I realize this using the plugin mechanism without changing Calibre codes? Any pointer/suggestion would be deeply appreciated. Thanks in advance. Jack |
![]() |
![]() |
![]() |
#2 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Aug 2011
Device: Kindle 3
|
Hmm, I think I figure it out. Seems that I need to add the format option in the class HaoDooPdbOutput?
Jack |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Sigil & calibre developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
I can't remember how the PDB components are designed off the top of my head. I will explain how to add a new writer and reader later today.
|
![]() |
![]() |
![]() |
#4 | |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Aug 2011
Device: Kindle 3
|
Quote:
class PDBOutput(OutputFormatPlugin): name = 'PDB Output' author = 'John Schember' file_type = 'pdb' options = set([ OptionRecommendation(name='format', recommended_value='doc', level=OptionRecommendation.LOW, short_switch='f', choices=FORMAT_WRITERS.keys(), help=(_('Format to use inside the pdb container. Choices are:')+\ ' %s' % FORMAT_WRITERS.keys())), |
|
![]() |
![]() |
![]() |
#5 |
Sigil & calibre developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
You cannot create a new output class for PDB. You must work within the current class. Calibre is file type based. There is no way to associate multiple output classes with a single format.
calibre.ebooks.pdb.output.PDBOutput.convert This takes the PDB identity and checks if there is a writer associated with it. The writer used for output is taken from calibre.ebooks.pdb.FORMAT_WRITERS. You would need to add a key and associated class reference to this dictionary to enable writing a specific PDB type. Also if you are adding a new identity be sure to add it to calibre.ebooks.pdb.IDENTITY_TO_NAME if it is not already in that list. calibre.ebooks.pdb.output.PDBInput uses the same design for adding PDB readers. Add a new module to the PDB module. You will need to put your writer class in a file named writer.py. The writer must be a subclass of calibre.ebooks.pdb.formatreader.FormatReader. Your subclass must implement __init__ and extract_content. Look at the palmdoc module for a simple example. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Sigil & calibre developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,487
Karma: 1063785
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
|
Also, you have no need to modify the format option as its options are derived from FORMAT_WRITERS and is populated by the available writers.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
output pdb from calibre | GillianMary | Calibre | 7 | 11-02-2010 10:39 PM |
PDB output conversion error | silinthar | Calibre | 6 | 10-01-2010 02:18 AM |
Problem with output of PDB files | Katelyn | Calibre | 2 | 03-21-2010 01:01 PM |
eReader output (pdb) has too much space on my iPhone | bthoven | Calibre | 7 | 10-27-2009 07:43 AM |
PRS-500 PDB header format | Avian | Sony Reader Dev Corner | 14 | 10-03-2007 09:39 AM |