Template.Scope

Fields

None

Methods

class

new ()

dup_string (name)

get (name)

list_symbols (recursive)

new_with_parent ()

peek (name)

ref ()

require (namespace_, version)

set (name, symbol)

set_boolean (name, value)

set_double (name, value)

set_null (name)

set_object (name, value)

set_resolver (resolver, *user_data)

set_string (name, value)

set_strv (name, value)

set_value (name, value)

set_variant (name, value)

take (name, symbol)

unref ()

Details

class Template.Scope
classmethod new()
Returns:

A newly created Template.Scope.

Return type:

Template.Scope

Creates a new scope to contain variables and custom expressions,

dup_string(name)
Parameters:

name (str) –

Returns:

a string or None

Return type:

str or None

Gets a string if the symbol name is a string.

Otherwise, None is returned.

New in version 3.36.

get(name)
Parameters:

name (str) –

Returns:

A Template.Symbol.

Return type:

Template.Symbol

If the symbol could not be found, it will be allocated.

list_symbols(recursive)
Parameters:

recursive (bool) – if the parent scopes should be included

Returns:

an array containing the names of all symbols within the scope.

Return type:

[str]

Gets the names of all symbols within the scope.

new_with_parent()
Returns:

A newly created Template.Scope.

Return type:

Template.Scope

Creates a new scope to contain variables and custom expressions, If self is set, the parent scope will be inherited.

peek(name)
Parameters:

name (str) –

Returns:

A Template.Symbol or None.

Return type:

Template.Symbol or None

If the symbol could not be found, None is returned.

ref()
Return type:

Template.Scope

require(namespace_, version)
Parameters:
  • namespace (str) – the namespace to import into the scope

  • version (str or None) – the version of namespace_ to import

Returns:

True if successful; otherwise False

Return type:

bool

Imports namespace_ into self so it can be used by expressions.

set(name, symbol)
Parameters:

If the symbol already exists, it will be overwritten.

If symbol is None, the symbol will be removed from scope.

set_boolean(name, value)
Parameters:
  • name (str) – a name for the symbol

  • value (bool) – a bool

Sets the value of the symbol named name to a bool value of value.

set_double(name, value)
Parameters:

Sets the value of the symbol named name to a float value of value.

set_null(name)
Parameters:

name (str) –

set_object(name, value)
Parameters:

Sets the value of the symbol named name to the object value.

set_resolver(resolver, *user_data)
Parameters:
set_string(name, value)
Parameters:
  • name (str) – a name for the symbol

  • value (str or None) – A string or None.

Sets the value of the symbol named name to a string matching value.

set_strv(name, value)
Parameters:
  • name (str) – a name for the symbol

  • value ([str] or None) – the value to set it to, or None

Sets the value of the symbol named name to the strv value.

set_value(name, value)
Parameters:

Sets the contents of the symbol named name to the value value.

set_variant(name, value)
Parameters:

Sets the value of the symbol named name to the variant value.

If value has a floating reference, it is consumed.

take(name, symbol)
Parameters:

Sets the symbol named name to symbol in scope.

This differs from Template.Scope.set() in that it takes ownership of symbol.

unref()