Use logging.warning() instead of deprecated logging.warn().

This commit is contained in:
Chris Berkhout 2021-08-01 14:04:04 +02:00
parent de4a8f2227
commit 3218338bff
2 changed files with 7 additions and 5 deletions

View file

@ -6,7 +6,7 @@ from pricehist import exceptions
def fetch(series, source, output, invert: bool, quantize: int, fmt) -> str: def fetch(series, source, output, invert: bool, quantize: int, fmt) -> str:
if series.start < source.start(): if series.start < source.start():
logging.warn( logging.warning(
f"The start date {series.start} preceeds the {source.name()} " f"The start date {series.start} preceeds the {source.name()} "
f"source start date of {source.start()}." f"source start date of {source.start()}."
) )
@ -15,7 +15,9 @@ def fetch(series, source, output, invert: bool, quantize: int, fmt) -> str:
series = source.fetch(series) series = source.fetch(series)
if len(series.prices) == 0: if len(series.prices) == 0:
logging.warn(f"No data found for the interval [{series.start}--{series.end}].") logging.warning(
f"No data found for the interval [{series.start}--{series.end}]."
)
else: else:
first = series.prices[0].date first = series.prices[0].date
last = series.prices[-1].date last = series.prices[-1].date
@ -28,7 +30,7 @@ def fetch(series, source, output, invert: bool, quantize: int, fmt) -> str:
if first == series.start and last == expected_end: if first == series.start and last == expected_end:
logging.debug(message) # Missing today's price is expected logging.debug(message) # Missing today's price is expected
else: else:
logging.warn(message) logging.warning(message)
if invert: if invert:
series = series.invert() series = series.invert()

View file

@ -110,7 +110,7 @@ class GnuCashSQL(BaseOutput):
if too_big: if too_big:
# https://code.gnucash.org/docs/MAINT/group__Numeric.html # https://code.gnucash.org/docs/MAINT/group__Numeric.html
# https://code.gnucash.org/docs/MAINT/structgnc__price__s.html # https://code.gnucash.org/docs/MAINT/structgnc__price__s.html
logging.warn( logging.warning(
"This SQL contains numbers outside of the int64 range required " "This SQL contains numbers outside of the int64 range required "
"by GnuCash for the numerators and denominators of prices. " "by GnuCash for the numerators and denominators of prices. "
"Using the --quantize option to limit the number of decimal " "Using the --quantize option to limit the number of decimal "
@ -132,7 +132,7 @@ class GnuCashSQL(BaseOutput):
def _warn_about_backslashes(self, fields): def _warn_about_backslashes(self, fields):
hits = [name for name, value in fields.items() if "\\" in value] hits = [name for name, value in fields.items() if "\\" in value]
if hits: if hits:
logging.warn( logging.warning(
f"Before running this SQL, check the formatting of the " f"Before running this SQL, check the formatting of the "
f"{self._english_join(hits)} strings. " f"{self._english_join(hits)} strings. "
f"SQLite treats backslahes in strings as plain characters, but " f"SQLite treats backslahes in strings as plain characters, but "