Functions

base64_decode_simple (data, len)

base64_decode_step (in_, len, out, state, save)

base64_encode_close (in_, break_lines, out, state, save)

base64_encode_simple (data, len)

base64_encode_step (in_, len, break_lines, out, state, save)

debug_flag (flag)

doc_meta_dump (meta)

error_quark ()

extension_pointer (path)

filename_to_utf8 (filename, quoted)

init ()

init_dynamic (module)

le_get_double (p)

le_get_float (p)

le_get_guint64 (p)

le_set_double (p, d)

le_set_float (p, f)

mem_dump (ptr, len)

msole_codepage_to_lid (codepage)

msole_iconv_win_codepage ()

msole_inflate (input, offset)

msole_language_for_lid (lid)

msole_lid_for_language (lang)

msole_lid_to_codepage (lid)

msole_lid_to_codepage_str (lid)

odf_get_ns ()

odf_get_version ()

odf_get_version_string ()

open_pkg_error_id ()

open_pkg_foreach_rel (opkg, func, *user_data)

open_pkg_open_rel (opkg, rel)

open_pkg_open_rel_by_id (opkg, id)

open_pkg_open_rel_by_type (opkg, type)

open_pkg_parse_rel_by_id (xin, id, dtd, ns)

property_settings_find (name, params)

property_settings_free (params)

shutdown ()

shutdown_dynamic (module)

value_get_docprop_array (value)

value_get_docprop_varray (value)

value_get_docprop_vector (value)

vba_inflate (input, offset, size, add_null_terminator)

xmlDocFormatDump (output, cur, encoding, format)

xml_gvalue_from_str (res, t, str)

xml_probe (input, func)

Details

Gsf.base64_decode_simple(data, len)
Parameters:
  • data (bytes) – data stream

  • len (int) – max length of data to decode

Returns:

the number of bytes converted

Return type:

int

Decodes a chunk of base64 encoded data from data back into data.

Gsf.base64_decode_step(in_, len, out, state, save)
Parameters:
  • in (bytes) – input stream

  • len (int) – max length of data to decode

  • out (bytes) – output stream

  • state (int) – holds the number of bits that are stored in save

  • save (int) – leftover bits that have not yet been decoded

Returns:

the number of bytes converted

state:

holds the number of bits that are stored in save

save:

leftover bits that have not yet been decoded

Return type:

(int, state: int, save: int)

Decodes a chunk of base64 encoded data

Gsf.base64_encode_close(in_, break_lines, out, state, save)
Parameters:
  • in (bytes) – Data to be encoded

  • break_lines (bool) – Whether to use line breaks

  • out (bytes) – Encoded data.

  • state (int) – holds the number of bits that are stored in save

  • save (int) – leftover bits that have not yet been decoded

Returns:

a count of the number of bytes in the final block.

state:

holds the number of bits that are stored in save

save:

leftover bits that have not yet been decoded

Return type:

(int, state: int, save: int)

This funcion should be called to when finished encoding everything, to flush off the last little bit.

Gsf.base64_encode_simple(data, len)
Parameters:
  • data (bytes) – data stream

  • len (int) – max length of data to encode

Returns:

the number of bytes encoded

Return type:

int

Encodes data from data back into data using base64 encoding.

Gsf.base64_encode_step(in_, len, break_lines, out, state, save)
Parameters:
  • in (bytes) – input stream

  • len (int) – max length of data to decode

  • break_lines (bool) – Whether to use line breaks

  • out (bytes) – output stream

  • state (int) – holds the number of bits that are stored in save

  • save (int) – leftover bits that have not yet been decoded

Returns:

the number of bytes encoded

state:

holds the number of bits that are stored in save

save:

leftover bits that have not yet been decoded

Return type:

(int, state: int, save: int)

Performs an ‘encode step’, only encodes blocks of 3 characters from in into the output out at a time, saves left-over state in state and save (initialise to 0 on first invocation).

Gsf.debug_flag(flag)
Parameters:

flag (str) –

Return type:

bool

Gsf.doc_meta_dump(meta)
Parameters:

meta (Gsf.DocMetaData) – Gsf.DocMetaData

A debugging utility to dump the content of meta via g_print

Gsf.error_quark()
Returns:

the #GQuark used to identify libgsf errors in GLib.Error structures. Specific error codes come from the Gsf.Error enumeration.

Return type:

int

Gsf.extension_pointer(path)
Parameters:

path (str) – A filename or file path.

Returns:

A pointer to the extension part of the filename, or a pointer to the end of the string if the filename does not have an extension.

Return type:

str

Extracts the extension from the end of a filename (the part after the final ‘.’ in the filename).

Gsf.filename_to_utf8(filename, quoted)
Parameters:
  • filename (str) – file name suitable for open(2).

  • quoted (bool) – if True, the resulting utf8 file name will be quoted (unless it is invalid).

Returns:

filename using utf-8 encoding for display

Return type:

str

A utility wrapper to make sure filenames are valid utf8. Caller must GLib.free the result.

Gsf.init()

Initializes the GSF library

Gsf.init_dynamic(module)
Parameters:

module (GObject.TypeModule) – GObject.TypeModule.

Initializes the GSF library and associates it with a type module mod.

Gsf.le_get_double(p)
Parameters:

p (object or None) – pointer to storage

Returns:

interpreted data

Return type:

float

Interpret binary data as a double in little endian order.

Gsf.le_get_float(p)
Parameters:

p (object or None) – pointer to storage

Returns:

interpreted data

Return type:

float

Interpret binary data as a float in little endian order.

Gsf.le_get_guint64(p)
Parameters:

p (object or None) – pointer to storage

Returns:

interpreted data

Return type:

int

Interpret binary data as a guint64 (8 byte unsigned integer type) in little endian order.

Gsf.le_set_double(p, d)
Parameters:
  • p (object or None) – pointer to storage

  • d (float) – double to be stored

Store a value of type double in memory in little endian order

Gsf.le_set_float(p, f)
Parameters:
  • p (object or None) – pointer to storage

  • f (float) – float to be stored

Store a value of type float in memory in little endian order.

Gsf.mem_dump(ptr, len)
Parameters:
  • ptr (int) – memory area to be dumped.

  • len (int) – how many bytes will be dumped.

Dump len bytes from the memory location given by ptr.

Gsf.msole_codepage_to_lid(codepage)
Parameters:

codepage (int) –

Return type:

int

Gsf.msole_iconv_win_codepage()
Returns:

our best guess at the applicable windows code page based on an environment variable or the current locale.

Return type:

int

Gsf.msole_inflate(input, offset)
Parameters:
  • input (Gsf.Input) – stream to read from

  • offset (int) – offset into it for start byte of compresse stream

Returns:

A GLib.ByteArray that the caller is responsible for freeing

Return type:

bytes

Decompresses an LZ compressed stream.

Gsf.msole_language_for_lid(lid)
Parameters:

lid (int) – numerical language id

Returns:

the xx_YY style string (can be just xx or xxx) for the given LID. If the LID is not found, is set to 0x0400, or is set to 0x0000, will return “-none-”

Return type:

str

Gsf.msole_lid_for_language(lang)
Parameters:

lang (str or None) – Language id, i.e., locale name.

Returns:

the LID (Language Identifier) for the input language. If lang is None, return 0x0400 (“-none-“), and not 0x0000 (“no proofing”)

Return type:

int

Gsf.msole_lid_to_codepage(lid)
Parameters:

lid (int) – numerical language id

Returns:

our best guess at the codepage for the given language id

Return type:

int

Gsf.msole_lid_to_codepage_str(lid)
Parameters:

lid (int) – numerical language id

Returns:

the Iconv codepage string for the given LID.

Return type:

str

Gsf.odf_get_ns()
Returns:

the used ODF namespace

Return type:

Gsf.XMLInNS

New in version 1.14.24.

Gsf.odf_get_version()
Returns:

the ODF version: 102.

Return type:

int

Gives the ODF version used by libgsf when writing Open Document files.

New in version 1.14.24.

Gsf.odf_get_version_string()
Returns:

the ODF version as a string: “1.2”.

Return type:

str

Gives the ODF version used by libgsf when writing Open Document files.

New in version 1.14.24.

Gsf.open_pkg_error_id()
Return type:

int

Gsf.open_pkg_foreach_rel(opkg, func, *user_data)
Parameters:

New in 1.14.9

Walks each relationship associated with opkg and calls func with user_data.

Gsf.open_pkg_open_rel(opkg, rel)
Parameters:
Raises:

GLib.Error

Returns:

a new Gsf.Input which the called needs to unref, or None and sets err

Return type:

Gsf.Input

Gsf.open_pkg_open_rel_by_id(opkg, id)
Parameters:
Raises:

GLib.Error

Returns:

A new Gsf.Input or None, and sets err if possible.

Return type:

Gsf.Input

New in 1.14.7

Open opkg's relation id

Gsf.open_pkg_open_rel_by_type(opkg, type)
Parameters:
Raises:

GLib.Error

Returns:

A new Gsf.Input or None, and sets err if possible.

Return type:

Gsf.Input

New in 1.14.9

Open one of opkg's relationships with type=`type`.

Gsf.open_pkg_parse_rel_by_id(xin, id, dtd, ns)
Parameters:
Returns:

None on success or a GLib.Error on failure.

Return type:

GLib.Error

Convenience function to parse a related part.

Gsf.property_settings_find(name, params)
Parameters:
Return type:

GObject.Parameter

Gsf.property_settings_free(params)
Parameters:

params ([GObject.Parameter]) –

Gsf.shutdown()

De-intializes the GSF library Currently does nothing.

Gsf.shutdown_dynamic(module)
Parameters:

module (GObject.TypeModule) – currently unused

De-intializes the GSF library from a type module. Currently does nothing.

Gsf.value_get_docprop_array(value)
Parameters:

value (GObject.Value) – A GObject.Value of type Gsf.DocPropVector.

Returns:

A GLib.Array of GObject.Value

Return type:

[GObject.Value] or None

This function returns the array of values inside Gsf.DocPropVector. No additional references are created.

Gsf.value_get_docprop_varray(value)
Parameters:

value (GObject.Value) –

Return type:

GObject.ValueArray

Gsf.value_get_docprop_vector(value)
Parameters:

value (GObject.Value) – A GObject.Value of type Gsf.DocPropVector.

Returns:

A pointer to the Gsf.DocPropVector structure in value

Return type:

Gsf.DocPropVector

This function returns a pointer to the Gsf.DocPropVector structure in value. No additional references are created.

Gsf.vba_inflate(input, offset, size, add_null_terminator)
Parameters:
  • input (Gsf.Input) – stream to read from

  • offset (int) – offset into it for start byte of compressed stream

  • size (int) – size of the returned array

  • add_null_terminator (bool) – whenever add or not null at the end of array

Returns:

A pointer to guint8 array

Return type:

int

Decompresses VBA stream.

Gsf.xmlDocFormatDump(output, cur, encoding, format)
Parameters:
Returns:

status from xmlSaveFormatFileTo.

Return type:

int

Dumps the document cur into output.

Gsf.xml_gvalue_from_str(res, t, str)
Parameters:
Returns:

True when parsing of str as a value of type t was succesfull; false otherwise.

Return type:

bool

Try to parse str as a value of type t into res.

Gsf.xml_probe(input, func)
Parameters:
Returns:

True on success.

Return type:

bool