Commit 5a833c7b authored by Nicolas Joyard's avatar Nicolas Joyard

Remove unused cache from parltrack import

parent c622f421
......@@ -185,9 +185,7 @@ class ParltrackImporter(GenericImporter):
)
def add_mandates(self, representative, mep_json):
def get_or_create_mandate(mandate_data, representative, group,
constituency):
def create_mandate(mandate_data, representative, group, constituency):
if mandate_data.get("start"):
begin_date = _parse_date(mandate_data.get("start"))
if mandate_data.get("end"):
......@@ -206,7 +204,6 @@ class ParltrackImporter(GenericImporter):
if _:
logger.debug('Created mandate %s with %s', mandate.pk,
mandate_data)
return mandate
# Committee
for mandate_data in mep_json.get('Committees', []):
......@@ -216,10 +213,8 @@ class ParltrackImporter(GenericImporter):
kind='committee', name=mandate_data['Organization'],
chamber=self.ep_chamber)
self.mep_cache['committees'].append(
get_or_create_mandate(mandate_data, representative,
group, self.ep_constituency)
)
create_mandate(mandate_data, representative, group,
self.ep_constituency)
# Delegations
for mandate_data in mep_json.get('Delegations', []):
......@@ -229,10 +224,8 @@ class ParltrackImporter(GenericImporter):
chamber=self.ep_chamber
)
self.mep_cache['delegations'].append(
get_or_create_mandate(mandate_data, representative, group,
self.ep_constituency)
)
create_mandate(mandate_data, representative, group,
self.ep_constituency)
# Group
convert = {
......@@ -258,10 +251,8 @@ class ParltrackImporter(GenericImporter):
chamber=self.ep_chamber
)
self.mep_cache['groups'].append(
get_or_create_mandate(mandate_data, representative, group,
self.ep_constituency)
)
create_mandate(mandate_data, representative, group,
self.ep_constituency)
# Countries
for mandate_data in mep_json.get('Constituencies', []):
......@@ -296,15 +287,10 @@ class ParltrackImporter(GenericImporter):
if save_constituency:
constituency.save()
self.mep_cache['constituencies'].append(
get_or_create_mandate(mandate_data, representative, group,
constituency)
)
create_mandate(mandate_data, representative, group, constituency)
self.mep_cache['chambers'].append(
get_or_create_mandate(mandate_data, representative,
self.ep_group, self.ep_constituency)
)
create_mandate(mandate_data, representative, self.ep_group,
self.ep_constituency)
# Organisations
for mandate_data in mep_json.get('Staff', []):
......@@ -315,10 +301,8 @@ class ParltrackImporter(GenericImporter):
name=mandate_data['Organization']
)
self.mep_cache['staff'].append(
get_or_create_mandate(mandate_data, representative, group,
self.ep_constituency)
)
create_mandate(mandate_data, representative, group,
self.ep_constituency)
def add_contacts(self, representative, mep_json):
# Addresses
......@@ -400,8 +384,6 @@ def main(stream=None):
GenericImporter.pre_import(importer)
for data in ijson.items(stream or sys.stdin, 'item'):
importer.mep_cache = dict(staff=[], constituencies=[], chambers=[],
committees=[], groups=[], delegations=[])
importer.manage_mep(data)
# Commenting for now, it's a bit dangerous, if a json file was corrupt it
# would drop valid data !
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment