.. _aggrdef-py: ########## aggrdef.py ########## aggrdef test definitions:: >>> from lxml import etree >>> import datetime >>> from pprint import pprint >>> from simo.builder.output.aggrdef import AggregationOutputDef >>> tdf = open('../../simulator/xml/schemas/Typedefs_SIMO.xsd') >>> typedef = tdf.read() >>> tdf.close() >>> sf = open('../../simulator/xml/schemas/report_definition.xsd') >>> schema = sf.read() >>> sf.close() >>> xml = ''' ... ... 2009-01-01 ... 3.0 ... ... ... 5 ... year ... ... ... ... ... sum[0:99](stratum:SP*stratum:HgM) ... true ... ... ... stratum ... HgM ... ... ... stratum ... DgM ... ... ... ... ... sum[0:99](operation:Volume) ... false ... ... ... ''' ************************************** class AggregationOutputDef(XmlObject): ************************************** Aggregation output definitions. def __init__(self, typedef): ============================ :: >>> aodef = AggregationOutputDef(typedef) >>> aodef.schema = schema >>> aodef.xml = ('test data', xml, None) ******************************** class AggregationOutput(object): ******************************** Aggregationoutput info. def __init__(self, ns, root, validator): ======================================== :: >>> ao = aodef.obj['test data'] >>> pprint(ao.data) # doctest: +NORMALIZE_WHITESPACE {'discount_rate': 3.0, 'initial_date': datetime.date(2009, 1, 1), 'reporting_periods': [{'length': '5', 'unit': 'year'}], 'reporting_variables': [{'expression': 'sum[0:99](stratum:SP*stratum:HgM)', 'grouping': {'stratum': ['HgM', 'DgM']}, 'proportion': True}, {'expression': 'sum[0:99](operation:Volume)', 'grouping': {}, 'proportion': False}]} def _parse(self, root): ======================= Parses the agregation output instructions into self.data