Calibre package

AMQP communication wrapper for calibre’s ebook-convert program.

edeposit.amqp.calibre.INPUT_FORMATS = ['cbz', 'cbr', 'cbc', 'chm', 'djvu', 'docx', 'epub', 'fb2', 'html', 'htmlz', 'lit', 'lrf', 'mobi', 'odt', 'pdf', 'prc', 'pdb', 'pml', 'rb', 'rtf', 'snb', 'tcr', 'txt', 'txtz']

List of available input formats.

edeposit.amqp.calibre.OUTPUT_FORMATS = ['azw3', 'epub', 'fb2', 'oeb', 'lit', 'lrf', 'mobi', 'htmlz', 'pdb', 'pml', 'rb', 'pdf', 'rtf', 'snb', 'tcr', 'txt', 'txtz']

List of available output formats.

class edeposit.amqp.calibre.ConversionRequest(input_format, output_format, b64_data)[source]

This structure specifies details of AMQP message, which is passed to reactToAMQPMessage() as request for conversion.

Parameters:
  • input_format (str) – see INPUT_FORMATS for list of valid input formats
  • output_format (str) – see OUTPUT_FORMATS for list of valid output formats
  • b64_data (base64 str) – base64 encoded file
Raises:

ValueError – if invalid input/output format is provided.

class edeposit.amqp.calibre.ConversionResponse[source]

Structure is returned as response from reactToAMQPMessage(), when the file is converted.

Parameters:
  • type (str) – see OUTPUT_FORMATS for details
  • b64_data (base64 str) – base64 encoded converted data
  • protocol (str) – protocol of the conversion
edeposit.amqp.calibre.reactToAMQPMessage(message, UUID)[source]

React to given (AMQP) message. message is usually expected to be collections.namedtuple() structure filled with all necessary data.

Parameters:
  • message (*Request class) – only ConversionRequest class is supported right now
  • UUID (str) – unique ID of received message
Returns:

ConversionResponse – response filled with data about conversion and converted file.

Raises:

ValueError – if bad type of message structure is given.

Lowlevel access

It is possible to access module directly, by calling python functions to convert data. If you are interested in this way of accessing functuions, please look at:

Table Of Contents

This Page