def generate_csv_file(self, lang): csvfile = file(self.get_poll_result_file_path('csv', 'csv', lang[0]), "w") if self.module_id == "score": csv_from_score_polls(self.election, [self.poll], lang[0], csvfile) elif self.module_id == "stv": csv_from_stv_polls(self.election, [self.poll], lang[0], csvfile) else: csv_from_polls(self.election, [self.poll], lang[0], csvfile) csvfile.close()
def generate_csv_file(self, lang): csvfile = file(self.get_poll_result_file_path("csv", "csv", lang[0]), "w") if self.module_id == "score": csv_from_score_polls(self.election, [self.poll], lang[0], csvfile) elif self.module_id == "stv": csv_from_stv_polls(self.election, [self.poll], lang[0], csvfile) else: csv_from_polls(self.election, [self.poll], lang[0], csvfile) csvfile.close()
def generate_csv_file(self, lang): with open(self.get_poll_result_file_path('csv', 'csv', lang[0]), "w") as f: if self.module_id == "score": csv_from_score_polls(self.election, [self.poll], lang[0], f) elif self.module_id == "stv": csv_from_stv_polls(self.election, [self.poll], lang[0], f) else: csv_from_polls(self.election, [self.poll], lang[0], f)
def generate_election_csv_file(self, lang): csvpath = self.get_election_result_file_path('csv', 'csv', lang[0]) csvfile = file(self.get_election_result_file_path('csv', 'csv', lang[0]), "w") if self.module_id == "score": csv_from_score_polls(self.election, self.election.polls.all(),\ lang[0], csvfile) elif self.module_id == "stv": csv_from_stv_polls(self.election, self.election.polls.all(),\ lang[0], csvfile) else: csv_from_polls(self.election, self.election.polls.all(),\ lang[0], csvfile) csvfile.close()
def test_csv_writer(self): from zeus.reports import csv_from_polls from StringIO import StringIO buffer = StringIO() for char in ["=", "+", "-", "@"]: election, polls = self.make_election({ 'name': '%sINJECTION()' % char }) csv_from_polls(election, polls, "el", buffer) # injection escaped with ' self.assertTrue(",'%sINJECTION" % char in buffer.getvalue())