Skip to content

Commit

Permalink
added datetime as int
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Jan 3, 2017
1 parent d248e90 commit 50e0776
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 6 additions & 5 deletions keepaAPI/Interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def ProductQuery(asins, settings):
if settings['history']:
for product in response['products']:
if product['csv']: # if data exists
product['data'] = ParseCSV(product['csv'])
product['data'] = ParseCSV(product['csv'], settings['to_datetime'])
del product['csv']

return response
Expand All @@ -261,7 +261,7 @@ def ProductQuery(asins, settings):
raise Exception('REQUEST_FAILED')


def ParseCSV(csv):
def ParseCSV(csv, to_datetime):
"""
Parses csv list from keepa into a python dictionary
Expand Down Expand Up @@ -302,7 +302,7 @@ def ParseCSV(csv):
key = index[1]

# Data goes [time0, value0, time1, value1, ...]
product_data[key + '_time'] = keepaTime.KeepaMinutesToTime(csv[ind][::2])
product_data[key + '_time'] = keepaTime.KeepaMinutesToTime(csv[ind][::2], to_datetime)

# Convert to float price if applicable
if index[2]:
Expand Down Expand Up @@ -372,7 +372,7 @@ def WaitForTokens(self, updatetype='server'):


def ProductQuery(self, asins, domain='US', history=True, offers=False,
update=None, nthreads=4):
update=None, nthreads=4, to_datetime=True):
"""
Performs a product query of a list, array, or single ASIN. Returns a
list of product data with one entry for each product.
Expand Down Expand Up @@ -426,7 +426,8 @@ def ProductQuery(self, asins, domain='US', history=True, offers=False,
'accesskey': self.accesskey,
'offers': offers,
'update': None,
'history': history}
'history': history,
'to_datetime': to_datetime}

# Report time to completion
tcomplete = float(nitems - self.user.RemainingTokens())/self.user.status['refillRate'] - (60000 - self.user.status['refillIn'])/60000.0
Expand Down
2 changes: 2 additions & 0 deletions keepaAPI/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
__version__ = '0.12'


0 comments on commit 50e0776

Please sign in to comment.