示例#1
0
 def frontpage(threshold) -> list:
     """ Function will scrape -> populate_catalogue -> print to terminal """
     ozb_catalog = Catalogue()
     ozb_response = Ozbargain.scrape()
     if ozb_response.status_code == 200:
         ozb_catalog.extract_deals(Ozbargain.scrape().text)
         current_deals = ozb_catalog.populate_catalogue(threshold)
         if len(current_deals) == 0:
             print("No Deals meet the threshold. "
                   "Please lower the Upvote threshold in Options")
         for deal in current_deals:
             deal.print_deal()
             print("*************************\n")
         return current_deals
     else:
         print(f"Status code {ozb_response.status_code}: "
               "Website might be down. Please try again later")
         return []
示例#2
0
        return totalPrice

    def clearCart(self):
        self.cart = []

    def __str__(self):
        skuScanned = "SKUs scanned: "
        for item in self.cart[:-1]:
            skuScanned += item["sku"] + ", "
        skuScanned += self.cart[-1]["sku"]
        expectedTotal = "Total expected: ${0:.2f}".format(self.total())
        return skuScanned + "\n" + expectedTotal


if __name__ == '__main__':
    cat = Catalogue()
    cat.addProduct({"sku": "ipd", "name": "Super iPad", "price": 549.99})
    cat.addProduct({"sku": "mbp", "name": "Macbook Pro", "price": 1399.99})
    cat.addProduct({"sku": "atv", "name": "Apple TV", "price": 109.50})
    cat.addProduct({"sku": "vga", "name": "VGA Adapter", "price": 30.00})
    print(cat)

    pl = PricingRules()
    pl.addXforYDiscount("atv", 3, "atv", 1, datetime.datetime.now().date())
    pl.addBulkDiscount("ipd", 4, 499.99, datetime.datetime.now().date())
    pl.addXforYDiscount("mbp", 1, "vga", 1, datetime.datetime.now().date())

    co = Checkout(cat, pl)

    # Case 1: {atv, atv, atv, vga}
    co.scan("atv")
示例#3
0
                    csv_writer.writerow((batch_id, key, ref_code))
                    progress.save_not_matched(key, ref_code, batch_id)
                    print(
                        f"Could not match folder name {key} to a valid ref code. Tried to use {ref_code}"
                    )

    pool.close()
    print(f"Waiting for Uploads to Complete")
    pool.join()

    print(num_processed)


if __name__ == '__main__':
    config = configparser.ConfigParser()
    config.read('credentials.properties')

    java_home = config['credentials']['java_home']
    catalogue_path = config['credentials']['catalogue.path']
    jar_path = config['credentials']['jar_path']
    document_path = config['credentials']['document.path']
    security_tag = config['credentials']['security.tag']

    catalogue = Catalogue(java_home, catalogue_path, jar_path)
    progress = ProgressDB(java_home, document_path, jar_path)

    main()

    catalogue.close()
    progress.close()
示例#4
0
文件: lon_st.py 项目: carj/LoN
def main():
    config = configparser.ConfigParser()
    config.read('credentials.properties')
    num_processed = 0

    dry_run = bool(
        config['credentials'].get("dry.run", fallback="True") == "True")

    batch_paths = list()
    for i in range(1, 50):
        key = "batch.path.{0}".format(i)
        key = config['credentials'].get(key, "")
        if key:
            batch_paths.append(key)

    java_home = config['credentials']['java_home']
    catalogue_path = config['credentials']['catalogue.path']
    jar_path = config['credentials']['jar_path']
    document_path = config['credentials']['document.path']
    security_tag = config['credentials']['security.tag']

    catalogue = Catalogue(java_home, catalogue_path, jar_path)
    progress = ProgressDB(java_home, document_path, jar_path)

    entity = EntityAPI()

    max_submission = int(config['credentials']['max.submission'])

    numb_submission = int(0)

    for path in batch_paths:
        batch_id = os.path.basename(os.path.dirname(path))
        with open(f"{batch_id}.csv", 'w', newline='') as not_matched_csv:
            csv_writer = csv.writer(not_matched_csv)
            csv_writer.writerow(("Batch ID", "Folder Name", "Ref Code Guess"))
            paths = get_PDF_JPEG_CSV(path)
            document_map = get_document_locations(paths)
            for key in document_map:
                result, ref_code = try_to_find_record_from_folder(
                    key, catalogue)
                if result is not None:
                    in_progress = progress.check_in_progress(ref_code)
                    if in_progress is not None:
                        print(
                            f"{ref_code} found in the in-progress database. Skipping...."
                        )
                        continue
                    system_id = result['id']
                    result = catalogue.get_by_id(system_id)
                    assert result['id'] == system_id
                    identifiers = entity.identifier(ScopeArchivID, system_id)
                    if len(identifiers) == 1:
                        asset = identifiers.pop()
                        print(
                            f"{ref_code} already exists with ref: {asset.reference}. Skipping...."
                        )
                    elif len(identifiers) == 0:
                        print(
                            f"{ref_code} does not exists, creating new asset..."
                        )
                        num_processed = num_processed + 1
                        if dry_run:
                            print(f"Dry-run enabled skipping...")
                            continue
                        else:
                            folder = get_folder(entity, result, catalogue,
                                                security_tag)
                            content_paths = document_map[key]
                            create_package(folder, key, content_paths, config,
                                           result, progress)
                            numb_submission = numb_submission + 1
                            if max_submission > 0:
                                if numb_submission >= max_submission:
                                    print("Max Submission Reached")
                                    return
                    elif len(identifiers) > 1:
                        print("Found Duplicate Assets for {ref_code}")
                else:
                    csv_writer.writerow((batch_id, key, ref_code))
                    progress.save_not_matched(key, ref_code, batch_id)
                    print(
                        f"Could not match folder name {key} to a valid ref code. Tried to use {ref_code}"
                    )

    catalogue.close()
    progress.close()
    print(num_processed)
def test_new_catalogue_current():
    cat = Catalogue("2021 Catalogue")
    assert cat.cat_name == "2021 Catalogue"
    assert cat.candle_list == []
def test_add_candle_puts_candle_in_list():
    cat = Catalogue("2021 Catalogue")
    candle1 = Candle("beach", "name", 54, "Fragrance", "Candle_Type",
                     "Burn_Time", "height", "side", "price")
    cat.add_candle(candle1)
    assert cat.candle_list == [candle1]
def test_list_all_candles_empty_for_new_cat():
    cat = Catalogue("2021 Catalogue")
    list_candles = cat.list_all_candles("Candle list")
    assert list_candles == []