Now, this logic looks really too similar to the one found in ```openquake.engine.calculators.risk.base.BaseRiskCalculator.export```. What about abstracting it (in the base class, or in a separate function/class)?