Пример #1
0
def visible_offers():
    offers = Serialization.load(Amex.Offer.FILE)
    if "-v" in sys.argv:
        return offers
    ignored = Serialization.load(Amex.Offer.IGNOREDFILE)
    visible = [x for x in offers if x not in ignored]
    return visible
Пример #2
0
def main():
    keep_running = True
    while keep_running is True:
        print("\nPick an offer to ignore")
        offers = Serialization.load(Amex.Offer.FILE)
        ignored = Serialization.load(Amex.Offer.IGNOREDFILE)
        visible = [x for x in offers if x not in ignored]
        printlist = [repr(x) for x in visible]
        _, index = Serialization.pick_from_list(printlist, sort=True)
        item = visible[index]

        if query_yes_no("\nAdd to ignore list?"):
            ignored.append(item)
            Serialization.save(ignored, Amex.Offer.IGNOREDFILE)
        print("Added\n")
Пример #3
0
def defaultprint():
    lookup_table = Serialization.load(Amex.CardOffer.FILE)
    cards = Serialization.load(Amex.Card.FILE)
    offers = sorted(visible_offers(), key=lambda x: x.discovered_date)

    groups = itertools.groupby(offers, key=lambda x: x.discovered_date)
    index = 0
    for date, elmts in groups:
        index += 1
        prefix = f"{index} "
        print("\n" * 15)
        print("-----------------------")
        print(f" Discovered: {date}")
        print(f"{prefix}")

        for x in sorted(elmts, key=lambda x: x.site.lower()):
            print_offer(prefix, x, lookup_table, cards)
Пример #4
0
def main():
    accounts = Serialization.load(Account.FILE)
    accounts = [x for x in accounts if x.site == "AmericanExpress"]
    if len(accounts) == 0:
        message = f"No accounts defined in {Account.FILE} with site == \"AmericanExpress\".  Use _EditDatabase.py to add an account."
        raise ValueError(message)

    offers = []
    cards = []
    lookup_table = []
    # loop over accounts
    for account in accounts:
        driver = AmexOffersDriver(account)
        driver.login()
        account_cards = driver.list_cards()
        # store cards
        cards += account_cards
        # loop ofer cards
        for index, card in enumerate(account_cards):
            # one time I got 0 offers, which isn't possible, so I added this loop to try to fix it
            for x in range(2):
                # select card
                driver.select_card_at_index(index)
                # get offers
                card_offers = driver.list_offers()
                # one time I got 0 offers, which isn't possible, so I added this loop to try to fix it
                if len(card_offers) != 0:
                    break
            # update discover date from offer history
            for x in card_offers:
                update_discovered_date(x)
            # append to list of offers
            # should be a set but doesnt hurt to keep as list for ease of coding
            offers += card_offers
            # add to card_offer table
            lookup_table += [Amex.CardOffer(card, x) for x in card_offers]
        driver.quit()

    # store all offers only at end
    # otherwise we lose discovered time on offers we hadn't encountered yet if we hit an exception
    store(offers, cards, lookup_table)
def main():
    print("\nIgnoring offers:")
    ignored = Serialization.load(Amex.Offer.IGNOREDFILE)
    printlist = [repr(x) for x in ignored]
    Serialization.print_list(printlist)
Пример #6
0
 def with_name(cls, fname, lname):
     people = Serialization.load(cls.FILE)
     for p in people:
         if p.first_name.lower() == fname.lower() and p.last_name.lower() == lname.lower():
             return p
     return None
Пример #7
0
def verboseprint():
    offers = Serialization.load(Amex.Offer.FILE)
    printlist = sorted([repr(x) for x in offers], key=str)
    Serialization.print_list(printlist)
Пример #8
0
def get_offers():
    if 'OFFERS' not in globals():
        global OFFERS
        OFFERS = set(Serialization.load(__offers_FILE()))
    return OFFERS