Functions

backend_query_type ()

document_error_quark ()

file_compress (uri, type)

file_copy_metadata (from_, to)

file_get_mime_type (uri, fast)

file_get_mime_type_from_fd (fd)

file_is_temp (file)

file_uncompress (uri, type)

init ()

mkstemp (tmpl)

mkstemp_file (tmpl)

rect_cmp (a, b)

shutdown ()

tmp_file_unlink (file)

tmp_filename_unlink (filename)

tmp_uri_unlink (uri)

xfer_uri_simple (from_, to)

xmp_parse (xmp, size, info)

Details

PapersDocument.backend_query_type()
Return type:

GObject.GType

PapersDocument.document_error_quark()
Return type:

int

PapersDocument.file_compress(uri, type)
Parameters:
Raises:

GLib.Error

Returns:

a newly allocated string URI, or None on error

Return type:

str

Compresses the file at uri.

If type is PapersDocument.CompressionType.NONE, it does nothing and returns None.

Otherwise, it returns the filename of a temporary file containing the compressed data from the file at uri.

On error it returns None and fills in error.

It is the caller’s responsibility to unlink the temp file after use.

PapersDocument.file_copy_metadata(from_, to)
Parameters:
  • from (str) – the source URI

  • to (str) – the target URI

Raises:

GLib.Error

Returns:

True if the attributes were copied successfully, False otherwise.

Return type:

bool

Performs a Gio.File.copy_attributes() with Gio.FileCopyFlags.ALL_METADATA from from to to.

New in version 3.4.

PapersDocument.file_get_mime_type(uri, fast)
Parameters:
  • uri (str) – the URI

  • fast (bool) – whether to use fast MIME type detection

Raises:

GLib.Error

Returns:

a newly allocated string with the MIME type of the file at uri, or None on error or if the MIME type could not be determined

Return type:

str

PapersDocument.file_get_mime_type_from_fd(fd)
Parameters:

fd (int) – an file descriptor (must be seekable)

Raises:

GLib.Error

Returns:

a newly allocated string with the MIME type of the file referred to by fd, or None on error or if the MIME type could not be determined

Return type:

str

PapersDocument.file_is_temp(file)
Parameters:

file (Gio.File) –

Return type:

bool

PapersDocument.file_uncompress(uri, type)
Parameters:
Raises:

GLib.Error

Returns:

a newly allocated string URI, or None on error

Return type:

str

Uncompresses the file at uri.

If type is PapersDocument.CompressionType.NONE, it does nothing and returns None.

Otherwise, it returns the filename of a temporary file containing the decompressed data from the file at uri. On error it returns None and fills in error.

It is the caller’s responsibility to unlink the temp file after use.

PapersDocument.init()
Returns:

True if any backends were found; False otherwise

Return type:

bool

Initializes the papers document library, and binds the papers gettext domain.

You must call this before calling any other function in the papers document library.

PapersDocument.mkstemp(tmpl)
Parameters:

tmpl (str) – a template string; must contain ‘XXXXXX’, but not necessarily as a suffix

Raises:

GLib.Error

Returns:

a file descriptor to the newly created temp file name, or %-1 on error with error filled in

file_name:

a location to store the filename of the temp file

Return type:

(int, file_name: str)

Creates a temp file in the papers temp directory.

PapersDocument.mkstemp_file(tmpl)
Parameters:

tmpl (str) – a template string; must contain ‘XXXXXX’, but not necessarily as a suffix

Raises:

GLib.Error

Returns:

a newly allocated Gio.File for the newly created temp file name, or None on error with error filled in

Return type:

Gio.File

Creates a temp Gio.File in the papers temp directory. See PapersDocument.mkstemp() for more information.

PapersDocument.rect_cmp(a, b)
Parameters:
Return type:

int

PapersDocument.shutdown()

Shuts the papers document library down.

Parameters:

file (Gio.File) –

Parameters:

filename (str) –

Parameters:

uri (str) –

PapersDocument.xfer_uri_simple(from_, to)
Parameters:
  • from (str) – the source URI

  • to (str) – the target URI

Raises:

GLib.Error

Returns:

True on success, or False on error with error filled in

Return type:

bool

Performs a Gio.File.copy() from from to to.

PapersDocument.xmp_parse(xmp, size, info)
Parameters:
Return type:

bool