Best Python code snippet using robotframework-anywherelibrary
transfer_data.py
Source:transfer_data.py  
...10# Connect to the database11database = local_path + "products.db"12connection = sqlite3.connect(database)13cursor = connection.cursor()14def verify_value(value):15    if value == '':16        return 'No Data'17    return value18# Transfer the data from the csv file to the database19def transfer_products_data(filename):20    with open(filename, 'r') as csv_file:21        csv_reader = csv.reader(csv_file)22        for row in csv_reader:23            # Skip the header row24            if row[0] == 'Uniq Id':25                continue26            # Get the seller ids27            seller_ids = get_seller_ids()28            seller_id = random.choice(seller_ids)29            #! Product's Basic Infos30            product_id = verify_value(row[0])            31            name = verify_value(row[1])32            category = verify_value(row[4])33            price = verify_value(row[7])34            image_url = verify_value(row[15])35            rating = random.choice(arange(0, 5.5, 0.5))36            is_best_seller = 037            # Insert the data into the database - "products" table38            try:39                cursor.execute('''40                    INSERT INTO products (product_id, name, category, price, image_url, rating, is_best_seller) 41                    VALUES (?, ?, ?, ?, ?, ?, ?)42                ''', (product_id, name, category, price, image_url, rating, is_best_seller))43                connection.commit()44            except sqlite3.IntegrityError:45                connection.rollback()46            #! Product's Details47            model_number = verify_value(row[9])48            about_product = verify_value(row[10])49            product_specification = verify_value(row[11])50            technical_details = verify_value(row[12])51            shipping_weight = verify_value(row[13])52            product_dimensions = verify_value(row[14])53            upc_ean_code = verify_value(row[5])54            seller_id = seller_id[0]55            product_url = verify_value(row[18])56            # Insert the data into the database - "product_details" table57            try:58                cursor.execute('''59                    INSERT INTO product_details (product_id, model_number, about_product, product_specification, technical_details, shipping_weight, product_dimensions, upc_ean_code, seller_id, product_url)60                    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)61                ''', (product_id, model_number, about_product, product_specification, technical_details, shipping_weight, product_dimensions, upc_ean_code, seller_id, product_url))62                connection.commit()63            except sqlite3.IntegrityError:64                connection.rollback()65                66# Transfer the data from the csv file to the database67def transfer_best_sellers_data(filename):68    with open(filename, 'r') as csv_file:69        csv_reader = csv.reader(csv_file)70        for row in csv_reader:71            # Skip the header row72            if row[0] == 'ASIN':73                continue74            #! Best Seller's Basic Infos75            product_id = verify_value(row[0] + row[21])            76            name = verify_value(row[3])77            category = verify_value(row[2])78            price = verify_value(row[8])79            image_url = verify_value(row[4])80            rating = verify_value(row[16])81            is_best_seller = 182            # Insert the data into the database - "products" table83            try:84                cursor.execute('''85                    INSERT INTO products (product_id, name, category, price, image_url, rating, is_best_seller) 86                    VALUES (?, ?, ?, ?, ?, ?, ?)87                ''', (product_id, name, category, price, image_url, rating, is_best_seller))88                connection.commit()89            except sqlite3.IntegrityError:90                connection.rollback()91            #! Best Seller's Details92            fba_fee = verify_value(row[9])93            fbm_fee = verify_value(row[10])94            height = verify_value(row[11])95            length = verify_value(row[12])96            width = verify_value(row[13])97            weight = verify_value(row[14])98            review_count = verify_value(row[15])99            seller_id = verify_value(row[7])100            # Insert the data into the database - "best_sellers_details" table101            try:102                cursor.execute('''103                    INSERT INTO best_sellers_details (product_id, fba_fee, fbm_fee, height, length, width, weight, review_count, seller_id)104                    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)105                ''', (product_id, fba_fee, fbm_fee, height, length, width, weight, review_count, seller_id))106                connection.commit()107            except sqlite3.IntegrityError:108                connection.rollback()109if __name__ == '__main__':110    products_data = datasets_path + "amazon_dataset.csv"111    transfer_products_data(products_data)112    best_sellers_data = datasets_path + "best_sellers_dataset.csv"113    transfer_best_sellers_data(best_sellers_data)...verify.py
Source:verify.py  
1from printer import print_line2def set_verification(app_data, is_periodic):3    print_line()4    print("[verify]: Setting the verification values ...")5    verify_data = {}6    verify_data['verified'] = False7    verify_data['epsilon'] = 1.0e-88    verify_value = 0.09    Class = app_data['prob_class']10    if Class == 'S':11        if is_periodic == True:12            verify_value = 0.530770700573e-0413        else:14            verify_value = 0.115028215110e-0115    elif Class == 'W':16        if is_periodic == True:17            verify_value = 0.646732937534e-0518        else:19            verify_value = 0.731581264884e-0120    elif Class == 'A':21        if is_periodic == True:22            verify_value = 0.243336530907e-0523        else:24            verify_value = 0.979991065870e-0125    elif Class == 'B':26        if is_periodic == True:27            verify_value = 0.180056440136e-0528        else:29            verify_value = 0.184378110108e+1930    elif Class == 'C':31        if is_periodic == True:32            verify_value = 0.570673228574e-0633        else:34            verify_value = 0.474623829181e+2435    elif Class == 'D':36        if is_periodic == True:37            verify_value = 0.158327506043e-0938        else:39            verify_value = 0.183242406095e+8440    #fi41    verify_data['verify_value'] = verify_value42    app_data['verify_data'] = verify_data43    return44def verify_norm(app_data):45    print_line()46    print("[verify]: Verifying the results ...")47    verify_data = app_data['verify_data']48    rnm2 = app_data['rnm2']49    verify_value = verify_data['verify_value']50    epsilon = verify_data['epsilon']51    err = abs(rnm2 - verify_value) / verify_value52    if err <= epsilon:53        print("[verify]: VERIFICATION SUCCESSFUL")54        print("[verify]: L2 norm            =", rnm2)55        print("[verify]: Error              =", err)56    else:57        print("[verify]: VERIFICATION FAILED")58        print("[verify]: L2 norm            =", rnm2)59        print("[verify]: Correct L2 norm    =", verify_value)60    #fi61    verify_data['verified'] = True...AlipayOpenMiniInnerbaseinfoParameterVerifyModel.py
Source:AlipayOpenMiniInnerbaseinfoParameterVerifyModel.py  
...12    @verify_type.setter13    def verify_type(self, value):14        self._verify_type = value15    @property16    def verify_value(self):17        return self._verify_value18    @verify_value.setter19    def verify_value(self, value):20        self._verify_value = value21    def to_alipay_dict(self):22        params = dict()23        if self.verify_type:24            if hasattr(self.verify_type, 'to_alipay_dict'):25                params['verify_type'] = self.verify_type.to_alipay_dict()26            else:27                params['verify_type'] = self.verify_type28        if self.verify_value:29            if hasattr(self.verify_value, 'to_alipay_dict'):30                params['verify_value'] = self.verify_value.to_alipay_dict()31            else:32                params['verify_value'] = self.verify_value33        return params...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
