diff --git a/representatives_recommendations/contrib/import_data.py b/representatives_recommendations/contrib/import_data.py index 889600d2f0bd54db62d86aaedd81ccf3c48ed706..4d3c3df00f4713d6a03106146d9ec4aed05cfad6 100644 --- a/representatives_recommendations/contrib/import_data.py +++ b/representatives_recommendations/contrib/import_data.py @@ -2,20 +2,44 @@ # flake8: noqa dossier_mappings = { - "Resolution on Anti-Counterfeiting Trade Agreement (ACTA)": - "Resolution on the Anti-Counterfeiting Trade Agreement (ACTA)", + # Patent law: patentability of computer-implemented inventions + "Directive on patentability of \"computer-implemented inventions\" (software patents), 1st reading": + "2002/0047(COD)", + + # Criminal measures aimed at ensuring the enforcement of intellectual property rights + "Criminal measures aimed at ensuring the enforcement of intellectual property rights (IPRED 2), 1st reading": + "2005/0127(COD)", + + # Electronic communications: common regulatory framework for networks and services, access, interconnection and authorisation ['Telecoms Package' (amend. Directives 2002/19/EC, 2002/20/EC and 2002/21/EC)] + "Directives reforming the EU's regulatory framework for electronic communications networks and services (telecoms package), 1st reading": + "2007/0247(COD)", + + "Directives reforming the EU's regulatory framework for electronic communications networks and services (telecoms package), 2nd reading": + "2007/0247(COD)", + + # Cultural industries in Europe "Rapport Bono on cultural industries in Europe": - "Cultural industries in Europe", - "Rapport Gallo on enforcement of intellectual property rights in the internal market": - "Enforcement of intellectual property rights in the internal market", + "2007/2153(INI)", + + # Strengthening security and fundamental freedoms on the Internet "Rapport Lambrinidis on strengthening security and fundamental freedoms on the Internet": - "Strengthening security and fundamental freedoms on the Internet", - "Criminal measures aimed at ensuring the enforcement of intellectual property rights (IPRED 2), 1st reading": - "Criminal measures aimed at ensuring the enforcement of intellectual property rights", - "A7-0204/2012": - "EU/Australia, Canada, Japan, Korea, Mexico, Morocco, New Zealand, Singapore, Switzerland and United States Anti-Counterfeiting Trade Agreement (ACTA)", + "2008/2160(INI)", + + # Enforcement of intellectual property rights in the internal market + "Rapport Gallo on enforcement of intellectual property rights in the internal market": + "2009/2178(INI)", + + # Resolution on the Anti-Counterfeiting Trade Agreement (ACTA) + "Resolution on Anti-Counterfeiting Trade Agreement (ACTA)": + "2010/2935(RSP)", + + # Enhanced cooperation in the area of the creation of unitary patent protection: implementation "A7-0001/2012": - "Enhanced cooperation in the area of the creation of unitary patent protection: implementation" + "2011/0093(COD)", + + # EU/Australia, Canada, Japan, Korea, Mexico, Morocco, New Zealand, Singapore, Switzerland and United States Anti-Counterfeiting Trade Agreement (ACTA) + "A7-0204/2012": + "2011/0167(NLE)", } resolutions = [ diff --git a/representatives_recommendations/contrib/import_recommendations.py b/representatives_recommendations/contrib/import_recommendations.py index 3c77e07eb60ada01a29a3769681143eeb7660185..0031c24d1cab47c9109737729bbbfc3f6e3ecec1 100644 --- a/representatives_recommendations/contrib/import_recommendations.py +++ b/representatives_recommendations/contrib/import_recommendations.py @@ -19,15 +19,17 @@ class RecommendationImporter: self.dossier_cache = {} def get_dossier(self, title): - alt_title = dossier_mappings.get(title, None) - if alt_title is not None: - title = alt_title - dossier = self.dossier_cache.get(title, None) if dossier is None: + ref = dossier_mappings.get(title, None) + if ref is not None: + query = { 'reference':ref } + else: + query = { 'title__iexact': title } + try: - dossier = Dossier.objects.get(title__iexact=title) + dossier = Dossier.objects.get(**query) self.dossier_cache[title] = dossier except Dossier.DoesNotExist: dossier = None @@ -54,13 +56,14 @@ class RecommendationImporter: def import_row(self, row): dossier = self.get_dossier(row['title']) if dossier is None: - logger.warn('Could not find dossier "%s"' % row['title']) + logger.warn('No dossier "%s"' % row['title']) return False proposal = self.get_proposal(dossier, row['part']) if proposal is None: - logger.warn('Could not find proposal "%s" for dossier "%s"' % ( - row['part'], row['title'])) + logger.warn('No proposal "%s" for dossier %s (%d): "%s"' % ( + row['part'].decode('utf-8'), dossier.reference, dossier.pk, + row['title'])) return False weight = int(row['weight']) * int(row['ponderation'])