import datetime,os,re,requests from bs4 import BeautifulSoup from collections import Counter import log,variables values = ["red","orange","yellow","green","blue","purple","brown","gray","special","limited"] numbers = ["01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20"] print("Getting list of deck colours") deckkey = {} request = requests.get("https://colors-tcg.eu/cards.php?view=alpha") alldecks = open("key.html","w") alldecks.write(request.text) alldecks.close() # need to correct some html issues with open("key.html","r") as file: filedata = file.read() filedata = filedata.replace("","") with open("key.html","w") as file: file.write(filedata) with open("key.html") as decks: decksoup = BeautifulSoup(decks, "html.parser") soupdecks = decksoup.find("table",{"id":"colors"}) souprows = soupdecks.find_all("tr") for row in souprows: soupcells = row.find_all("td") deckname = soupcells[2].text.lower().replace(" ","").replace("'","").replace("Ƨ","c").replace(".","").replace("politetness","politeness") decktype = soupcells[3].text.lower() if decktype in values: deckkey[deckname] = decktype elif decktype == "n/a": deckkey[deckname] = "limited" print("Parsing log") cardlist = [] portfolios = [] crayred = 0 crayorange = 0 crayyellow = 0 craygreen = 0 crayblue = 0 craypurple = 0 craybrown = 0 craygrey = 0 tradeout = [] tradein = [] redeemedsketch = 0 coupons = [] datelist = [] logitems = [] pends = [] for event in log.log: logentry = {} logentry["date"] = event["date"] logentry["name"] = event["event"] logentry["url"] = event["url"] logit = False if event["event"] == "portfolio": portfolio = {} thedecks = {} for spacedeck in event["decks"]: deck = spacedeck.replace(" ","") thedecks[spacedeck] = deckkey[deck] portcolours = list(thedecks.values()) portcolours = sorted(list(dict.fromkeys(portcolours))) if len(portcolours) < 3: portfolio["type"] = "monochrome" else: portfolio["type"] = "palette" portfolio["decks"] = thedecks portfolio["url"] = event["url"] portfolios.append(portfolio) else: try: if event["received"]: logit = True receivedcards = [] for card in event["received"]: thecard = {} if card[0:4] != "sig_": thedeck = card[:-2] thecard["name"] = card thecard["received"] = event["date"] thecard["mass"] = [] if card[0:4] != "sig_": for theme in variables.masscollect: try: if thedeck in variables.masscollect[theme]["decks"]: thecard["mass"].append(theme) except KeyError: pass try: if card in variables.masscollect[theme]["singles"]: thecard["mass"].append(theme) except KeyError: pass if card[0:4] == "sig_": thecard["colour"] = "sig" else: try: thecard["colour"] = deckkey[thedeck] except: pass try: if thecard["colour"]: pass except: print("Warning: no colour found for " + thedeck) if thecard["colour"] == "sig": if card[4:] == variables.name.lower(): thecard["priority"] = 5 else: thecard["priority"] = 1 else: if thedeck in variables.highpriority: thecard["priority"] = 1 elif len(thecard["mass"]) > 0: thecard["priority"] = 2 else: thecard["priority"] = 4 cardlist.append(thecard) datelist.append(event["date"]) receivedcards.append(thecard) logentry["received"] = receivedcards except KeyError: pass try: if event["lost"]: logit = True lostcards = [] for card in event["lost"]: checkno = len(cardlist) - 1 deleted = False while checkno >= 0: if cardlist[checkno]["name"] == card: if deleted == False: colour = cardlist[checkno]["colour"] cardlist.remove(cardlist[checkno]) deleted = True checkno -= 1 if deleted == False: print("Warning: trying to remove " + card + " but none found") lostcard = {} lostcard["name"] = card lostcard["colour"] = colour lostcards.append(lostcard) datelist.remove(datelist[-1]) logentry["lost"] = lostcards except KeyError: pass crayons = {} try: crayred += event["crayons"]["red"] logit = True crayons["red"] = event["crayons"]["red"] except: pass try: crayorange += event["crayons"]["orange"] logit = True crayons["orange"] = event["crayons"]["orange"] except: pass try: crayyellow += event["crayons"]["yellow"] logit = True crayons["yellow"] = event["crayons"]["yellow"] except: pass try: craygreen += event["crayons"]["green"] logit = True crayons["green"] = event["crayons"]["green"] except: pass try: crayblue += event["crayons"]["blue"] logit = True crayons["blue"] = event["crayons"]["blue"] except: pass try: craypurple += event["crayons"]["purple"] logit = True crayons["purple"] = event["crayons"]["purple"] except: pass try: craybrown += event["crayons"]["brown"] logit = True crayons["brown"] = event["crayons"]["brown"] except: pass try: craygrey += event["crayons"]["gray"] logit = True crayons["grey"] = event["crayons"]["gray"] except: pass if len(crayons) > 0: logentry["crayons"] = crayons if event["event"][0:11] == "trade with ": try: for card in event["lost"]: tradeout.append(event["event"]) except: pass try: for card in event["received"]: tradein.append(event["event"]) except: pass if len(crayons) > 0: logentry["crayons"] = crayons try: redeemedsketch -= event["sketch"] except: pass try: for newcoupon in event["coupons"]: found = False for oldcoupon in coupons: if found == False: if newcoupon == list(oldcoupon.keys())[0]: found = True oldcoupon[newcoupon] += event["coupons"][newcoupon] if found == False: coupons.append({newcoupon:event["coupons"][newcoupon]}) except: pass try: for card in event["pend"]: pends.append(card) except: pass try: for card in event["unpend"]: pends.remove(card) except: pass if logit == True: logitems.append(logentry) logitems = logitems[::-1] coupons = coupons[::-1] print("Getting list of owned decks") portdecks = [] for portfolio in portfolios: oneportdecks = list(portfolio["decks"].keys()) for deck in oneportdecks: portdecks.append(deck.replace(" ","")) portdecks = sorted(list(dict.fromkeys(portdecks))) decks = [] for card in cardlist: if card["colour"] != "sig": deck = card["name"][:-2] decks.append(deck) decks = sorted(list(dict.fromkeys(decks))) decklist = [] for deck in decks: thedeck = {} thedeck["name"] = deck thedeck["colour"] = deckkey[deck] thedeck["mass"] = [] thedeck["massmaster"] = [] for theme in variables.masscollect: try: if deck in variables.masscollect[theme]["decks"]: thedeck["mass"].append(theme) except KeyError: pass try: if deck in variables.masscollect[theme]["masters"]: thedeck["massmaster"].append(theme) except KeyError: pass count = 0 for number in numbers: thedeck[number] = None for card in cardlist: if card["name"] == deck + number: if thedeck[number] == None: thedeck[number] = card["received"] count += 1 thedeck["count"] = count if count == 20: dates = [] for number in numbers: dates.append(thedeck[number]) dates = sorted(dates) thedeck["mastered"] = dates[-1] else: thedeck["mastered"] = False if deck in variables.highpriority or count >= variables.highthreshold or deck in portdecks or thedeck["colour"] == "limited": thedeck["priority"] = 1 elif len(thedeck["mass"]) > 0 or count >= variables.mediumthreshold: thedeck["priority"] = 2 elif count >= variables.collectthreshold: thedeck["priority"] = 3 else: thedeck["priority"] = 4 decklist.append(thedeck) if __name__ == "__main__": print("Checking for new card images") for card in cardlist: if card["colour"] == "sig": if not os.path.exists("build/decks/sigs/" + card["name"][4:] + ".gif"): print("Downloading " + card["name"]) r = requests.get("https://colors-tcg.eu/cards/" + card["name"] + ".gif") open("build/decks/sigs/" + card["name"][4:] + ".gif","wb").write(r.content) for deck in decklist: if not os.path.isdir("build/decks/" + deck["name"]): os.mkdir("build/decks/" + deck["name"]) print("Downloading " + deck["name"]) number = 0 while number < 21: if number < 10: r = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + "0" + str(number) + ".gif") open("build/decks/" + deck["name"] + "/0" + str(number) + ".gif","wb").write(r.content) else: r = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + str(number) + ".gif") open("build/decks/" + deck["name"] + "/" + str(number) + ".gif","wb").write(r.content) number += 1 master = requests.get("https://colors-tcg.eu/cards/" + deck["name"] + "master.gif") open("build/decks/" + deck["name"] + "/master.gif","wb").write(master.content) print("Getting list of wanted cards") wantedlist = [] for deck in decklist: if deck["priority"] < 4: for number in numbers: if deck[number] == None: wantedcard = {} wantedcard["name"] = deck["name"] + number wantedcard["colour"] = deck["colour"] wantedcard["priority"] = deck["priority"] wantedlist.append(wantedcard) decknames = [] for deck in decklist: decknames.append(deck["name"]) cardnames = [] for card in cardlist: cardnames.append(card["name"]) for theme in variables.masscollect: try: for deck in variables.masscollect[theme]["decks"]: if deck not in decknames: for number in numbers: wantedcard = {} wantedcard["name"] = deck + number wantedcard["colour"] = deckkey[deck] wantedcard["priority"] = 3 wantedlist.append(wantedcard) except KeyError: pass try: for card in variables.masscollect[theme]["singles"]: if card not in cardnames: wantedcard = {} wantedcard["name"] = card wantedcard["colour"] = deckkey[card[:-2]] wantedcard["priority"] = 3 wantedlist.append(wantedcard) except KeyError: pass wantedlist = sorted(wantedlist, key=lambda d: d["name"]) removelist = [] for card in wantedlist: if card["name"] in pends: removelist.append(card) for card in removelist: wantedlist.remove(card) print("Adjusting card priorities") for card in cardlist: for deck in decklist: if card["name"][:-2] == deck["name"]: if card["priority"] > deck["priority"]: card["priority"] = deck["priority"] cardlist = sorted(cardlist, key=lambda d: d["name"]) theindex = 0 for card in cardlist: card["dupe"] = False if card["name"][0:4] != "sig_": if theindex > 0: if card["name"] == cardlist[theindex-1]["name"]: card["priority"] = 4 card["dupe"] = True theindex += 1 theindex = 0 if variables.keepsig == True: for card in cardlist: if card["name"] == "sig_" + variables.name.lower(): card["priority"] = 1 if theindex > 0: if cardlist[theindex-1]["name"] == "sig_" + variables.name.lower(): card["priority"] = 5 theindex += 1 # core functions def headerwrite(thefile,pagename): header = open(thefile,"a") header.write("\n\n \n \n \n 0: header.write("/" + variables.subfolder) header.write("/style.css\">\n 0: header.write("/" + variables.subfolder) header.write("/user.css\">\n \n " + variables.name + "ā€™s card collection :: " + pagename + "\n \n \n \n \n
\n") header.close() def footerwrite(thefile): footer = open(thefile,"a") footer.write("
\n \n") footer.close() def printcard(card): if type(card) == dict: if card["colour"] == "sig": imgstring = " 0: imgstring += "/" + variables.subfolder imgstring += "/decks/sigs/" + card["name"][4:] + ".gif\" title=\"" + card["name"] + "\" loading=\"lazy\">" return imgstring else: deck = card["name"][:-2] cardid = card["name"][-2:] imgstring = " 0: imgstring += "/" + variables.subfolder imgstring += "/decks/" + deck + "/" + cardid + ".gif\" title=\"" + card["name"] + "\" loading=\"lazy\">" return imgstring elif type(card) == str: if card[0:4] == "sig_": imgstring = " 0: imgstring += "/" + variables.subfolder imgstring += "/decks/sigs/" + card[4:] + ".gif\" title=\"" + card + "\" loading=\"lazy\">" return imgstring else: deck = card[:-2] cardid = card[-2:] imgstring = " 0: imgstring += "/" + variables.subfolder imgstring += "/decks/" + deck + "/" + cardid + ".gif\" title=\"" + card + "\" loading=\"lazy\">" return imgstring def cardtext(card): cardtext = "" if card["colour"] == "red": cardtext += "šŸ”“" elif card["colour"] == "orange": cardtext += "šŸŸ " elif card["colour"] == "yellow": cardtext += "šŸŸ”" elif card["colour"] == "green": cardtext += "šŸŸ¢" elif card["colour"] == "blue": cardtext += "šŸ”µ" elif card["colour"] == "purple": cardtext += "šŸŸ£" elif card["colour"] == "brown": cardtext += "šŸŸ¤" elif card["colour"] == "gray": cardtext += "āšŖ" elif card["colour"] == "special": cardtext += "āœØ" elif card["colour"] == "limited": cardtext += "šŸŒˆ" elif card["colour"] == "sig": cardtext += "āœ" cardtext += card["name"] + "" return cardtext def portfoliogen(theportfolio,thetype,portnumber): if thetype == "palette": portstring = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
" + variables.name.lower() + "
" try: reddeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("red")] for deck in decklist: if deck["name"] == reddeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + reddeck except: specialdeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("special")] for deck in decklist: if deck["name"] == specialdeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + specialdeck portstring += "" try: bluedeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("blue")] for deck in decklist: if deck["name"] == bluedeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + bluedeck except: specialdeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("special")] for deck in decklist: if deck["name"] == specialdeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + specialdeck portstring += "
" try: orangedeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("orange")] for deck in decklist: if deck["name"] == orangedeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + orangedeck except: specialdeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("special")] for deck in decklist: if deck["name"] == specialdeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + specialdeck portstring += "" try: purpledeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("purple")] for deck in decklist: if deck["name"] == purpledeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + purpledeck except: specialdeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("special")] for deck in decklist: if deck["name"] == specialdeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + specialdeck portstring += "
" try: yellowdeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("yellow")] for deck in decklist: if deck["name"] == yellowdeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + yellowdeck except: specialdeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("special")] for deck in decklist: if deck["name"] == specialdeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + specialdeck portstring += "" try: browndeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("brown")] for deck in decklist: if deck["name"] == browndeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + browndeck except: specialdeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("special")] for deck in decklist: if deck["name"] == specialdeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + specialdeck portstring += "
" try: greendeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("green")] for deck in decklist: if deck["name"] == greendeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + greendeck except: specialdeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("special")] for deck in decklist: if deck["name"] == specialdeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + specialdeck portstring += "" try: greydeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("gray")] for deck in decklist: if deck["name"] == greydeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + greydeck except: specialdeck = list(theportfolio["decks"].keys())[list(theportfolio["decks"].values()).index("special")] for deck in decklist: if deck["name"] == specialdeck.replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + specialdeck portstring += "
palette portfolio " if portnumber < 10: portstring += "0" + str(portnumber) else: portstring += str(portnumber) portstring += "
\n" elif thetype == "monochrome": thecolour = list(theportfolio["decks"].values())[0] portstring = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
" + variables.name.lower() + "
" thedecks = sorted(list(theportfolio["decks"].keys())) for deck in decklist: if deck["name"] == thedecks[0].replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + thedecks[0] + "" for deck in decklist: if deck["name"] == thedecks[4].replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + thedecks[4] + "
" for deck in decklist: if deck["name"] == thedecks[1].replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + thedecks[1] + "" for deck in decklist: if deck["name"] == thedecks[5].replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + thedecks[5] + "
" for deck in decklist: if deck["name"] == thedecks[2].replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + thedecks[2] + "" for deck in decklist: if deck["name"] == thedecks[6].replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + thedecks[6] + "
" for deck in decklist: if deck["name"] == thedecks[3].replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + thedecks[3] + "" for deck in decklist: if deck["name"] == thedecks[7].replace(" ",""): if deck["mastered"]: portstring += "ā– " else: portstring += "ā–”" break portstring += " " + thedecks[7] + "
monochrome portfolio " if portnumber < 10: portstring += "0" + str(portnumber) else: portstring += str(portnumber) portstring += "
\n" return portstring portfoliosearch = len(portfolios) latestpalette = 0 latestmonochrome = 0 palettes = 0 monochromes = 0 while portfoliosearch > 0: if portfolios[portfoliosearch-1]["type"] == "palette": palettes += 1 if latestpalette == 0: latestpalette = portfoliosearch if portfolios[portfoliosearch-1]["type"] == "monochrome": monochromes += 1 if latestmonochrome == 0: latestmonochrome = portfoliosearch portfoliosearch -= 1 def filterwrite(page,colour=False,sigs=False): filterstring = "

" if colour: filterstring += "Filtered to " if colour == "gray": if variables.british: filterstring += "grey" else: filterstring += "gray" else: filterstring += colour filterstring += ". 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "\">Show all" else: filterstring += "Filter: 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/red\" title=\"red\">šŸ”“ 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/orange\" title=\"orange\">šŸŸ  0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/yellow\" title=\"yellow\">šŸŸ” 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/green\" title=\"green\">šŸŸ¢ 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/blue\" title=\"blue\">šŸ”µ 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/purple\" title=\"purple\">šŸŸ£ 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/brown\" title=\"brown\">šŸŸ¤ 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/gray\" title=\"" if variables.british: filterstring += "grey" else: filterstring += "gray" filterstring += "\">āšŖ 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/special\" title=\"special\">āœØ 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/limited\" title=\"limited\">šŸŒˆ" if sigs: filterstring += " 0: filterstring += "/" + variables.subfolder filterstring += "/" + page + "/sig\" title=\"sig\">āœ" filterstring += "

\n" return filterstring def printdeck(deck,fold=True): if fold: deckstring = "
\n" + deck["name"] + " [" if deck["mastered"]: deckstring += deck["mastered"].strftime("%Y-%m-%d") else: deckstring += str(deck["count"]) + "/20" deckstring += "]\n" else: deckstring = "" deckstring += "\n" if not fold: deckstring += "\n \n \n \n\n" deckstring += "\n" test = 1 while test < 21: if test % 5 == 1: deckstring += " \n" deckstring += " \n" if test % 5 == 0: deckstring += " \n" test += 1 if deck["mastered"]: deckstring += " \n \n" deckstring += "\n
" + deck["name"] + " [" if deck["mastered"]: deckstring += deck["mastered"].strftime("%Y-%m-%d") else: deckstring += str(deck["count"]) + "/20" deckstring += "]
" if test < 10: teststring = "0" + str(test) else: teststring = str(test) found = False for card in cardlist: if card["name"] == deck["name"] + teststring: deckstring += printcard(card) found = True break if found == False: deckstring += " 0: deckstring += "/" + variables.subfolder deckstring += "/decks/" + deck["name"] + "/00.gif\" loading=\"lazy\">" if deck["name"] + teststring in pends: deckstring += "

pending

" deckstring += "
0: deckstring += "/" + variables.subfolder deckstring += "/decks/" + deck["name"] + "/master.gif\" title=\"mastered " + deck["name"] try: if deck["name"] in variables.firstmasteries: deckstring += " (first)\" class=\"first" except: pass deckstring += "\">\n
\n" if fold: deckstring += "
\n" return deckstring def crayonlog(colour,event): crayonno = event["crayons"][colour] if variables.british: if colour == "grey": crayonrend = "grey" else: crayonrend = colour else: crayonrend = colour if crayonno > 0: crayonstring = "+" + str(crayonno) + " " + crayonrend else: crayonstring = str(crayonno) + " " + crayonrend return crayonstring def dupes(mass=True,nonmass=True,characters=True,specials=True): dupeslist = [] previouscard = "" for card in cardlist: try: if card["colour"] != "sig" and card ["colour"] != "limited": if card["name"] == previouscard["name"]: dupe = {} dupe["name"] = card["name"] if len(card["mass"]) > 0: if mass: dupe["mass"] = card["mass"] if card["colour"] == "special": if specials: dupeslist.append(dupe) else: if characters: dupeslist.append(dupe) else: if nonmass: if card["colour"] == "special": if specials: dupeslist.append(dupe) else: if characters: dupeslist.append(dupe) except: pass previouscard = card return dupeslist def activitydupes(): print(dupes(False,True,True,False)) def riku(): print("Specials") print(dupes(True,False,False,True)) print("Characters") print(dupes(True,False,True,False)) def nextportfolio(monochrome=False): useddecks = {} already = 0 if monochrome: for portfolio in portfolios: if portfolio["type"] == "monochrome": already += 1 useddecks.update(portfolio["decks"]) else: for portfolio in portfolios: if portfolio["type"] == "palette": already += 1 useddecks.update(portfolio["decks"]) potentials = [] for deck in decklist: if deck["mastered"]: if deck["colour"] != "special" and deck["colour"] != "limited": potential = True for key, value in useddecks.items(): if deck["name"] == key.replace(" ",""): potential = False if potential: potentials.append(deck) potentials = sorted(potentials, key=lambda d: d["mastered"]) if monochrome: reddecks = [] orangedecks = [] yellowdecks = [] greendecks = [] bluedecks = [] purpledecks = [] browndecks = [] greydecks = [] for deck in potentials: if deck["colour"] == "red": reddecks.append(deck) elif deck["colour"] == "orange": orangedecks.append(deck) elif deck["colour"] == "yellow": yellowdecks.append(deck) elif deck["colour"] == "green": greendecks.append(deck) elif deck["colour"] == "blue": bluedecks.append(deck) elif deck["colour"] == "purple": purpledecks.append(deck) elif deck["colour"] == "brown": browndecks.append(deck) elif deck["colour"] == "gray": greydecks.append(deck) longestvalue = len(reddecks) nextportcolour = "red" if len(orangedecks) > longestvalue: nextportcolour = "orange" if len(yellowdecks) > longestvalue: nextportcolour = "yellow" if len(greendecks) > longestvalue: nextportcolour = "green" if len(bluedecks) > longestvalue: nextportcolour = "blue" if len(purpledecks) > longestvalue: nextportcolour = "purple" if len(browndecks) > longestvalue: nextportcolour = "brown" if len(greydecks) > longestvalue: nextportcolour = "grey" firstthree = [] if nextportcolour == "red": firstthree.append(reddecks[0]["name"]) firstthree.append(reddecks[1]["name"]) firstthree.append(reddecks[2]["name"]) elif nextportcolour == "orange": firstthree.append(orangedecks[0]["name"]) firstthree.append(orangedecks[1]["name"]) firstthree.append(orangedecks[2]["name"]) elif nextportcolour == "yellow": firstthree.append(yellowdecks[0]["name"]) firstthree.append(yellowdecks[1]["name"]) firstthree.append(yellowdecks[2]["name"]) elif nextportcolour == "green": firstthree.append(greendecks[0]["name"]) firstthree.append(greendecks[1]["name"]) firstthree.append(greendecks[2]["name"]) elif nextportcolour == "blue": firstthree.append(bluedecks[0]["name"]) firstthree.append(bluedecks[1]["name"]) firstthree.append(bluedecks[2]["name"]) elif nextportcolour == "purple": firstthree.append(purpledecks[0]["name"]) firstthree.append(purpledecks[1]["name"]) firstthree.append(purpledecks[2]["name"]) elif nextportcolour == "brown": firstthree.append(browndecks[0]["name"]) firstthree.append(browndecks[1]["name"]) firstthree.append(browndecks[2]["name"]) elif nextportcolour == "grey": firstthree.append(greydecks[0]["name"]) firstthree.append(greydecks[1]["name"]) firstthree.append(greydecks[2]["name"]) secondfive = [] nearingdecks = sorted(decklist, key=lambda d: d["count"],reverse=True) slots = 5 for deck in nearingdecks: if slots > 0: if not deck["mastered"]: if nextportcolour == "grey": if deck["colour"] == "gray": secondfive.append(deck["name"]) slots -= 1 else: if deck["colour"] == nextportcolour: secondfive.append(deck["name"]) slots -= 1 alleight = sorted(firstthree + secondfive) else: thereddeck = False redmastered = False theorangedeck = False orangemastered = False theyellowdeck = False yellowmastered = False thegreendeck = False greenmastered = False thebluedeck = False bluemastered = False thepurpledeck = False purplemastered = False thebrowndeck = False brownmastered = False thegreydeck = False greymastered = False sorteddecks = 0 for deck in potentials: if sorteddecks < 3: if deck["colour"] == "red" and thereddeck == False: thereddeck = deck["name"] redmastered = True sorteddecks += 1 elif deck["colour"] == "orange" and theorangedeck == False: theorangedeck = deck["name"] orangemastered = True sorteddecks += 1 elif deck["colour"] == "yellow" and theyellowdeck == False: theyellowdeck = deck["name"] yellowmastered = True sorteddecks += 1 elif deck["colour"] == "green" and thegreendeck == False: thegreendeck = deck["name"] greenmastered = True sorteddecks += 1 elif deck["colour"] == "blue" and thebluedeck == False: thebluedeck = deck["name"] bluemastered = True sorteddecks += 1 elif deck["colour"] == "purple" and thepurpledeck == False: thepurpledeck = deck["name"] purplemastered = True sorteddecks += 1 elif deck["colour"] == "brown" and thebrowndeck == False: thebrowndeck = deck["name"] brownmastered = True sorteddecks += 1 elif deck["colour"] == "gray" and thegreydeck == False: thegreydeck = deck["name"] greymastered = True sorteddecks += 1 nearingdecks = sorted(decklist, key=lambda d: d["count"],reverse=True) if thereddeck == False: for deck in nearingdecks: if not deck["mastered"]: if thereddeck == False: if deck["colour"] == "red": used = False for key, value in useddecks.items(): if deck["name"] == key.replace(" ",""): used = True if used == False: thereddeck = deck["name"] if theorangedeck == False: for deck in nearingdecks: if not deck["mastered"]: if theorangedeck == False: if deck["colour"] == "orange": used = False for key, value in useddecks.items(): if deck["name"] == key.replace(" ",""): used = True if used == False: theorangedeck = deck["name"] if theyellowdeck == False: for deck in nearingdecks: if not deck["mastered"]: if theyellowdeck == False: if deck["colour"] == "yellow": used = False for key, value in useddecks.items(): if deck["name"] == key.replace(" ",""): used = True if used == False: theyellowdeck = deck["name"] if thegreendeck == False: for deck in nearingdecks: if not deck["mastered"]: if thegreendeck == False: if deck["colour"] == "green": used = False for key, value in useddecks.items(): if deck["name"] == key.replace(" ",""): used = True if used == False: thegreendeck = deck["name"] if thebluedeck == False: for deck in nearingdecks: if not deck["mastered"]: if thebluedeck == False: if deck["colour"] == "blue": used = False for key, value in useddecks.items(): if deck["name"] == key.replace(" ",""): used = True if used == False: thebluedeck = deck["name"] if thepurpledeck == False: for deck in nearingdecks: if not deck["mastered"]: if thepurpledeck == False: if deck["colour"] == "purple": used = False for key, value in useddecks.items(): if deck["name"] == key.replace(" ",""): used = True if used == False: thepurpledeck = deck["name"] if thebrowndeck == False: for deck in nearingdecks: if not deck["mastered"]: if thebrowndeck == False: if deck["colour"] == "brown": used = False for key, value in useddecks.items(): if deck["name"] == key.replace(" ",""): used = True if used == False: thebrowndeck = deck["name"] if thegreydeck == False: for deck in nearingdecks: if not deck["mastered"]: if thegreydeck == False: if deck["colour"] == "gray": used = False for key, value in useddecks.items(): if deck["name"] == key.replace(" ",""): used = True if used == False: thegreydeck = deck["name"] alleight = [] alleight.append(thereddeck) alleight.append(theorangedeck) alleight.append(theyellowdeck) alleight.append(thegreendeck) alleight.append(thebluedeck) alleight.append(thepurpledeck) alleight.append(thebrowndeck) alleight.append(thegreydeck) portcomment = "ā™„ Your Name: " + variables.name + "\nā™„ Card post: " + variables.url + "\nā™„ " if monochrome: portcomment += "Monochrome" else: portcomment += "Palette" portcomment += " Portfolio #: " + str(already + 1) + "\n" if monochrome: portcomment += "ā™„ Monochrome Color: " if nextportcolour == "grey": if variables.british: portcomment += "grey" else: portcomment += "gray" else: portcomment += nextportcolour portcomment += "\nā™„ 1st deck: " + alleight[0] if alleight[0] in firstthree: portcomment += " (mastered)" portcomment += "\nā™„ 2nd deck: " + alleight[1] if alleight[1] in firstthree: portcomment += " (mastered)" portcomment += "\nā™„ 3rd deck: " + alleight[2] if alleight[2] in firstthree: portcomment += " (mastered)" portcomment += "\nā™„ 4th deck: " + alleight[3] if alleight[3] in firstthree: portcomment += " (mastered)" portcomment += "\nā™„ 5th deck: " + alleight[4] if alleight[4] in firstthree: portcomment += " (mastered)" portcomment += "\nā™„ 6th deck: " + alleight[5] if alleight[5] in firstthree: portcomment += " (mastered)" portcomment += "\nā™„ 7th deck: " + alleight[6] if alleight[6] in firstthree: portcomment += " (mastered)" portcomment += "\nā™„ 8th deck: " + alleight[7] if alleight[7] in firstthree: portcomment += " (mastered)" else: portcomment += "ā™„ Red deck: " + thereddeck if redmastered: portcomment += " (mastered)" portcomment += "\nā™„ Orange deck: " + theorangedeck if orangemastered: portcomment += " (mastered)" portcomment += "\nā™„ Yellow deck: " + theyellowdeck if yellowmastered: portcomment += " (mastered)" portcomment += "\nā™„ Green deck: " + thegreendeck if greenmastered: portcomment += " (mastered)" portcomment += "\nā™„ Blue deck: " + thebluedeck if bluemastered: portcomment += " (mastered)" portcomment += "\nā™„ Purple deck: " + thepurpledeck if purplemastered: portcomment += " (mastered)" portcomment += "\nā™„ Brown deck: " + thebrowndeck if brownmastered: portcomment += " (mastered)" portcomment += "\nā™„ Gray deck: " + thegreydeck if greymastered: portcomment += " (mastered)" print(portcomment) porturl = input("\nPaste the comment URL here: ") print("\n{\"event\":\"portfolio\",\"date\":datetime.datetime(" + datetime.datetime.today().strftime("%Y,%-m,%-d") + "),\"url\":\"" + porturl + "\",\"decks\":[\"" + alleight[0] + "\",\"" + alleight[1] + "\",\"" + alleight[2] + "\",\"" + alleight[3] + "\",\"" + alleight[4] + "\",\"" + alleight[5] + "\",\"" + alleight[6] + "\",\"" + alleight[7] + "\"]}") if __name__ == "__main__": print("Building index page") def indexgen(): if os.path.exists("build/index.html"): os.remove("build/index.html") thefile = "build/index.html" headerwrite(thefile,"index") content = open(thefile,"a") firstdate = log.log[0]["date"] if len(cardlist) > 14400: rankcode = "rainbow" extra = len(cardlist) - 14400 plusranks = int(extra / 300) if plusranks > 0: rank = "rainbow + " + str(plusranks) else: rank = "rainbow" else: if len(cardlist) > 14100: rank = "himalayan" elif len(cardlist) > 13800: rank = "puma" elif len(cardlist) > 13500: rank = "chartreux" elif len(cardlist) > 13500: rank = "russian blue" elif len(cardlist) > 12900: rank = "panther" elif len(cardlist) > 12600: rank = "cheetah" elif len(cardlist) > 12300: rank = "tiger" elif len(cardlist) > 12000: rank = "lion" elif len(cardlist) > 11700: rank = "metal" elif len(cardlist) > 11400: rank = "ground" elif len(cardlist) > 11100: rank = "darkness" elif len(cardlist) > 10800: rank = "water" elif len(cardlist) > 10500: rank = "nature" elif len(cardlist) > 10200: rank = "light" elif len(cardlist) > 9900: rank = "wind" elif len(cardlist) > 9600: rank = "fire" elif len(cardlist) > 9300: rank = "mercury" elif len(cardlist) > 9000: rank = "jupiter" elif len(cardlist) > 8700: rank = "uranus" elif len(cardlist) > 8400: rank = "neptune" elif len(cardlist) > 8100: rank = "earth" elif len(cardlist) > 7800: rank = "venus" elif len(cardlist) > 7500: rank = "saturn" elif len(cardlist) > 7200: rank = "mars" elif len(cardlist) > 6900: rank = "magnolia" elif len(cardlist) > 6600: rank = "chocolate cosmos" elif len(cardlist) > 6300: rank = "lilac" elif len(cardlist) > 6000: rank = "hydrangea" elif len(cardlist) > 5700: rank = "clover" elif len(cardlist) > 5400: rank = "daffodil" elif len(cardlist) > 5100: rank = "tiger lily" elif len(cardlist) > 4800: rank = "sakura" elif len(cardlist) > 4500: rank = "silver" elif len(cardlist) > 4200: rank = "bronze" elif len(cardlist) > 3900: rank = "amethyst" elif len(cardlist) > 3600: rank = "sapphire" elif len(cardlist) > 3300: rank = "emerald" elif len(cardlist) > 3000: rank = "gold" elif len(cardlist) > 2700: rank = "amber" elif len(cardlist) > 2400: rank = "ruby" elif len(cardlist) > 2200: rank = "dragon fruit" elif len(cardlist) > 2000: rank = "apricot" elif len(cardlist) > 1800: rank = "grape" elif len(cardlist) > 1600: rank = "blueberry" elif len(cardlist) > 1400: rank = "lime" elif len(cardlist) > 1200: rank = "lemon" elif len(cardlist) > 1000: rank = "tangerine" elif len(cardlist) > 800: rank = "strawberry" elif len(cardlist) > 700: rank = "gray" elif len(cardlist) > 600: rank = "brown" elif len(cardlist) > 500: rank = "purple" elif len(cardlist) > 400: rank = "blue" elif len(cardlist) > 300: rank = "green" elif len(cardlist) > 200: rank = "yellow" elif len(cardlist) > 100: rank = "orange" else: rank = "red" rankcode = re.sub(" ","",rank) content.write(" 0: content.write("/" + variables.subfolder) content.write("/levels\"> 0: content.write("/" + variables.subfolder) content.write("/assets/levels/" + rankcode + ".gif\"> 0: content.write("/" + variables.subfolder) content.write("/decks/sigs/" + variables.name.lower() + ".gif\" loading=\"lazy\">\n\n") if crayred + crayorange + crayyellow + craygreen + crayblue + craypurple + craybrown + craygrey > 0: content.write("\n\n\n") if crayred > 0: content.write("\n") if crayorange > 0: content.write("\n") if crayyellow > 0: content.write("\n") if craygreen > 0: content.write("\n") if crayblue > 0: content.write("\n") if craypurple > 0: content.write("\n") if craybrown > 0: content.write("\n") if craygrey > 0: content.write("\n") content.write("\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/crayons/crayon1.gif\" class=\"crayon\" title=\"red\"> Ɨ " + str(crayred) + " 0: content.write("/" + variables.subfolder) content.write("/assets/crayons/crayon2.gif\" class=\"crayon\" title=\"orange\"> Ɨ " + str(crayorange) + " 0: content.write("/" + variables.subfolder) content.write("/assets/crayons/crayon3.gif\" class=\"crayon\" title=\"yellow\"> Ɨ " + str(crayyellow) + " 0: content.write("/" + variables.subfolder) content.write("/assets/crayons/crayon4.gif\" class=\"crayon\" title=\"green\"> Ɨ " + str(craygreen) + " 0: content.write("/" + variables.subfolder) content.write("/assets/crayons/crayon5.gif\" class=\"crayon\" title=\"blue\"> Ɨ " + str(crayblue) + " 0: content.write("/" + variables.subfolder) content.write("/assets/crayons/crayon6.gif\" class=\"crayon\" title=\"purple\"> Ɨ " + str(craypurple) + " 0: content.write("/" + variables.subfolder) content.write("/assets/crayons/crayon7.gif\" class=\"crayon\" title=\"brown\"> Ɨ " + str(craybrown) + " 0: content.write("/" + variables.subfolder) content.write("/assets/crayons/crayon8.gif\" class=\"crayon\" title=\"") if variables.british: content.write("grey") else: content.write("gray") content.write("\"> Ɨ " + str(craygrey) + "
\n") tradecommon = list((Counter(tradeout) & Counter(tradein)).elements()) sketch = len(tradecommon) if sketch > 0: content.write("\n\n\n\n") if sketch > 19: content.write("\n") content.write("\n\n\n") if sketch > 19: content.write("\n") content.write("\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/sketch/") if sketch % 20 < 10: content.write("0" + str(sketch % 20)) else: content.write(str(sketch % 20)) content.write(".gif\"> 0: content.write("/" + variables.subfolder) content.write("/assets/sketch/20.gif\" title=\"") sketchdifference = int(sketch / 20) - redeemedsketch if sketchdifference > 0: content.write(str(sketchdifference) + " to turn in") else: content.write("all turned in") content.write("\">
" + str(sketch % 20) + "/20" + str(int(sketch / 20)) + " completed
") if latestpalette + latestmonochrome > 0: content.write(" 0: content.write("/" + variables.subfolder) content.write("/portfolios\">\n
\n") if latestpalette > 0: content.write(portfoliogen(portfolios[latestpalette-1],"palette",palettes)) if latestmonochrome > 0: content.write(portfoliogen(portfolios[latestmonochrome-1],"monochrome",monochromes)) content.write("
\n
\n") decksofinterest = [] mastereddecks = [] for deck in decklist: if deck["mastered"]: mastereddecks.append(deck) mastereddecks = sorted(mastereddecks,key=lambda d: d["mastered"],reverse=True) if len(mastereddecks) > 0: content.write("

mastered decks

\n

") masteredcount = 0 for deck in mastereddecks: if masteredcount < variables.maxmastered: content.write(" 0: content.write("/" + variables.subfolder) content.write("/decks/" + deck["name"] + "/master.gif\" title=\"mastered " + deck["name"]) try: if deck["name"] in variables.firstmasteries: content.write(" (first)\" class=\"first") except: pass content.write("\">") masteredcount += 1 if len(mastereddecks) > variables.maxmastered: content.write(" 0: content.write("/" + variables.subfolder) content.write("mastered\">see all") content.write("

\n") sigs = [] for card in cardlist: if card["name"][0:4] == "sig_": sigs.append(card) if len(sigs) > 0: content.write("

signatures

\n

") for card in sigs: content.write(printcard(card)) content.write("

\n") if len(variables.faves) > 0: content.write("

faves

\n

") faveslist = sorted(variables.faves) for card in faveslist: content.write(printcard(card)) content.write("

\n") if len(coupons) > 0: content.write("

coupons

\n

") for coupon in coupons: for key,value in coupon.items(): content.write(" 0: content.write("/" + variables.subfolder) content.write("/assets/coupons/" + key + ".png\" class=\"coupon") if value == 0: content.write(" expired\" title=\"expired\"") else: content.write("\" title=\"" + str(value) + " left\"") content.write(" loading=\"lazy\">") content.write("

\n") donations = [] try: for donatedeck in variables.donations["decks"]: donation = {} donation["name"] = donatedeck for deck in decklist: if deck["name"] == donatedeck: if deck["mastered"]: donation["type"] = "mastered" else: donation["type"] = "deck" break donations.append(donation) except: pass try: for card in variables.donations["scrapbook"]: donation = {} donation["name"] = card donation["type"] = "single" donations.append(donation) except: pass if len(donations) > 0: donations = sorted(donations, key=lambda d: d["name"]) content.write("

donations

\n

") for donation in donations: if donation["type"] == "deck": content.write(" 0: content.write("/" + variables.subfolder) content.write("/decks/" + donation["name"] + "/00.gif\" loading=\"lazy\">") elif donation["type"] == "mastered": content.write(" 0: content.write("/" + variables.subfolder) content.write("/decks/" + donation["name"] + "/master.gif\" title=\"mastered " + donation["name"]) try: if donation["name"] in variables.firstmasteries: content.write(" (first)\" class=\"first") except: pass content.write("\">") elif donation["type"] == "single": content.write(printcard(donation["name"])) content.write("

\n") content.close() footerwrite(thefile) if __name__ == "__main__": indexgen() print("Building levels page") def levelsgen(): if not os.path.isdir("build/levels"): os.mkdir("build/levels") if os.path.exists("build/levels/index.html"): os.remove("build/levels/index.html") thefile = "build/levels/index.html" headerwrite(thefile,"levels") content = open(thefile,"a") content.write("

levels

\n\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/red.gif\" loading=\"lazy\">
" + datelist[0].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 100: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/orange.gif\" loading=\"lazy\">
" + datelist[100].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 200: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/yellow.gif\" loading=\"lazy\">
" + datelist[200].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 300: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/green.gif\" loading=\"lazy\">
" + datelist[300].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 400: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/blue.gif\" loading=\"lazy\">
" + datelist[400].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 500: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/purple.gif\" loading=\"lazy\">
" + datelist[500].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 600: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/brown.gif\" loading=\"lazy\">
" + datelist[600].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 700: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/gray.gif\" loading=\"lazy\">
" + datelist[700].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 800: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/strawberry.gif\" loading=\"lazy\">
" + datelist[800].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 1000: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/tangerine.gif\" loading=\"lazy\">
" + datelist[1000].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 1200: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/lemon.gif\" loading=\"lazy\">
" + datelist[1200].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 1400: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/lime.gif\" loading=\"lazy\">
" + datelist[1400].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 1600: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/blueberry.gif\" loading=\"lazy\">
" + datelist[1600].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 1800: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/grape.gif\" loading=\"lazy\">
" + datelist[1800].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 2000: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/apricot.gif\" loading=\"lazy\">
" + datelist[2000].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 2200: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/dragonfruit.gif\" loading=\"lazy\">
" + datelist[2200].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 2400: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/ruby.gif\" loading=\"lazy\">
" + datelist[2400].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 2700: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/amber.gif\" loading=\"lazy\">
" + datelist[2700].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 3000: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/gold.gif\" loading=\"lazy\">
" + datelist[3000].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 3300: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/emerald.gif\" loading=\"lazy\">
" + datelist[3300].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 3600: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/sapphire.gif\" loading=\"lazy\">
" + datelist[3600].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 3900: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/amethyst.gif\" loading=\"lazy\">
" + datelist[3900].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 4200: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/bronze.gif\" loading=\"lazy\">
" + datelist[4200].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 4500: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/silver.gif\" loading=\"lazy\">
" + datelist[4500].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 4800: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/sakura.gif\" loading=\"lazy\">
" + datelist[4800].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 5100: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/tigerlily.gif\" loading=\"lazy\">
" + datelist[5100].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 5400: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/daffodil.gif\" loading=\"lazy\">
" + datelist[5400].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 5700: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/clover.gif\" loading=\"lazy\">
" + datelist[5700].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 6000: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/hydrangea.gif\" loading=\"lazy\">
" + datelist[6000].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 6300: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/lilac.gif\" loading=\"lazy\">
" + datelist[6300].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 6600: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/chocolatecosmos.gif\" loading=\"lazy\">
" + datelist[6600].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 6900: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/magnolia.gif\" loading=\"lazy\">
" + datelist[6900].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 7200: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/mars.gif\" loading=\"lazy\">
" + datelist[7200].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 7500: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/saturn.gif\" loading=\"lazy\">
" + datelist[7500].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 7800: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/venus.gif\" loading=\"lazy\">
" + datelist[7800].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 8100: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/earth.gif\" loading=\"lazy\">
" + datelist[8100].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 8400: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/neptune.gif\" loading=\"lazy\">
" + datelist[8400].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 8700: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/uranus.gif\" loading=\"lazy\">
" + datelist[8700].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 9000: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/jupiter.gif\" loading=\"lazy\">
" + datelist[9000].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 9300: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/mercury.gif\" loading=\"lazy\">
" + datelist[9300].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 9600: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/fire.gif\" loading=\"lazy\">
" + datelist[9600].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 9900: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/wind.gif\" loading=\"lazy\">
" + datelist[9900].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 10200: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/light.gif\" loading=\"lazy\">
" + datelist[10200].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 10500: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/nature.gif\" loading=\"lazy\">
" + datelist[10500].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 10800: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/water.gif\" loading=\"lazy\">
" + datelist[10800].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 11100: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/darkness.gif\" loading=\"lazy\">
" + datelist[11100].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 11400: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/ground.gif\" loading=\"lazy\">
" + datelist[11400].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 11700: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/metal.gif\" loading=\"lazy\">
" + datelist[11700].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 12000: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/lion.gif\" loading=\"lazy\">
" + datelist[12000].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 12300: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/tiger.gif\" loading=\"lazy\">
" + datelist[12300].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 12600: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/cheetah.gif\" loading=\"lazy\">
" + datelist[12600].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 12900: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/panther.gif\" loading=\"lazy\">
" + datelist[12900].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 13200: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/russianblue.gif\" loading=\"lazy\">
" + datelist[13200].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 13500: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/chartreux.gif\" loading=\"lazy\">
" + datelist[13500].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 13800: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/puma.gif\" loading=\"lazy\">
" + datelist[13800].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 14100: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/himalayan.gif\" loading=\"lazy\">
" + datelist[14100].strftime("%Y-%m-%d") + "
\n") if len(cardlist) > 14400: content.write("\n\n\n\n\n\n\n\n\n
0: content.write("/" + variables.subfolder) content.write("/assets/levels/rainbow.gif\" loading=\"lazy\">
" + datelist[14400].strftime("%Y-%m-%d") + "
\n") content.close() footerwrite(thefile) if __name__ == "__main__": levelsgen() print("Building portfolios page") def portfoliosgen(colour=False): if not os.path.isdir("build/portfolios"): os.mkdir("build/portfolios") if colour: if not os.path.isdir("build/portfolios/" + colour): os.mkdir("build/portfolios/" + colour) thefile = "build/portfolios/" + colour + "/index.html" else: thefile = "build/portfolios/index.html" if os.path.exists(thefile): os.remove(thefile) headerwrite(thefile,"portfolios") content = open(thefile,"a") content.write("

portfolios

\n") if latestpalette + latestmonochrome > 0: if latestpalette > 0: content.write("
\n") portnumber = 1 for portfolio in portfolios: if portfolio["type"] == "palette": content.write(portfoliogen(portfolio,"palette",portnumber)) portnumber += 1 content.write("
\n") if latestmonochrome > 0: content.write("
\n") portnumber = 1 for portfolio in portfolios: if portfolio["type"] == "monochrome": content.write(portfoliogen(portfolio,"monochrome",portnumber)) portnumber += 1 content.write("
\n") content.close() footerwrite(thefile) if __name__ == "__main__": portfoliosgen() print("Building collecting page") def collectinggen(colour=False): if not os.path.isdir("build/collecting"): os.mkdir("build/collecting") if colour: if not os.path.isdir("build/collecting/" + colour): os.mkdir("build/collecting/" + colour) thefile = "build/collecting/" + colour + "/index.html" else: thefile = "build/collecting/index.html" if os.path.exists(thefile): os.remove(thefile) headerwrite(thefile,"collecting") content = open(thefile,"a") content.write("

decks in progress

\n" + filterwrite("collecting",colour) + "
\n

High priority

\n") for deck in decklist: if deck["priority"] == 1 and deck["mastered"] == False: if colour: if deck["colour"] == colour: content.write(printdeck(deck,False)) else: content.write(printdeck(deck,False)) content.write("
\n
\n

Medium priority

\n") for deck in decklist: if deck["priority"] == 2 and deck["mastered"] == False: if colour: if deck["colour"] == colour: content.write(printdeck(deck)) else: content.write(printdeck(deck)) content.write("
\n
\n

Low priority

\n") for deck in decklist: if deck["priority"] == 3 and deck["mastered"] == False: if colour: if deck["colour"] == colour: content.write(printdeck(deck)) else: content.write(printdeck(deck)) content.write("
\n") content.close() footerwrite(thefile) def collectingall(): collectinggen() for thevalue in values: collectinggen(thevalue) if __name__ == "__main__": collectingall() print("Building mass collecting pages") masslist = sorted(list(variables.masscollect.keys())) def massindexgen(): if not os.path.isdir("build/mass"): os.mkdir("build/mass") thefile = "build/mass/index.html" if os.path.exists(thefile): os.remove(thefile) headerwrite(thefile,"mass") content = open(thefile,"a") content.write("

mass collecting/keeping

\n\n") content.close() footerwrite(thefile) def massseriesgen(series,massindex): if not os.path.isdir("build/mass/" + str(massindex)): os.mkdir("build/mass/" + str(massindex)) thefile = "build/mass/" + str(massindex) + "/index.html" if os.path.exists(thefile): os.remove(thefile) headerwrite(thefile,"mass") content = open(thefile,"a") content.write("

" + series + "

\n

0: content.write("/" + variables.subfolder) content.write("/mass\">back to mass decks page

\n

") for deck in decklist: if deck["mastered"]: if series in deck["mass"] or series in deck["massmaster"]: content.write(" 0: content.write("/" + variables.subfolder) content.write("/decks/" + deck["name"] + "/master.gif\" title=\"mastered " + deck["name"]) try: if deck["name"] in variables.firstmasteries: content.write(" (first)\" class=\"first") except: pass content.write("\">") content.write("

") for card in cardlist: if series in card["mass"]: if card["dupe"] == False: content.write(printcard(card)) content.write("

\n") content.close() footerwrite(thefile) def massall(): massindexgen() massindex = 1 for series in masslist: massseriesgen(series,massindex) massindex += 1 if __name__ == "__main__": massall() print("Building mastered page") def masteredgen(colour=False): if not os.path.isdir("build/mastered"): os.mkdir("build/mastered") if colour: if not os.path.isdir("build/mastered/" + colour): os.mkdir("build/mastered/" + colour) thefile = "build/mastered/" + colour + "/index.html" else: thefile = "build/mastered/index.html" if os.path.exists(thefile): os.remove(thefile) headerwrite(thefile,"mastered") content = open(thefile,"a") content.write("

mastered decks

\n") content.write(filterwrite("mastered",colour)) for deck in decklist: if deck["mastered"]: if colour: if deck["colour"] == colour: content.write(printdeck(deck)) else: content.write(printdeck(deck)) content.close() footerwrite(thefile) def masteredall(): masteredgen() for thevalue in values: masteredgen(thevalue) if __name__ == "__main__": masteredall() print("Building trading page") tradelist = [] sigtradelist = [] for card in cardlist: if card["priority"] == 4: tradelist.append(card) elif card["priority"] == 5: sigtradelist.append(card) alltradelist = tradelist + sigtradelist def tradegen(colour=False): if not os.path.isdir("build/trade"): os.mkdir("build/trade") if colour: if not os.path.isdir("build/trade/" + colour): os.mkdir("build/trade/" + colour) thefile = "build/trade/" + colour + "/index.html" else: thefile = "build/trade/index.html" if os.path.exists(thefile): os.remove(thefile) headerwrite(thefile,"trade") content = open(thefile,"a") content.write("

available for trade

\n" + filterwrite("trade",colour,True) + "

") if len(variables.tradestatement) > 0: content.write(variables.tradestatement + " ") content.write("Trade cards here

\n

\n

") for card in alltradelist: if colour: if card["colour"] == colour: content.write(printcard(card)) else: content.write(printcard(card)) content.write("

\n") content.close() footerwrite(thefile) def tradeall(): tradegen() for thevalue in values: tradegen(thevalue) tradegen("sig") if __name__ == "__main__": tradeall() print("Building wanted page") def wantedgen(): if not os.path.isdir("build/wanted"): os.mkdir("build/wanted") if os.path.exists("build/wanted/index.html"): os.remove("build/wanted/index.html") thefile = "build/wanted/index.html" headerwrite(thefile,"wanted") content = open(thefile,"a") content.write("

wanted cards

\n

High priority

\n\n

") for card in wantedlist: if card["priority"] == 1: if precomma: content.write(", ") content.write(cardtext(card)) precomma = True precomma = False content.write("

\n

Medium priority

\n\n

") for card in wantedlist: if card["priority"] == 2: if precomma: content.write(", ") content.write(cardtext(card)) precomma = True precomma = False content.write("

\n

Low priority

\n\n

") for card in wantedlist: if card["priority"] == 3: if precomma: content.write(", ") content.write(cardtext(card)) precomma = True content.write("

\n") content.close() footerwrite(thefile) if __name__ == "__main__": wantedgen() print("Building search page") def searchgen(): if not os.path.isdir("build/search"): os.mkdir("build/search") thefile = "build/search/index.html" if os.path.exists(thefile): os.remove(thefile) headerwrite(thefile,"search") content = open(thefile,"a") content.write("

card search

\n
\n \n \n \n
\n

\n

\n

\n

\n

\n

\n

\n\n \n \n") content.close() if __name__ == "__main__": searchgen() print("Building log page") def loggen(month=False): if month: if not os.path.isdir("build/log/month"): os.mkdir("build/log/month") if os.path.exists("build/log/month/index.html"): os.remove("build/log/month/index.html") thefile = "build/log/month/index.html" else: if not os.path.isdir("build/log"): os.mkdir("build/log") if os.path.exists("build/log/index.html"): os.remove("build/log/index.html") thefile = "build/log/index.html" headerwrite(thefile,"log") content = open(thefile,"a") content.write("

log

\n

") if month: content.write(" 0: content.write("/" + variables.subfolder) content.write("/log\">Show all") else: content.write(" 0: content.write("/" + variables.subfolder) content.write("/log/month\">Show current month only") content.write("

\n") for event in logitems: if month: if event["date"].month == datetime.datetime.now().month and event["date"].year == datetime.datetime.now().year: admit = True else: admit = False else: admit = True if admit == True: content.write("

" + event["date"].strftime("%Y-%m-%d") + " [" + event["name"] + "]: ") try: if event["received"]: content.write("Received ") receivedlist = sorted(event["received"], key=lambda d: d["name"]) position = 1 for card in receivedlist: content.write(cardtext(card)) if len(receivedlist) != position: content.write(", ") position += 1 content.write(".") try: if event["lost"]: content.write(" ") except: try: if event["crayons"]: content.write(" ") except: pass except: pass try: if event["lost"]: content.write("Lost ") lostlist = sorted(event["lost"], key=lambda d: d["name"]) position = 1 for card in lostlist: content.write(cardtext(card)) if len(lostlist) != position: content.write(", ") position += 1 content.write(".") try: if event["crayons"]: content.write(" ") except: pass except: pass try: if event["crayons"]: content.write("Crayons: ") try: content.write(crayonlog("red",event)) if list(event["crayons"])[-1] != "red": content.write(", ") except: pass try: content.write(crayonlog("orange",event)) if list(event["crayons"])[-1] != "orange": content.write(", ") except: pass try: content.write(crayonlog("yellow",event)) if list(event["crayons"])[-1] != "yellow": content.write(", ") except: pass try: content.write(crayonlog("green",event)) if list(event["crayons"])[-1] != "green": content.write(", ") except: pass try: content.write(crayonlog("blue",event)) if list(event["crayons"])[-1] != "blue": content.write(", ") except: pass try: content.write(crayonlog("purple",event)) if list(event["crayons"])[-1] != "purple": content.write(", ") except: pass try: content.write(crayonlog("brown",event)) if list(event["crayons"])[-1] != "brown": content.write(", ") except: pass try: content.write(crayonlog("grey",event)) except: pass content.write(".") except: pass content.write("

\n") content.close() footerwrite(thefile) def logall(): loggen(False) loggen(True) if __name__ == "__main__": logall()