def raise_on_errorevent(context, events): binevents = list() for ev, item in events: yield ev, item binevents.append((ev, item)) if ev is ERROREVENT: e = item['exception'] msg = 'can\'t parse %s' % item['type'] pe = ParseError(msg) pe.cause = e pe.path = context.get('path') pe.treegroup = context.get('treegroup') pe.record = context.get('record') pe.offset = item.get('bin_offset') pe.binevents = binevents raise pe
def read_type_events(type, context, stream): resolve_values = resolve_values_from_stream(stream) events = resolve_type_events(type, context, resolve_values) for ev, item in events: yield ev, item if ev is ERROREVENT: from hwp5.dataio import ParseError e = item['exception'] msg = 'can\'t parse %s' % type pe = ParseError(msg) pe.cause = e pe.path = context.get('path') pe.treegroup = context.get('treegroup') pe.record = context.get('record') pe.offset = item.get('bin_offset') raise pe