Fixed otherFeild lambda func not being used

This commit is contained in:
Cal.W 2020-06-28 22:33:03 +10:00
parent 9284a55825
commit 6280533b39

View File

@ -127,8 +127,8 @@ def calculateStats(transactions, yearRangeVal=None, monthRangeVal=None, otherFel
if isinstance(monthRangeVal, list) or isinstance(monthRangeVal, tuple): monthRange = lambda x: x[1].month in monthRangeVal
if isinstance(monthRangeVal, int) or isinstance(monthRangeVal, float): monthRange = lambda x: x[1].month == int(monthRangeVal)
if not isinstance(yearRangeVal, type(monthRange)): otherFelid = lambda x: True
if not isinstance(otherFelid, type(monthRange)): otherFelid = lambda x: True
periodTransactions = [x for x in transactions if yearRange(x) and monthRange(x) and otherFelid(x)]
periodTransactions = sorted(periodTransactions, reverse = True, key = lambda x: x[1])
@ -163,7 +163,8 @@ import pprint
if __name__ == "__main__":
trans = loadTransactionData()
stats = calculateStats(trans, 2020, 1)
y = lambda x: x[-2] == TRANSACTION_TYPES[1]
stats = calculateStats(trans, 2020, 1, y)
pprint.pprint(stats, indent=4)
#calculateStats(trans)