flap.flap_xml

Created on Mon Jul 30 15:13:45 2018

XML file handling for FLAP.

@author: Sandor Zoletnik (zoletnik.sandor@ek-cer.hu) Centre for Energy Research

class flap.flap_xml.FlapXml

Bases: object

Class for creating XML files.

add_element(section=None, element=None, value=None, unit=None, comment=None, value_type=None)

Add an element to the XML tree.

Parameters:
sectionstr, optional, default=None

Section to add the element to.

elementstr, optional

Name of the element to be added.

valueint | float | str, optional, default=None

Value associated to the element.

unitstr, optional, default=None

Unit of the given value.

commentstr, optional, default=None

Comment to add to element.

value_typestr, optional, default=None

Type of the given value.

create_head(head_name='FLAPXml', attrib=None)

Create head (root) element.

Parameters:
head_namestr, optional, default=’FLAPXml’

Name of head (root) element.

attribdict, optional, default=None

Additional attributes to add.

get_element(section, element)

Get an element of the XML tree.

Parameters:
sectionstr

Section to search element in.

elementstr

Element to search for.

Returns:
dict

The attributes of element.

read_file(filename)

Read XML file into the object.

Parameters:
filenamestr

Name of the file to read from.

write_file(filename)

Write the XML tree to a file.

Parameters:
filenamestr

Name of the file to save to.

flap.flap_xml.test_read()

Test XML read.

Reads a file named ‘xx.xml’.

flap.flap_xml.test_write()

Test XML write.

Creates a file named ‘xx.xml’.