Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)