def output(self, key, obj): all_disruptions = {} def get_all_disruptions(_, val): if not hasattr(val, 'disruptions'): return disruptions = val.disruptions if not disruptions or not hasattr(disruptions[0], 'uri'): return for d in disruptions: all_disruptions[d.uri] = d utils.walk_protobuf(obj, get_all_disruptions) return [ marshal(d, disruption_marshaller, display_null=False) for d in all_disruptions.values() ]
def output(self, key, obj): all_impacts = {} def get_all_impacts(_, val): if not hasattr(val, 'impacts'): return impacts = val.impacts if not impacts or not hasattr(impacts[0], 'uri'): return for impact in impacts: all_impacts[impact.uri] = impact utils.walk_protobuf(obj, get_all_impacts) return [ marshal(d, disruption_marshaller, display_null=False) for d in all_impacts.values() ]