Messages

class djvu.decode.Message

An abstract base for all messages.

context
Returns

the concerned context.

Return type

Context.

document
Returns

the concerned document or None.

Type

Document

page_job
Returns

the concerned page job or None.

Return type

PageJob

job
Returns

the concerned job or None.

Return type

Job

Inheritance diagram:

Inheritance diagram of ErrorMessage, InfoMessage, NewStreamMessage, DocInfoMessage, PageInfoMessage, ChunkMessage, RelayoutMessage, RedisplayMessage, ThumbnailMessage, ProgressMessage
class djvu.decode.ErrorMessage

An ErrorMessage is generated whenever the decoder or the DDJVU API encounters an error condition. All errors are reported as error messages because they can occur asynchronously.

message
Returns

the actual error message, as text.

location
Returns

a (function, filename, line_no) tuple indicating where the error was detected.

class djvu.decode.InfoMessage

A InfoMessage provides informational text indicating the progress of the decoding process. This might be displayed in the browser status bar.

message
Returns

the actual error message, as text.

class djvu.decode.NewStreamMessage

A NewStreamMessage is generated whenever the decoder needs to access raw DjVu data. The caller must then provide the requested data using the stream file-like object.

In the case of indirect documents, a single decoder might simultaneously request several streams of data.

name

The first NewStreamMessage message always has name set to None. It indicates that the decoder needs to access the data in the main DjVu file.

Further NewStreamMessage messages are generated to access the auxiliary files of indirect or indexed DjVu documents. name then provides the base name of the auxiliary file.

uri
Returns

the requested URI.

URI is set according to the uri argument provided to function Context.new_document(). The first NewStreamMessage message always contain the URI passed to Context.new_document(). Subsequent NewStreamMessage messages contain the URI of the auxiliary files for indirect or indexed DjVu documents.

stream
Returns

a data stream.

class djvu.decode.Stream
close()

Indicate that no more data will be provided on the particular stream.

abort()

Indicate that no more data will be provided on the particular stream, because the user has interrupted the data transfer (for instance by pressing the stop button of a browser) and that the decoding threads should be stopped as soon as feasible.

flush()

Do nothing.

(This method is provided solely to implement Python’s file-like interface.)

read([size])
Raises

exceptions.IOError – always.

(This method is provided solely to implement Python’s file-like interface.)

write(data)

Provide raw data to the DjVu decoder.

This method should be called as soon as the data is available, for instance when receiving DjVu data from a network connection.

class djvu.decode.DocInfoMessage

A DocInfoMessage indicates that basic information about the document has been obtained and decoded. Not much can be done before this happens.

Check the document’s decoding_status to determine whether the operation was successful.

class djvu.decode.PageInfoMessage

The page decoding process generates a PageInfoMessage:

You can distinguish both cases using the page job’s status.

A PageInfoMessage may be also generated as a consequence of reading Page.get_info() or Page.dump.

class djvu.decode.ChunkMessage

A ChunkMessage indicates that an additional chunk of DjVu data has been decoded.

class djvu.decode.RelayoutMessage

A RelayoutMessage is generated when a DjVu viewer should recompute the layout of the page viewer because the page size and resolution information has been updated.

class djvu.decode.RedisplayMessage

A RedisplayMessage is generated when a DjVu viewer should call PageJob.render() and redisplay the page. This happens, for instance, when newly decoded DjVu data provides a better image.

class djvu.decode.ThumbnailMessage

A ThumbnailMessage is sent when additional thumbnails are available.

thumbnail
Return type

Thumbnail

Raises

NotAvailable – if the Document has been garbage-collected.

class djvu.decode.ProgressMessage

A ProgressMessage is generated to indicate progress towards the completion of a print or save job.

percent
Returns

the percent of the job done.

status
Returns

a JobException subclass indicating the current job status.