Defines various abstract base classes that can be subclassed to create powerful plugins. The useful classes are:
Abstract base class that contains a number of members and methods to create your plugin. All plugins must inherit from this class or a subclass of it.
The members and methods are:
The name of this plugin. You must set it something other than Trivial Plugin for it to work.
Default: 'Trivial Plugin'
The author of this plugin
Default: u'Unknown'
A short string describing what this plugin does
Default: u'Does absolutely nothing'
The version of this plugin as a 3-tuple (major, minor, revision)
Default: (1, 0, 0)
List of platforms this plugin works on For example: ``[‘windows’, ‘osx’, ‘linux’]
Default: []
When more than one plugin exists for a filetype, the plugins are run in order of decreasing priority i.e. plugins with higher priority will be run first. The highest possible priority is sys.maxint. Default priority is 1.
Default: 1
The earliest version of calibre this plugin requires
Default: (0, 4, 118)
If False, the user will not be able to disable this plugin. Use with care.
Default: True
Called once when calibre plugins are initialized. Plugins are re-initialized every time a new plugin is added.
Perform any plugin specific initialization here, such as extracting resources from the plugin zip file. The path to the zip file is available as self.plugin_path.
Note that self.site_customization is not available at this point.
Return a string giving help on how to customize this plugin. By default raise a NotImplementedError, which indicates that the plugin does not require customization.
If you re-implement this method in your subclass, the user will be asked to enter a string as customization for this plugin. The customization string will be available as self.site_customization.
Site customization could be anything, for example, the path to a needed binary on the user’s computer.
| Parameter: | gui – If True return HTML help, otherwise return plain text help. |
|---|
Return a file-like object that is a temporary file on the file system. This file will remain available even after being closed and will only be removed on interpreter shutdown. Use the name member of the returned object to access the full path to the created temporary file.
| Parameter: | suffix – The suffix that the temporary file will have. |
|---|
Abstract base class that contains a number of members and methods to create your file type plugin. All file type plugins must inherit from this class or a subclass of it.
The members and methods are:
Set of file types for which this plugin should be run For example: set(['lit', 'mobi', 'prc'])
Default: set([])
If True, this plugin is run when books are added to the database
Default: False
If True, this plugin is run just before a conversion
Default: False
If True, this plugin is run after conversion on the final file produced by the conversion output plugin.
Default: False
Run the plugin. Must be implemented in subclasses. It should perform whatever modifications are required on the ebook and return the absolute path to the modified ebook. If no modifications are needed, it should return the path to the original ebook. If an error is encountered it should raise an Exception. The default implementation simply return the path to the original ebook.
The modified ebook file should be created with the temporary_file() method.
| Parameter: | path_to_ebook – Absolute path to the ebook. |
|---|---|
| Returns: | Absolute path to the modified ebook. |
Abstract base class that contains a number of members and methods to create your metadata reader plugin. All metadata reader plugins must inherit from this class or a subclass of it.
The members and methods are:
Set of file types for which this plugin should be run For example: set(['lit', 'mobi', 'prc'])
Default: set([])
Return metadata for the file represented by stream (a file like object that supports reading). Raise an exception when there is an error with the input data.
| Parameter: | type – The type of file. Guaranteed to be one of the entries |
|---|
in file_types.
| Returns: | A calibre.ebooks.metadata.MetaInformation object |
|---|
Abstract base class that contains a number of members and methods to create your metadata writer plugin. All metadata writer plugins must inherit from this class or a subclass of it.
The members and methods are:
Set of file types for which this plugin should be run For example: set(['lit', 'mobi', 'prc'])
Default: set([])
Set metadata for the file represented by stream (a file like object that supports reading). Raise an exception when there is an error with the input data.
| Parameter: | type – The type of file. Guaranteed to be one of the entries |
|---|
in file_types. :param mi: A calibre.ebooks.metadata.MetaInformation object
Represents a source to query for metadata. Subclasses must implement at least the fetch method.
When fetch() is called, the self object will have the following useful attributes (each of which may be None):
title, author, publisher, isbn, log, verbose and extra
Use these attributes to construct the search query. extra is reserved for future use.
The fetch method must store the results in self.results as a list of MetaInformation objects. If there is an error, it should be stored in self.exception and self.tb (for the traceback).
The type of metadata fetched. ‘basic’ means basic metadata like title/author/isbn/etc. ‘social’ means social metadata like tags/rating/reviews/etc.
Default: 'basic'
If not None, the customization dialog will allow for string based customization as well the default customization. The string customization will be saved in the site_customization member.
Default: None