Variables Objects

Variables Class and Subclasses

class Variables

The Variables is dict-like container for subclasses of Variable. This is superclass for SimpleVariables and UserFields

Warning

Don’t create instances of this class and its subclasses yourself, use document.body.variables or document.body.userfields

Methods

Variables.__getitem__(key)

Get Variable instance by varible name

Parameters:key (str) – Variable name
Return type:Variable instance
Returns:Variable class instance
Variables.__setitem__(key, value)

Set Variable instance by varible name

Parameters:
  • key (str) – Variable name
  • value (float or boolean or str) – Variable value
Return type:

Variable instance

Returns:

Variable class instance

class SimpleVariables

The SimpleVariables is dict-like container for SimpleVariable, it’s a subclass of Variables

class UserFields

The UserFields is dict-like container for UserField, it’s a subclass of Variables

Variable class and subclasses

class Variable

This class represents a variable. The instances of it can be found in Variables and accessed through document.body.variables[‘somevar’] or document.body.userfields[‘somevar’]

Attributes

Variable.type(read/write)

Type of the variable can be ‘string’, ‘float’, ‘boolean’ or other described in 19.385 of “OpenDocument-v1.2-os-part1”

Type:str
Variable.value(read/write)

Value of the variable converted to Python type according to Variable.type

Type:str, float, boolean
Variable.instances(read/write)

See SimpleVariableInstance and UserFieldInstance

Warning

Use with caution can work a bit unexpected

class SimpleVariable

This class represents a simple variable. The instances of it can be found in SimpleVariables and accessed through document.body.variables[‘somevar’]

Attributes

SimpleVariable.instances(read/write)

List of SimpleVariableInstance subclasses that represents occurrences of variable in document see 7.4.4 - 6 of “OpenDocument-v1.2-os-part1”

Warning

Use with caution can work a bit unexpected

class UserField

This class represents a simple variable. The instances of it can be found in SimpleVariables and accessed through document.body.variables[‘somevar’]

Attributes

UserField.instances(read/write)

List of UserFieldInstance subclasses that represents occurrences of variable in document see 7.4.9 - 10 of “OpenDocument-v1.2-os-part1”

Warning

Use with caution can work a bit unexpected

Simple Variable Instance Subclasses

class SimpleVariableInstance

Base class for SimpleVariableGet, SimpleVariableSet and SimpleVariableInput

Attributes

SimpleVariableInstance.type(read/write)

Type of the variable can be ‘string’, ‘float’, ‘boolean’ or other described in 19.385 of “OpenDocument-v1.2-os-part1”

Type:str
SimpleVariableInstance.value(read/write)

Value of the variable converted to Python type according to SimpleVariableInstance.type

Type:str, float, boolean
class SimpleVariableGet

Subclass of SimpleVariableInstance handling “text:variable-get” tag.

class SimpleVariableSet

Subclass of SimpleVariableInstance handling “text:variable-set” tag.

class SimpleVariableInput

Subclass of SimpleVariableInstance handling “text:variable-input” tag.