def delivered_weighted_energy_stepA(components, fp):
    """Total delivered (or produced) weighted energy entering the assessment boundary in step A

    Energy is weighted depending on its origin (by source or grid).

    This function returns a data structure with keys 'ren' and 'nren' corresponding
    to the renewable and not renewable share of this weighted energy (step A).
    """

    delivered_wenergy_stepA = {'ren': 0.0, 'nren': 0.0}
    fpA = [fpi for fpi in fp if fpi['uso']=='input' and fpi['step']=='A']
    for source in components:
        origins = components[source]
        if 'input' in origins:
            factor_paso_A = [fpi for fpi in fpA if fpi['fuente']==source][0]
            delivered_wenergy_stepA = {'ren': delivered_wenergy_stepA['ren'] + factor_paso_A['ren'] * origins['input'],
                                       'nren': delivered_wenergy_stepA['nren'] + factor_paso_A['nren'] * origins['input'] }
    return delivered_wenergy_stepA