module xmlhelper.xml_tree_node

Inheritance diagram of pyrsslocal.xmlhelper.xml_tree_node

Short summary

module pyrsslocal.xmlhelper.xml_tree_node

parsing XML

source on GitHub

Classes

class

truncated documentation

XMLHandlerDictNode

Defines a node containing a dictionary.

Methods

method

truncated documentation

__cmp__

__iadd__

Concatenates every information.

__init__

__lt__

__str__

usual

_adopt_table

Adopts a table built on anoher object.

_build_othercount

Builds _othercount when not present.

_check_

some checking

_collapse

Collapses together all fields having the same name in the member other.

_convert_into_list

Converts all types into lists.

_guess_type

Replaces all values in the object.

_log_error

logs an object from the root if not already done

_transfer_to_object

Transfers values to the object self.table.

add_xml_content

Adds the content of the node itself (and all included nodes).

apply_change_names

private: change names attributes.

copy

Gets a copy.

enumerate_on_tag

Enumerates all nodes sharing the same name: tag.

find_node

find_node_regex

Finds all nodes depending on a regular expression.

find_node_value

get_full_name

get_root

get_values

Gets all values associated to a given field name.

get_values_group

Gets all values associated to a list of fields (must come together in a single node, not in self.other).

get_xml_content

get_xml_output

iadd

Concatenates every information.

is_text_only

Returns True if it only contains text.

iterfields

Iterator on the nodes.

rearrange

Moves all objects to other.

set

Changes the value of a field.

strip

Strips the buffer.

Documentation

parsing XML

source on GitHub

class pyrsslocal.xmlhelper.xml_tree_node.XMLHandlerDictNode(father, name, level, root=False)[source]

Bases: dict

Defines a node containing a dictionary.

attribute

meaning

father

ancestor

name

name of the section (tag)

buffer

value or content of the section

level

level in the hierarchy

other

included sections

source on GitHub

Parameters
  • father – father

  • name – node name

  • level – could be infered but still

  • root – is it the root

source on GitHub

__cmp__(other)[source]
__iadd__(other)[source]

Concatenates every information.

Parameters

other – other value to concatenate

Returns

self

source on GitHub

__init__(father, name, level, root=False)[source]
Parameters
  • father – father

  • name – node name

  • level – could be infered but still

  • root – is it the root

source on GitHub

__lt__(other)[source]

Return self<value.

__str__()[source]

usual

source on GitHub

_adopt_table(tbl, exception)[source]

Adopts a table built on anoher object.

Parameters
  • tbl – same kind of node but including members: - table - conversion_table

  • exception – if True, raises an exception, log otherwise

Warning

The method could change the object itself if it does not fit.

Warning

The method adds members ‘conversion_table’, ‘add_root_id’

source on GitHub

_build_othercount()[source]

Builds _othercount when not present.

source on GitHub

_check_(add_root_id)[source]

some checking

source on GitHub

_collapse(use_list)[source]

Collapses together all fields having the same name in the member other.

Warning

it should be called after iadd

source on GitHub

_convert_into_list()[source]

Converts all types into lists.

source on GitHub

_guess_type(tolerance=0.01, utf8=False)[source]

Replaces all values in the object.

Parameters
  • toleranceguess_type_list()

  • utf8 – if True, all types are str

Warning

it should be called after _collapse

source on GitHub

_log_error()[source]

logs an object from the root if not already done

source on GitHub

_transfer_to_object(root=True, exception=True)[source]

Transfers values to the object self.table.

Parameters
  • root – if True, it is the root

  • exception – if True, raise Exception

Returns

the value, dictionary of dictionary of list sometimes…

Warning

We assume fid is the key.

Warning

If root.add_root_id is True, is assumes column root_id is root.add_root_id

source on GitHub

add_xml_content(content)[source]

Adds the content of the node itself (and all included nodes).

source on GitHub

apply_change_names(change_names)[source]

private: change names attributes.

Parameters

change_names – { oldname : newname }

source on GitHub

copy()[source]

Gets a copy.

source on GitHub

enumerate_on_tag(tag, recursive=False)[source]

Enumerates all nodes sharing the same name: tag.

Parameters
  • tag – node name to enumerate on

  • recursive – if True, looks into node (name == tag) if there are sub-node with the same name

Returns

enumeration on node

source on GitHub

find_node(li)[source]
Parameters

li – list of names

Returns

a list of nodes which correspond to the list of names

source on GitHub

find_node_regex(regex)[source]

Finds all nodes depending on a regular expression.

Parameters

regex – regular expression

Returns

list of [ (node, value) ]

source on GitHub

find_node_value(li)[source]
Parameters

li – list of names

Returns

a list of values

source on GitHub

get_full_name()[source]
Returns

the list of self.name from all parents

source on GitHub

get_root()[source]
Returns

the root of the node

source on GitHub

get_values(field)[source]

Gets all values associated to a given field name.

Parameters

field – field name

Returns

list of [ key, value ]

source on GitHub

get_values_group(fields, nb=1)[source]

Gets all values associated to a list of fields (must come together in a single node, not in self.other).

Parameters
  • fields – fields name (list or dictionary)

  • nb – at least nb fields must be filled

Returns

list of dictionaries

source on GitHub

get_xml_content()[source]
Returns

self.xmlcontent

source on GitHub

get_xml_output()[source]
Returns

an XML output (all lines terminated by end_of_line

source on GitHub

iadd(other, use_list, collapse)[source]

Concatenates every information.

Parameters
  • other – other value to concatenate

  • use_list – use a list or not

  • collapse – collapse all information

Returns

self

source on GitHub

is_text_only()[source]

Returns True if it only contains text.

source on GitHub

iterfields()[source]

Iterator on the nodes.

source on GitHub

rearrange(debug=False)[source]

Moves all objects to other.

source on GitHub

set(i, v)[source]

Changes the value of a field.

Parameters
  • i – field

  • v – new value

source on GitHub

strip()[source]

Strips the buffer.

source on GitHub