def generateBodyElement(alert, item):

	returnBody = []
	returnBody.append("<p><img src='"+psn.getImage(item)+"'/></p>")
	returnBody.append("<p>"+psn.getName(item)+"</p>")
	returnBody.append("<p>Wished: "+str(alert['price'])+"</p>")
	returnBody.append("<p>Is now: "+str(psn.getPrice(item))+"</p>")

	return "\n".join(returnBody)
def checkWishPrice(cid, store, wishPrice):

    item = psn.getItemForCid(cid, store)
    normalPrice = psn.getPrice(item)
    name = psn.getName(item)

    if (normalPrice > wishPrice):
        utils.print_enc(("Wish price {0:.2f} for '"+name+"' does not yet match {1:.2f}, exiting").format(wishPrice, normalPrice))
        return False
    else:
        utils.print_enc(("Wish price {0:.2f} for '"+name+"' matched. Is now: {1:.2f}").format(wishPrice, normalPrice))
        return True
def formatItems(items):
    cids = []
    foundItems = []

    for item in items:
        try:
            logging.debug("Parsing:\n" + utils.prettyPrintJson(item))
            name = item['name']
            itemType = item['game_contentType']
            cid = item['id']
            price = str(psn.getPrice(item))

            platform = ", ".join(item['playable_platform'])
            foundItems.append((cid + "\t" + name + "\t" + platform + "\t" + price + "\t" + itemType))
            cids.append(cid)
        except Exception as e:
            logging.warn("Got error "+str(e)+" while parsing\n" + utils.prettyPrintJson(item))
    
    return foundItems	
def test_getPlaystationPlusPrice():
    store = "DE/de"
    item = psn.getItemForCid(freeForPlusCid, store)

    print(
        "Using '"
        + item["name"]
        + "' ("
        + freeForPlusCid
        + ") from "
        + store
        + " for comparison. Item must be free for Plus members in order to pass the unit test. This might fail due to price changes"
    )

    assert item is not None

    normalPrice = psn.getPrice(item)
    plusPrice = psn.getPlaystationPlusPrice(item)

    print("Normal Price: ", "%.2f" % normalPrice, "Plus Price: ", "%.2f" % plusPrice)

    assert type(normalPrice) is float
    assert type(plusPrice) is float
    assert plusPrice == 0
def alertIsMatched(alert, item):
	return float(psn.getPrice(item)) <= float(alert['price'])