Xmlb.BuilderNode

g GObject.Object GObject.Object Xmlb.BuilderNode Xmlb.BuilderNode GObject.Object->Xmlb.BuilderNode

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (element)

add_child (child)

add_flag (flag)

add_token (token)

depth ()

export (flags)

get_attr (name)

get_attr_as_uint (name)

get_child (element, text)

get_children ()

get_element ()

get_first_child ()

get_last_child ()

get_parent ()

get_tail ()

get_text ()

get_text_as_uint ()

get_tokens ()

has_flag (flag)

remove_attr (name)

remove_child (child)

set_attr (name, value)

set_element (element)

set_tail (tail, tail_len)

set_text (text, text_len)

sort_children (func, *user_data)

tokenize_text ()

traverse (order, flags, max_depth, func, *user_data)

unlink ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Xmlb.BuilderNode(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Xmlb.BuilderNodeClass

classmethod new(element)
Parameters:

element (str) – An element name, e.g. “component”

Returns:

a new Xmlb.BuilderNode

Return type:

Xmlb.BuilderNode

Creates a new builder node.

New in version 0.1.0.

add_child(child)
Parameters:

child (Xmlb.BuilderNode) – A Xmlb.BuilderNode

Adds a child builder node.

New in version 0.1.0.

add_flag(flag)
Parameters:

flag (Xmlb.BuilderNodeFlags) – a Xmlb.BuilderNodeFlags

Adds a flag to the builder node.

New in version 0.1.0.

add_token(token)
Parameters:

token (str) – a new token

Adds a token to the builder node.

New in version 0.3.1.

depth()
Return type:

int

Gets the depth of the node tree, where 0 is the root node.

New in version 0.1.1.

export(flags)
Parameters:

flags (Xmlb.NodeExportFlags) – some Xmlb.NodeExportFlags, e.g. Xmlb.NodeExportFlags.NONE

Raises:

GLib.Error

Returns:

XML data, or None for an error

Return type:

str

Exports the node to XML.

New in version 0.1.5.

get_attr(name)
Parameters:

name (str) – attribute name, e.g. type

Returns:

string, or None if unset

Return type:

str

Gets an attribute from the builder node.

New in version 0.1.0.

get_attr_as_uint(name)
Parameters:

name (str) – attribute name, e.g. priority

Returns:

integer, or 0 if unset

Return type:

int

Gets an attribute from the builder node.

New in version 0.1.3.

get_child(element, text)
Parameters:
  • element (str) – An element name, e.g. “url”

  • text (str or None) – node text, e.g. “gimp.desktop”

Returns:

a new Xmlb.BuilderNode, or None if not found

Return type:

Xmlb.BuilderNode

Finds a child builder node by the element name, and optionally text value.

New in version 0.1.1.

get_children()
Returns:

children

Return type:

[Xmlb.BuilderNode]

Gets the children of the builder node.

New in version 0.1.0.

get_element()
Returns:

string, or None if unset

Return type:

str

Gets the element from the builder node.

New in version 0.1.0.

get_first_child()
Returns:

a Xmlb.BuilderNode, or None

Return type:

Xmlb.BuilderNode

Gets the first child of the builder node.

New in version 0.1.12.

get_last_child()
Returns:

a Xmlb.BuilderNode, or None

Return type:

Xmlb.BuilderNode

Gets the last child of the builder node.

New in version 0.1.12.

get_parent()
Returns:

a new Xmlb.BuilderNode, or None no parent exists.

Return type:

Xmlb.BuilderNode

Gets the parent node for the current node.

New in version 0.1.1.

get_tail()
Returns:

string, or None if unset

Return type:

str

Gets the tail from the builder node.

New in version 0.1.12.

get_text()
Returns:

string, or None if unset

Return type:

str

Gets the text from the builder node.

New in version 0.1.0.

get_text_as_uint()
Returns:

integer, or 0 if unset

Return type:

int

Gets the text from the builder node.

New in version 0.1.3.

get_tokens()
Returns:

tokens

Return type:

[str] or None

Gets the tokens of the builder node.

New in version 0.3.1.

has_flag(flag)
Parameters:

flag (Xmlb.BuilderNodeFlags) – a Xmlb.BuilderNodeFlags

Returns:

True if flag is set

Return type:

bool

Checks a flag on the builder node.

New in version 0.1.0.

remove_attr(name)
Parameters:

name (str) – attribute name, e.g. type

Removes an attribute from the builder node.

New in version 0.1.0.

remove_child(child)
Parameters:

child (Xmlb.BuilderNode) – A Xmlb.BuilderNode

Removes a child builder node.

New in version 0.1.1.

set_attr(name, value)
Parameters:
  • name (str) – attribute name, e.g. type

  • value (str) – attribute value, e.g. desktop

Adds an attribute to the builder node.

New in version 0.1.0.

set_element(element)
Parameters:

element (str) – a string element

Sets the element name on the builder node.

New in version 0.1.0.

set_tail(tail, tail_len)
Parameters:
  • tail (str or None) – a string

  • tail_len (int) – length of tail, or -1 if tail is NUL terminated

Sets the tail on the builder node.

New in version 0.1.12.

set_text(text, text_len)
Parameters:
  • text (str or None) – a string

  • text_len (int) – length of text, or -1 if text is NUL terminated

Sets the text on the builder node.

New in version 0.1.0.

sort_children(func, *user_data)
Parameters:

Sorts the node children using a custom sort function.

New in version 0.1.3.

tokenize_text()

Tokenize text added with Xmlb.BuilderNode.set_text().

When searching, libxmlb often has to tokenize strings before they can be compared. This is done in the “fast path” and makes searching for non-ASCII text much slower.

Adding the tokens to the deduplicated string table allows much faster searching at the expense of a ~5% size increase of the silo.

This function adds all valid UTF-8 and ASCII search words generated from the value of Xmlb.BuilderNode.set_text().

The transliteration locale (e.g. en_GB) is read from the xml:lang node attribute if set.

New in version 0.3.1.

traverse(order, flags, max_depth, func, *user_data)
Parameters:

Traverses a tree starting from self. It calls the given function for each node visited.

The traversal can be halted at any point by returning True from func.

New in version 0.1.1.

Unlinks a Xmlb.BuilderNode from a tree, resulting in two separate trees.

This should not be used from the function called by Xmlb.BuilderNode.traverse() otherwise the entire tree will not be traversed.

Instead use Xmlb.BuilderNode.add_flag(bn,:obj:Xmlb.BuilderNodeFlags.IGNORE);

New in version 0.1.1.