]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/tools/special_phrases/importer_statistics.py
Merge pull request #2321 from AntoJvlt/csv-import-special-phrases
[nominatim.git] / nominatim / tools / special_phrases / importer_statistics.py
index 520c77d66592347b1a92e950ee5f09e7cdc167ed..d0b3bbf81fc3300ae59a10000db981427a212833 100644 (file)
@@ -1,5 +1,5 @@
 """
-    Contain the class which handle statistics for the
+    Contains the class which handles statistics for the
     import of special phrases.
 """
 import logging
@@ -12,10 +12,9 @@ class SpecialPhrasesImporterStatistics():
         process of special phrases.
     """
     def __init__(self):
-        self._set_lang_values_to_0()
-        self._set_global_values_to_0()
+        self._intialize_values()
 
-    def _set_global_values_to_0(self):
+    def _intialize_values(self):
         """
             Set all counts for the global
             import to 0.
@@ -23,50 +22,14 @@ class SpecialPhrasesImporterStatistics():
         self.tables_created = 0
         self.tables_deleted = 0
         self.tables_ignored = 0
-        self.global_phrases_invalid = 0
-        self.global_phrases_added = 0
-        self.global_phrases_ignored = 0
-        self.global_phrases_deleted = 0
-
-    def _set_lang_values_to_0(self):
-        """
-            Set all counts for the current
-            lang to 0.
-        """
-        self.lang_phrases_invalid = 0
-        self.lang_phrases_added = 0
-        self.lang_phrases_ignored = 0
+        self.invalids = 0
 
     def notify_one_phrase_invalid(self):
         """
             Add +1 to the count of invalid entries
             fetched from the wiki.
         """
-        self.lang_phrases_invalid += 1
-        self.global_phrases_invalid += 1
-
-    def notify_one_phrase_added(self):
-        """
-            Add +1 to the count of entries
-            added to the db.
-        """
-        self.lang_phrases_added += 1
-        self.global_phrases_added += 1
-
-    def notify_one_phrase_ignored(self):
-        """
-            Add +1 to the count of ignored
-            entries as it was already in the db.
-        """
-        self.lang_phrases_ignored += 1
-        self.global_phrases_ignored += 1
-
-    def notify_one_phrase_deleted(self):
-        """
-            Add +1 to the count of phrases deleted
-            from the database.
-        """
-        self.global_phrases_deleted += 1
+        self.invalids += 1
 
     def notify_one_table_created(self):
         """
@@ -86,45 +49,25 @@ class SpecialPhrasesImporterStatistics():
         """
         self.tables_ignored += 1
 
-
     def notify_import_done(self):
         """
             Print stats for the whole import process
             and reset all values.
         """
-        LOG.warning('====================================================================')
-        LOG.warning('Final statistics of the import:')
-        LOG.warning('- %s phrases were invalid.', self.global_phrases_invalid)
-        if self.global_phrases_invalid > 0:
-            LOG.warning('  Those invalid phrases have been skipped.')
-        LOG.warning('- %s phrases were ignored as they are already in the database',
-                    self.global_phrases_ignored)
-        LOG.warning('- %s phrases were added to the database', self.global_phrases_added)
-        LOG.warning('- %s phrases were deleted from the database', self.global_phrases_deleted)
-        if self.global_phrases_deleted > 0:
-            LOG.warning('  They were deleted as they are not valid anymore.')
-        LOG.warning('- %s tables were ignored as they already exist on the database',
-                    self.tables_ignored)
-        LOG.warning('- %s tables were created', self.tables_created)
-        LOG.warning('- %s tables were deleted from the database', self.tables_deleted)
+        LOG.info('====================================================================')
+        LOG.info('Final statistics of the import:')
+        LOG.info('- %s phrases were invalid.', self.invalids)
+        if self.invalids > 0:
+            LOG.info('  Those invalid phrases have been skipped.')
+        LOG.info('- %s tables were ignored as they already exist on the database',
+                 self.tables_ignored)
+        LOG.info('- %s tables were created', self.tables_created)
+        LOG.info('- %s tables were deleted from the database', self.tables_deleted)
         if self.tables_deleted > 0:
-            LOG.warning('  They were deleted as they are not valid anymore.')
-
-        self._set_global_values_to_0()
+            LOG.info('  They were deleted as they are not valid anymore.')
 
-    def notify_current_lang_done(self, lang):
-        """
-            Print stats for the current lang
-            and then reset lang values.
-        """
-        LOG.warning('====================================================================')
-        LOG.warning('Statistics for the import of %s:', lang)
-        LOG.warning('- %s phrases were invalid.', self.lang_phrases_invalid)
-        if self.lang_phrases_invalid > 0:
-            LOG.warning('  Those invalid phrases have been skipped.')
-        LOG.warning('- %s phrases were ignored as they are already in the database',
-                    self.lang_phrases_ignored)
-        LOG.warning('- %s phrases were added to the database', self.lang_phrases_added)
-        LOG.warning('====================================================================')
+        if self.invalids > 0:
+            LOG.warning('%s phrases were invalid and have been skipped during the whole process.',
+                        self.invalids)
 
-        self._set_lang_values_to_0()
+        self._intialize_values()