The dum module define a set of function to generate python objects from the projection of data structured in xml, json or csv.
The Node protocol must be defined by the classes that host the result of the data projection.
A class complying to the Node protocol must accept an empty constructor and define :
- class dum
This static class is used as a namespace to store the projection fields.
The dum class can also define the following attributes:
- dum_projection()¶
This optional method is called when the closing tag is parsed. Define it to return an alternative object (masquerade) or to perform some post parsing process. In the second case the method should return self.
returned by converter functions when a value should be ignored
All child elements corresponding to name1,name2... should be collected in the same list after being interpreted by type1, type2... converter. You can give a dictionary as first argument if some child name are not valid Python identifiers. The group fields are only used for Xml parsing.
Use these decorator when you need to define a function to convert values. The form without argument is optional : you can use raw function as well.
| Parameters: |
|
|---|
When you need converter to be applied on a collection of values
| Parameters: | source – xPath string for locating value in input data |
|---|
Parse the xml file stored in the file descriptor fd, an project it’s root element into the Node class.
| Parameters: |
|
|---|---|
| Returns: | Node instance initialized from xml root element. |
Parse the xml present in text string.
| Parameters: |
|
|---|---|
| Returns: | Node instance initialized from xml root element. |
Project object root element into the Node class; object may come from json.load function.
| Parameters: |
|
|---|---|
| Returns: | Node instance initialized from object. |
Parse and project tabulated data from iterator into the Node class. The iterator object may come from csv.reader
| Parameters: |
|
|---|---|
| Returns: | a generator of Node instances initialized from input rows values. |