After 10 months of bickering and failed deals, two inconclusive general elections and some of the most dramatic political upheaval since its return to democracy more than four decades ago, Spain is finally set to have a government again.