lawwenda.previewer package

Submodules

lawwenda.previewer.commonimages module

Preview functionality for common image formats.

class lawwenda.previewer.commonimages.CommonImagesPreviewer

Bases: lawwenda.previewer.Previewer

Preview functionality for common image formats.

_abc_impl = <_abc_data object>
is_previewable(iar)

Return if this previewer is able to generate an html preview snippet for a file.

Note that this decision has to be made with very few information, e.g. without knowing the file content, for performance reasons.

See also preview_html().

Parameters

iar – An object that describes the file.

is_thumbnailable(iar)

Return if this previewer is able to generate a thumbnail for a file.

Note that this decision has to be made with very few information, e.g. without knowing the file content, for performance reasons.

See also thumbnail().

Parameters

iar – An object that describes the file.

preview_html(node)

Return an html snippet that shows a preview of a file.

This is larger and richer in terms of flexibility than thumbnails, and is typically used by the file details panel.

See also is_previewable().

Parameters

node – The file to preview.

thumbnail(node)

Return a thumbnail for a file in PNG format.

See also is_thumbnailable().

Parameters

node – The file to generate a thumbnail for.

lawwenda.previewer.commonvideos module

Preview functionality for common video formats.

class lawwenda.previewer.commonvideos.CommonVideosPreviewer

Bases: lawwenda.previewer.Previewer

Preview functionality for common video formats.

__ffmpeg_thumb(stdin=- 3)
Parameters
  • inputpath (str) –

  • stdin (Any) –

Return type

bytes

_abc_impl = <_abc_data object>
is_previewable(iar)

Return if this previewer is able to generate an html preview snippet for a file.

Note that this decision has to be made with very few information, e.g. without knowing the file content, for performance reasons.

See also preview_html().

Parameters

iar – An object that describes the file.

is_thumbnailable(iar)

Return if this previewer is able to generate a thumbnail for a file.

Note that this decision has to be made with very few information, e.g. without knowing the file content, for performance reasons.

See also thumbnail().

Parameters

iar – An object that describes the file.

preview_html(node)

Return an html snippet that shows a preview of a file.

This is larger and richer in terms of flexibility than thumbnails, and is typically used by the file details panel.

See also is_previewable().

Parameters

node – The file to preview.

thumbnail(node)

Return a thumbnail for a file in PNG format.

See also is_thumbnailable().

Parameters

node – The file to generate a thumbnail for.

Module contents

Preview functionality.

Used by different parts of the Lawwenda user interface.

class lawwenda.previewer.IsAbleRequest(name, mimetype)

Bases: object

Information about a particular file, used for asking a Previewer if it can provide some functionality for that file.

Instances of this class are used as an argument to some Previewer methods.

The available infos are not very rich for performance reasons.

Parameters
  • name (str) –

  • mimetype (str) –

Return type

None

mimetype: str
name: str
class lawwenda.previewer.Previewer

Bases: abc.ABC

Base class for previewers.

Subclasses implement thumbnail and preview functionality for particular file formats.

_abc_impl = <_abc_data object>
_image_scale_to_thumbnail_size(imgdata)
Parameters

imgdata (BinaryIO) –

Return type

_io.BytesIO

abstract is_previewable(iar)

Return if this previewer is able to generate an html preview snippet for a file.

Note that this decision has to be made with very few information, e.g. without knowing the file content, for performance reasons.

See also preview_html().

Parameters

iar (lawwenda.previewer.IsAbleRequest) – An object that describes the file.

Return type

bool

abstract is_thumbnailable(iar)

Return if this previewer is able to generate a thumbnail for a file.

Note that this decision has to be made with very few information, e.g. without knowing the file content, for performance reasons.

See also thumbnail().

Parameters

iar (lawwenda.previewer.IsAbleRequest) – An object that describes the file.

Return type

bool

abstract preview_html(node)

Return an html snippet that shows a preview of a file.

This is larger and richer in terms of flexibility than thumbnails, and is typically used by the file details panel.

See also is_previewable().

Parameters

node (lawwenda.fs.Filesystem.Node) – The file to preview.

Return type

str

thumbheight = 300
abstract thumbnail(node)

Return a thumbnail for a file in PNG format.

See also is_thumbnailable().

Parameters

node (lawwenda.fs.Filesystem.Node) – The file to generate a thumbnail for.

Return type

bytes

thumbsize = (300, 300)
thumbwidth = 300