From 0e1e9e95cb2b423667e7bc328a78f348daa69a10 Mon Sep 17 00:00:00 2001 From: Kevin Cojean <40899632+kevincojean@users.noreply.github.com> Date: Thu, 4 Mar 2021 16:23:20 +0100 Subject: [PATCH] Hotfix to stats parser (#94) * _parse_stats fix: added stats to ignore to prevent typeerrors. * version bump --- keepa/_version.py | 2 +- keepa/interface.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/keepa/_version.py b/keepa/_version.py index 393369d..91d25ef 100644 --- a/keepa/_version.py +++ b/keepa/_version.py @@ -1,6 +1,6 @@ """Version number for keepa """ # major, minor, patch, -extra -version_info = 1, 2, 0 +version_info = 1, 2, 1 __version__ = '.'.join(map(str, version_info)) diff --git a/keepa/interface.py b/keepa/interface.py index e063491..a9f4a56 100644 --- a/keepa/interface.py +++ b/keepa/interface.py @@ -74,10 +74,23 @@ def _parse_stats(stats, to_datetime): + """Parses *numeric* stats object. There is no need to parse strings or list of strings.\n + Keepa stats object response documentation: https://keepa.com/#!discuss/t/statistics-object/1308""" + + stats_keys_parse_not_required = { + 'buyBoxSellerId', + 'sellerIdsLowestFBA', + 'sellerIdsLowestFBM', + 'buyBoxShippingCountry', + 'buyBoxAvailabilityMessage', + } stats_parsed = {} for stat_key, stat_value in stats.items(): - if isinstance(stat_value, int) and stat_value < 0: # -1 or -2 means not exist. 0 doesn't mean not exist. + if stat_key in stats_keys_parse_not_required: + stat_value = None + + elif isinstance(stat_value, int) and stat_value < 0: # -1 or -2 means not exist. 0 doesn't mean not exist. stat_value = None if stat_value is not None: