From 7c61cae41791301ed49bc84903ee7dee55a61fe9 Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 1 Sep 2022 15:41:21 +0300 Subject: [PATCH] csv_metadata_quality/fix.py: silence warning By default country_converter prints "not found in regex" if a coun- try is not found. We can silence this by switching the logging lev- el to something above WARNING. --- csv_metadata_quality/fix.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/csv_metadata_quality/fix.py b/csv_metadata_quality/fix.py index 00aa6e7..8cca992 100755 --- a/csv_metadata_quality/fix.py +++ b/csv_metadata_quality/fix.py @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-3.0-only +import logging import re from unicodedata import normalize @@ -313,6 +314,10 @@ def countries_match_regions(row): # because we don't need to re-load the country data with each iteration. cc = coco.CountryConverter() + # Set logging to ERROR so country_converter's convert() doesn't print the + # "not found in regex" warning message to the screen. + logging.basicConfig(level=logging.ERROR) + # Iterate over the labels of the current row's values to get the names of # the title and citation columns. Then we check if the title is present in # the citation.