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._intialize_values()
 
  17     def _intialize_values(self):
 
  19             Set all counts for the global
 
  22         self.tables_created = 0
 
  23         self.tables_deleted = 0
 
  24         self.tables_ignored = 0
 
  27     def notify_one_phrase_invalid(self):
 
  29             Add +1 to the count of invalid entries
 
  30             fetched from the wiki.
 
  34     def notify_one_table_created(self):
 
  36             Add +1 to the count of created tables.
 
  38         self.tables_created += 1
 
  40     def notify_one_table_deleted(self):
 
  42             Add +1 to the count of deleted tables.
 
  44         self.tables_deleted += 1
 
  46     def notify_one_table_ignored(self):
 
  48             Add +1 to the count of ignored tables.
 
  50         self.tables_ignored += 1
 
  52     def notify_import_done(self):
 
  54             Print stats for the whole import process
 
  57         LOG.info('====================================================================')
 
  58         LOG.info('Final statistics of the import:')
 
  59         LOG.info('- %s phrases were invalid.', self.invalids)
 
  61             LOG.info('  Those invalid phrases have been skipped.')
 
  62         LOG.info('- %s tables were ignored as they already exist on the database',
 
  64         LOG.info('- %s tables were created', self.tables_created)
 
  65         LOG.info('- %s tables were deleted from the database', self.tables_deleted)
 
  66         if self.tables_deleted > 0:
 
  67             LOG.info('  They were deleted as they are not valid anymore.')
 
  70             LOG.warning('%s phrases were invalid and have been skipped during the whole process.',
 
  73         self._intialize_values()