Local electronic structure of Cu2O, CuO and YBa2Cu3O7−δ