API Reference

Core

class libcomxml.core.Field(name, value=None, attributes=None, rep=None)

Base Field class

Parameters:
  • name – the name of the field super(Cabecera, self).__init__(name, root)
  • value – the value of the field
  • attributes – a dict with optional field attributes
  • rep – function that returns the representation of ‘value’
get_value()

self.__value getter

set_value(value)

self.__value setter

value

self.__value getter

class libcomxml.core.Model(name)

Base Model class

feed(vals)

Populates the vals dictionary to the value property of the fields.

Parameters:vals – a dictionary with key:value pairs for this model’s fields.
sorted_fields()

Returns a sorted list of the model fields’ names.

class libcomxml.core.XmlField(name, value=None, parent=None, attributes=None, rep=None, namespace=None)

Field with XML capabilities

Parameters:
  • name – the name of the field super(Cabecera, self).__init__(name, root)
  • value – the value of the field
  • parent – the parent node
  • attributes – a dict with optional field attributes
  • rep – function that returns the representation of ‘value’
  • namespace – namespace associated with element
element(parent=None)

Constructs the lxml.Element that represents the field

Parameters:parent – an etree Element to be used as parent for this one
class libcomxml.core.XmlModel(name, root, drop_empty=True)

Model with XML capabilities

This class is intended to be subclassed and used as follows:

build_tree()

Bulids the tree with all the fields converted to Elements