Skip to content

Commit

Permalink
Hotfix to stats parser (#94)
Browse files Browse the repository at this point in the history
* _parse_stats fix: added stats to ignore to prevent typeerrors.

* version bump
  • Loading branch information
dehidehidehi authored Mar 4, 2021
1 parent e703054 commit 0e1e9e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion keepa/_version.py
Original file line number Diff line number Diff line change
@@ -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))
15 changes: 14 additions & 1 deletion keepa/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0e1e9e9

Please sign in to comment.