Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 08-10-2011, 10:16 PM   #1
yo123
Junior Member
yo123 began at the beginning.
 
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
yo123 is offline   Reply With Quote
Old 08-11-2011, 01:44 AM   #2
yo123
Junior Member
yo123 began at the beginning.
 
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
yo123 is offline   Reply With Quote
Advert
Old 08-11-2011, 09:32 AM   #3
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
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.
user_none is offline   Reply With Quote
Old 08-11-2011, 05:50 PM   #4
yo123
Junior Member
yo123 began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Aug 2011
Device: Kindle 3
Quote:
Originally Posted by user_none View Post
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.
Thanks. Here is what I think I need to change in the inheriting class.

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())),
yo123 is offline   Reply With Quote
Old 08-11-2011, 05:59 PM   #5
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
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.
user_none is offline   Reply With Quote
Advert
Old 08-11-2011, 06:00 PM   #6
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
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.
user_none is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 03:00 PM.


MobileRead.com is a privately owned, operated and funded community.