module xmlhelper.xmlfilewalk
¶
Short summary¶
module pyrsslocal.xmlhelper.xmlfilewalk
functions related to XML files representing objects
Functions¶
function |
truncated documentation |
---|---|
Iterators on all possible tuple of values taken into a list. Let’s assume you have two rows: |
|
Goes through a XML file, extracts values and put them into a flat file. |
|
Goes through a XML file, extracts values and put them into an iterator. |
|
Goes through a XML file, returns XML content if a condition is verified, the result is put into a stream. … |
|
Goes through a XML file, returns XML content if a condition is verified, the result is an iterator. … |
Documentation¶
functions related to XML files representing objects
- pyrsslocal.xmlhelper.xmlfilewalk._iteration_values(values)¶
Iterators on all possible tuple of values taken into a list. Let’s assume you have two rows:
a1 a2 a3 b1 b2
The function will produce:
a1 b1 a1 b2 a2 b1 a2 b2 a3 b1 a3 b2
The function is used by
table_extraction_from_xml_files_iterator
.- Parameters:
values – list of rows
- Returns:
iterator on rows
- pyrsslocal.xmlhelper.xmlfilewalk.table_extraction_from_xml_files(file, output, fields, log=False, encoding='utf-8', errors=None)¶
Goes through a XML file, extracts values and put them into a flat file.
- Parameters:
file – a file
output – output file, string or file object,
fields – list of fields to get from the XML files
log – do logs if True
errors – sent to function library.function
encoding – encoding
One example for fields:
[ ("tag1/tag2", "all"), ("tag1/tag2/tag3/_", "one"), ... ]
- pyrsslocal.xmlhelper.xmlfilewalk.table_extraction_from_xml_files_iterator(file, fields, log=False, fLOG=None, encoding='utf-8', errors=None)¶
Goes through a XML file, extracts values and put them into an iterator.
- Parameters:
file – a file
fields – list of fields to get from the XML files (see below)
log – do logs if True
fLOG – logging function
errors – sent to function library.function
encoding – encoding
- Returns:
iterator on lines
One example for fields:
[ ("tag1/tag2", "all"), ("tag1/tag2/tag3/_", "one"), ... ]
- pyrsslocal.xmlhelper.xmlfilewalk.xml_filter(file, output, filter_, log=False, xmlformat=True, encoding='utf-8', errors=None)¶
Goes through a XML file, returns XML content if a condition is verified, the result is put into a stream.
- Parameters:
file – a file
output – output file, string or file object
filter – a function which takes a node and returns a boolean
xmlformat – if True, return the xml, otherwise return the node
encoding – encoding
errors – sent to function library.function
log – do logs if True
- pyrsslocal.xmlhelper.xmlfilewalk.xml_filter_iterator(file, filter_=None, log=False, xmlformat=True, fLOG=None, encoding='utf-8', errors=None)¶
Goes through a XML file, returns XML content if a condition is verified, the result is an iterator.
- Parameters:
file – a file
filter – a function which takes a node and returns a boolean, if None, accepts everything
log – do logs if True
xmlformat – if True, return the xml, otherwise return the node
fLOG – logging function
encoding – encoding
errors – sent to function library.function
- Returns:
the xml format or a node depending on thevalue of xmlformat