Whoops - Fix switchDateRange arguments, Add =None to all (primary) function arguments

I had the arguments for switchDateRange reversed, dateRange should be the second argument
Now our error checking ifs at the beginning of the main functions will detect if they're None and the Interperter shouldn't trackback when neglecting to add arguments
This commit is contained in:
David Todd 2016-03-25 14:14:35 -05:00
parent 5bd3f0b85b
commit b9d65b7d64
No known key found for this signature in database
GPG Key ID: 48E847F18074C953

20
ebay.py
View File

@ -73,7 +73,7 @@ def setDateRange(days=None, start=None, rangeType=None):
return {'from': today, 'to': future, 'type': rangeType} return {'from': today, 'to': future, 'type': rangeType}
# We call this a couple times, so it gets its own function # We call this a couple times, so it gets its own function
def switchDateRange(range=None, list=None): def switchDateRange(list=None, range=None):
# Switch statement to check which type of dateRange to search by # Switch statement to check which type of dateRange to search by
# This can be start/mod/end # This can be start/mod/end
def rangeType(condition): def rangeType(condition):
@ -122,7 +122,7 @@ def switchDateRange(range=None, list=None):
# minor logic checking - We don't want to get trackbacks for silly reasons # minor logic checking - We don't want to get trackbacks for silly reasons
# getSeller gets a list of our itemIDs # getSeller gets a list of our itemIDs
def getSeller(api, list): def getSeller(api=None, list=None):
# api is the connection to the Trading API # api is the connection to the Trading API
# list is a dict containing required information for ebay to search for (http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/GetSellerEvents.html) # list is a dict containing required information for ebay to search for (http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/GetSellerEvents.html)
# - The datapoints that MUST be defined are EndTimeFrom and EndTimeTo - These select the dateRange that items end on ebay # - The datapoints that MUST be defined are EndTimeFrom and EndTimeTo - These select the dateRange that items end on ebay
@ -173,7 +173,7 @@ def getSeller(api, list):
return res return res
# getItems uses the list of ItemIDs provided by getSeller to get specific information about each ItemID # getItems uses the list of ItemIDs provided by getSeller to get specific information about each ItemID
def getItems(api, itemList, itemArgs={}): def getItems(api=None, itemList=None, itemArgs=None):
# api is the connection to the Trading API # api is the connection to the Trading API
# itemList is a dict containing ItemIDs and other info as a result of getSeller # itemList is a dict containing ItemIDs and other info as a result of getSeller
# itemArgs is an optional dict that contains extra details to refine the search returned by ebay (http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/GetItem.html) # itemArgs is an optional dict that contains extra details to refine the search returned by ebay (http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/GetItem.html)
@ -219,7 +219,7 @@ def getItems(api, itemList, itemArgs={}):
# Use the modTime range and only return data for items that have been modified in the timerange # Use the modTime range and only return data for items that have been modified in the timerange
# Args we want are the modTime and NewItemFilter=True to get only items that have changed in this timerange # Args we want are the modTime and NewItemFilter=True to get only items that have changed in this timerange
def checkRevisedItems(api, itemArgs={}, dateRange={}): def checkRevisedItems(api=None, itemArgs=None, dateRange=None):
# api is the connection to the Trading API # api is the connection to the Trading API
# itemList is a list containing itemIDs to check for updates # itemList is a list containing itemIDs to check for updates
# itemArgs is an optional dict that contains extra details to refine the search returned by ebay # itemArgs is an optional dict that contains extra details to refine the search returned by ebay
@ -228,14 +228,14 @@ def checkRevisedItems(api, itemArgs={}, dateRange={}):
res['error']['code'] = '1' res['error']['code'] = '1'
res['error']['msg'] = 'api is not set' res['error']['msg'] = 'api is not set'
return res return res
if (itemList == None) | (isinstance(itemList, dict) != True):
res['error']['code'] = '2'
res['error']['msg'] = 'itemList doesn\'t exist or is of wrong type, must be list containing one or more dicts'
return res
if (itemArgs == None) | (isinstance(itemArgs, dict) != True): if (itemArgs == None) | (isinstance(itemArgs, dict) != True):
res['error']['code'] = '2' res['error']['code'] = '2'
res['error']['msg'] = 'itemArgs doesn\'t exist or is of wrong type, must be dict' res['error']['msg'] = 'itemArgs doesn\'t exist or is of wrong type, must be dict'
return res return res
if (dateRange == None) | (isinstance(dateRange, dict) != True):
res['error']['code'] = '2'
res['error']['msg'] = 'dateRange doesn\'t exist or is of wrong type, must be dict'
return res
itemArgs['NewItemFilter'] = 'True' itemArgs['NewItemFilter'] = 'True'
@ -249,7 +249,7 @@ def checkRevisedItems(api, itemArgs={}, dateRange={}):
# storeItems uses the dict of Items provided by getItems and stores the information we want # storeItems uses the dict of Items provided by getItems and stores the information we want
def storeItems(itemList): def storeItems(itemList=None):
# itemList is the apiRequest value presented as a result of getItems # itemList is the apiRequest value presented as a result of getItems
# - This contains every item that matches getItems criteria with the ItemID as the key of further dicts # - This contains every item that matches getItems criteria with the ItemID as the key of further dicts
@ -337,7 +337,7 @@ def storeItems(itemList):
return res return res
# Glue logic to run all the functions above properly # Glue logic to run all the functions above properly
def glue(api=None, sellerList={}, dateRange={}): def glue(api=None, sellerList=None, dateRange=None):
# api is the connection to the api, this is passed to the functions as called # api is the connection to the api, this is passed to the functions as called
# sellerList is the options that you can present ebay for searching (http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/GetSellerEvents.html) # sellerList is the options that you can present ebay for searching (http://developer.ebay.com/DevZone/XML/docs/Reference/ebay/GetSellerEvents.html)
# dateRange overrides EndTimeFrom and EndTimeTo from sellerList for ease of passing these required data with nothing else # dateRange overrides EndTimeFrom and EndTimeTo from sellerList for ease of passing these required data with nothing else