def process_activity(self, activity_id): """ process a single activity """ from iati.parser.parse_manager import ParseManager parser = ParseManager(self) parser.parse_activity(activity_id)
def process(self, force_reparse=False): """if not self.iati_version: self.update_activities_count()""" if self.iati_version in ['2.01', '2.02', '2.03']: from iati.parser.parse_manager import ParseManager start_datetime = datetime.datetime.now() parser = ParseManager(self, force_reparse=force_reparse) parser.parse_all() self.update_activities_count() if self.activities_count_in_database == \ self.activities_count_in_xml: self.is_parsed = True else: self.is_parsed = False self.date_updated = datetime.datetime.now() time_diff = self.date_updated - start_datetime hours, remainder = divmod(time_diff.seconds, 3600) minutes, seconds = divmod(remainder, 60) def prepend_zero(time_period): if time_period < 10: return '0' + str(time_period) return time_period self.time_to_parse = '%s:%s:%s' % (prepend_zero(hours), prepend_zero(minutes), prepend_zero(seconds)) self.save(process=False)
def setUpClass(self): self.iati_identifier = "NL-KVK-51018586-0666" self.alt_iati_identifier = "NL-KVK-51018586-0667" self.iati_202 = build_xml("2.02", self.iati_identifier) dummy_source = synchroniser_factory.DatasetFactory.create(filetype=2) self.parser_202 = ParseManager(dummy_source, self.iati_202).get_parser() assert (isinstance(self.parser_202, OrgParse_202))
def setUpClass(self): self.iati_identifier = "NL-KVK-51018586-0666" self.alt_iati_identifier = "NL-KVK-51018586-0667" self.iati_202 = build_xml("2.02", self.iati_identifier) dummy_source = IatiXmlSource.objects.get(id=2) self.parser_202 = ParseManager(dummy_source, self.iati_202).get_parser() assert (isinstance(self.parser_202, OrgParse_202))
def process(self, force_reparse=False): from iati.parser.parse_manager import ParseManager start_datetime = datetime.datetime.now() parser = ParseManager(self, force_reparse=force_reparse) parser.parse_all() self.is_parsed = True self.date_updated = datetime.datetime.now() time_diff = self.date_updated - start_datetime hours, remainder = divmod(time_diff.seconds, 3600) minutes, seconds = divmod(remainder, 60) def prepend_zero(time_period): if time_period < 10: return '0' + str(time_period) return time_period self.time_to_parse = '%s:%s:%s' % (prepend_zero(hours), prepend_zero(minutes), prepend_zero(seconds)) self.save(process=False)
def setUpClass(self): # for fixture in self.fixtures: # management.call_command("loaddata", fixture) self.iati_identifier = "NL-KVK-51018586-0666" self.iati_105 = build_xml("1.05", self.iati_identifier) dummy_source = IatiXmlSource.objects.get(id=2) self.parser_105 = ParseManager(dummy_source, self.iati_105).get_parser() assert(isinstance(self.parser_105, OrgParse_105))
def setUpClass(self): # for fixture in self.fixtures: # management.call_command("loaddata", fixture) self.iati_identifier = "NL-KVK-51018586-0666" self.iati_105 = build_xml("1.05", self.iati_identifier) dummy_source = synchroniser_factory.DatasetFactory.create(filetype=2) self.parser_105 = ParseManager(dummy_source, self.iati_105).get_parser() assert (isinstance(self.parser_105, OrgParse_105))
def process(self, force_reparse=False): from iati.parser.parse_manager import ParseManager start_datetime = datetime.datetime.now() parser = ParseManager(self, force_reparse=force_reparse) parser.parse_all() self.is_parsed = True self.date_updated = datetime.datetime.now() time_diff = self.date_updated - start_datetime hours, remainder = divmod(time_diff.seconds, 3600) minutes, seconds = divmod(remainder, 60) def prepend_zero(time_period): if time_period < 10: return '0' + str(time_period) return time_period self.time_to_parse = '%s:%s:%s' % (prepend_zero( hours), prepend_zero(minutes), prepend_zero(seconds)) self.save(process=False)