A chemical model of the variable oxygen content of YBa2Cu3O7−y