From 56169d88a059fe7e2aa05eadefacf2f58e1509d4 Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 9 Sep 2023 21:00:31 -0400 Subject: [PATCH] fstrings and fix deprecation of logger.warn --- sc2reader/factories/plugins/replay.py | 4 ++-- sc2reader/log_utils.py | 2 +- sc2reader/objects.py | 4 ++-- sc2reader/resources.py | 4 ++-- sc2reader/utils.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sc2reader/factories/plugins/replay.py b/sc2reader/factories/plugins/replay.py index 7f645eb..05c424b 100644 --- a/sc2reader/factories/plugins/replay.py +++ b/sc2reader/factories/plugins/replay.py @@ -212,8 +212,8 @@ def SelectionTracker(replay): if error: person.selection_errors += 1 if debug: - logger.warn( - "Error detected in deselection mode {}.".format(event.mask_type) + logger.warning( + f"Error detected in deselection mode {event.mask_type}." ) person.selection = player_selections diff --git a/sc2reader/log_utils.py b/sc2reader/log_utils.py index 3337e34..dc20fe9 100644 --- a/sc2reader/log_utils.py +++ b/sc2reader/log_utils.py @@ -33,7 +33,7 @@ def createLock(self): LEVEL_MAP = dict( DEBUG=logging.DEBUG, INFO=logging.INFO, - WARN=logging.WARN, + WARN=logging.WARNING, ERROR=logging.ERROR, CRITICAL=logging.CRITICAL, ) diff --git a/sc2reader/objects.py b/sc2reader/objects.py index 9a7a0e8..de82cb0 100644 --- a/sc2reader/objects.py +++ b/sc2reader/objects.py @@ -562,7 +562,7 @@ def __init__(self, contents): data = ByteDecoder(contents, endian="LITTLE") magic = data.read_string(4) if magic != "MapI": - self.logger.warn(f"Invalid MapInfo file: {magic}") + self.logger.warning(f"Invalid MapInfo file: {magic}") return #: The map info file format version @@ -773,7 +773,7 @@ def __init__(self, contents): self.enemy_flags = data.read_uint(int(math.ceil(self.enemy_flags_length / 8.0))) if data.length != data.tell(): - self.logger.warn("Not all of the MapInfo file was read!") + self.logger.warning("Not all of the MapInfo file was read!") def __str__(self): return self.map_name diff --git a/sc2reader/resources.py b/sc2reader/resources.py index 924f7bd..3e495c3 100644 --- a/sc2reader/resources.py +++ b/sc2reader/resources.py @@ -552,7 +552,7 @@ def get_team(team_id): if team.result == "Win": self.winner = team else: - self.logger.warn( + self.logger.warning( f"Conflicting results for Team {team.number}: {results}" ) team.result = "Unknown" @@ -1336,7 +1336,7 @@ def load_player_stats(self): ) ) elif stat_id != 83886080: # We know this one is always bad. - self.logger.warn(f"Untranslatable key = {stat_id}") + self.logger.warning(f"Untranslatable key = {stat_id}") # Once we've compiled all the build commands we need to make # sure they are properly sorted for presentation. diff --git a/sc2reader/utils.py b/sc2reader/utils.py index 514ca80..2567895 100644 --- a/sc2reader/utils.py +++ b/sc2reader/utils.py @@ -65,7 +65,7 @@ class Color: def __init__(self, name=None, r=0, g=0, b=0, a=255): if name: if name not in COLOR_CODES_INV: - self.logger.warn("Invalid color name: " + name) + self.logger.warning(f"Invalid color name: {name}") hexstr = COLOR_CODES_INV.get(name, "000000") self.r = int(hexstr[0:2], 16) self.g = int(hexstr[2:4], 16) @@ -78,7 +78,7 @@ def __init__(self, name=None, r=0, g=0, b=0, a=255): self.b = b self.a = a if self.hex not in COLOR_CODES: - self.logger.warn("Invalid color hex value: " + self.hex) + self.logger.warning(f"Invalid color hex value: {self.hex}") self.name = COLOR_CODES.get(self.hex, self.hex) @property