# coding: utf-8
from utils import CanadianJurisdiction
from opencivicdata.divisions import Division
from pupa.scrape import Organization

from datetime import datetime


class Canada(CanadianJurisdiction):
    classification = 'legislature'
    division_id = 'ocd-division/country:ca'
    division_name = 'Canada'
    name = 'Parliament of Canada'
    url = 'http://www.parl.gc.ca'
    parties = [
        {'name': 'Bloc Québécois'},
        {'name': 'Co-operative Commonwealth Federation'},
        {'name': 'Conservative'},
        {'name': 'Conservative Independent'},
        {'name': 'Forces et Démocratie'},
        {'name': 'Green Party'},
        {'name': 'Groupe parlementaire québécois'},
        {'name': 'Independent'},
        {'name': 'Liberal'},
        {'name': 'NDP'},
    ]

    def get_organizations(self):
        parliament = Organization(self.name, classification=self.classification)
        yield parliament

        upper = Organization('Senate', classification='upper', parent_id=parliament)
        lower = Organization('House of Commons', classification='lower', parent_id=parliament)

        for division in Division.get(self.division_id).children('ed'):
            if division.attrs.get('validFrom') and division.attrs['validFrom'] <= datetime.now().strftime('%Y-%m-%d'):
                lower.add_post(role='MP', label=division.name, division_id=division.id)

        yield upper
        yield lower

@@ -775,24 +775,59 @@
 e': 'NDP'%7D,%0A
+        %7B'name': 'Qu%C3%A9bec debout'%7D,%0A
     %5D%0A%0A    d

Add party