forked from opencivicdata/scrapers-ca
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
42 lines (35 loc) · 1.47 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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'},
{'name': "People's Party"},
{'name': 'Québec debout'},
]
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