Internal Class Representation
Microparser
Transformer
- class transformer.JSONTransformer[source]
- Bases: - object- JSON transformer class. - Transforms given JSON (text) data into XML format. Data in the first step will be transformed to internal JSON structs and afterwards converted (recursive) to xml. - This class will be inherited by the microparser.Serializer class which provides base members/methods for recursive transformation processing. - _set_json_attribute(key, value)[source]
- Set single json attribute. - Parameters:
- key (str) – attribute key 
- value (mixed) – attribute value (str or dict) 
 
 
 - get_json()[source]
- Return json result. - Returns:
- json result dictionary (json dumped) 
- Return type:
- str 
 
 
Helper
- class helper.Looper(*, payload, function, methods=None)[source]
- Bases: - object- Looper Class. - Provides processing of list of input items (type should be irrelevant, currently set to type string) applied to multiple processing method references (list). - After single item has been processed by multiple methods specified in methods list (e.g. strip), it will be sent to the final processing function. - __init__(*, payload, function, methods=None)[source]
- Loops over payload items. For each item: - applies methods given in methods list. 
- calls function reference given in function argument using item as argument. 
 - Parameters:
- payload (list[str]) – payload list 
- function (str) – function reference for item processing after methods processing 
- methods (list[str]) – list of methods applied to item 
 
- Variables:
- _payload (list[str]) – list of payload items to be processed 
- _function (str) – stored function reference 
- _methods (list[str]) – list of methods applied to payload items 
 
- Example:
 - >>> from microparser import Looper >>> >>> def myfunction(payload): >>> print(payload) >>> >>> payload = 'one,two,three' >>> >>> args = { >>> 'payload': payload.split(','), >>> 'function': myfunction, >>> 'methods': ['strip'] >>> } >>> >>> Looper(**args).process()