2 Contains the class which handles statistics for the
3 import of special phrases.
6 LOG = logging.getLogger()
8 class SpecialPhrasesImporterStatistics():
9 # pylint: disable-msg=too-many-instance-attributes
11 Class handling statistics of the import
12 process of special phrases.
15 self._set_lang_values_to_0()
16 self._set_global_values_to_0()
18 def _set_global_values_to_0(self):
20 Set all counts for the global
23 self.tables_created = 0
24 self.tables_deleted = 0
25 self.tables_ignored = 0
26 self.global_phrases_invalid = 0
28 def _set_lang_values_to_0(self):
30 Set all counts for the current
33 self.lang_phrases_invalid = 0
35 def notify_one_phrase_invalid(self):
37 Add +1 to the count of invalid entries
38 fetched from the wiki.
40 self.lang_phrases_invalid += 1
41 self.global_phrases_invalid += 1
43 def notify_one_table_created(self):
45 Add +1 to the count of created tables.
47 self.tables_created += 1
49 def notify_one_table_deleted(self):
51 Add +1 to the count of deleted tables.
53 self.tables_deleted += 1
55 def notify_one_table_ignored(self):
57 Add +1 to the count of ignored tables.
59 self.tables_ignored += 1
62 def notify_import_done(self):
64 Print stats for the whole import process
67 LOG.info('====================================================================')
68 LOG.info('Final statistics of the import:')
69 LOG.info('- %s phrases were invalid.', self.global_phrases_invalid)
70 if self.global_phrases_invalid > 0:
71 LOG.info(' Those invalid phrases have been skipped.')
72 LOG.info('- %s tables were ignored as they already exist on the database',
74 LOG.info('- %s tables were created', self.tables_created)
75 LOG.info('- %s tables were deleted from the database', self.tables_deleted)
76 if self.tables_deleted > 0:
77 LOG.info(' They were deleted as they are not valid anymore.')
79 if self.global_phrases_invalid > 0:
80 LOG.warning('%s phrases were invalid and have been skipped during the whole process.',
81 self.global_phrases_invalid)
83 self._set_global_values_to_0()
85 def notify_current_lang_done(self, lang):
87 Print stats for the current lang
88 and then reset lang values.
90 LOG.info('====================================================================')
91 LOG.info('Statistics for the import of %s:', lang)
92 LOG.info('- %s phrases were invalid.', self.lang_phrases_invalid)
93 if self.lang_phrases_invalid > 0:
94 LOG.info(' Those invalid phrases have been skipped.')
95 LOG.info('====================================================================')
97 if self.lang_phrases_invalid > 0:
98 LOG.warning('%s phrases were invalid and have been skipped for the import of lang %s.',
99 self.lang_phrases_invalid, lang)
101 self._set_lang_values_to_0()