How to use copy_files method in avocado

Best Python code snippet using avocado_python

sortdata.py

Source:sortdata.py Github

copy

Full Screen

...19valid_wrist_folder = 'dataset/valid/wrist'20training_set = 021valid_set = 122image_count = 023def copy_files(src: str , dest: str, value: int, model_type: str):24 global image_count25 src_files = os.listdir(src)26 for file_name in src_files:27 full_file_name = os.path.join(src, file_name)28 new_file_name = dest + '/' + str(image_count) + '.png'29 if os.path.isfile(full_file_name):30 shutil.copy(full_file_name, new_file_name)31 image_count += 132 add_to_dataset_file(new_file_name, value, model_type)33 else:34 print("Copy failed :\(")35def add_to_dataset_file(path: str, value: int, model_type: str):36 model_dataset_path = 'dataset/' + model_type + '.csv'37 with open(model_dataset_path, 'a+') as dataset_file:38 dataset_file.write(path + "," + str(value) + '\n')39training_file_name = 'MURA-v1.1/train_labeled_studies.csv'40valid_file_name = 'MURA-v1.1/valid_labeled_studies.csv'41'''42This is to be used to sort the data for the regression models.43'''44with open(training_file_name) as csv_file:45 csv_reader = csv.reader(csv_file, delimiter=',')46 row_count = 147 for row in csv_reader:48 if 'ELBOW' in row[0]:49 # copy_files(row[0], train_elbow_folder)50 if row[1] == '1':51 copy_files(row[0], train_elbow_folder, 100, 'train_elbow')52 else:53 copy_files(row[0], train_elbow_folder, 0, 'train_elbow')54 elif 'FINGER' in row[0]:55 # copy_files(row[0], train_finger_folder)56 if row[1] == '1':57 copy_files(row[0], train_finger_folder, 100, 'train_finger')58 else:59 copy_files(row[0], train_finger_folder, 0, 'train_finger')60 elif 'FOREARM' in row[0]:61 # copy_files(row[0], train_forearm_folder)62 if row[1] == '1':63 copy_files(row[0], train_forearm_folder, 100, 'train_forearm')64 else:65 copy_files(row[0], train_forearm_folder, 0, 'train_forearm')66 elif 'HAND' in row[0]:67 # copy_files(row[0], train_hand_folder)68 if row[1] == '1':69 copy_files(row[0], train_hand_folder, 100, 'train_hand')70 else:71 copy_files(row[0], train_hand_folder, 0, 'train_hand')72 elif 'HUMERUS' in row[0]:73 # copy_files(row[0], train_humerus_folder)74 if row[1] == '1':75 copy_files(row[0], train_humerus_folder, 100, 'train_humerus')76 else:77 copy_files(row[0], train_humerus_folder, 0, 'train_humerus')78 elif 'SHOULDER' in row[0]:79 # copy_files(row[0], train_shoulder_folder)80 if row[1] == '1':81 copy_files(row[0], train_shoulder_folder, 100, 'train_shoulder')82 else:83 copy_files(row[0], train_shoulder_folder, 0, 'train_shoulder')84 elif 'WRIST' in row[0]:85 # copy_files(row[0], train_wrist_folder)86 if row[1] == '1':87 copy_files(row[0], train_wrist_folder, 100, 'train_wrist')88 else:89 copy_files(row[0], train_wrist_folder, 0, 'train_wrist')90 else:91 print("Oops")92 print('Training: ', row_count)93 row_count += 194with open(valid_file_name) as csv_file:95 csv_reader = csv.reader(csv_file, delimiter=',')96 row_count = 197 for row in csv_reader:98 if 'ELBOW' in row[0]:99 # copy_files(row[0], valid_elbow_folder)100 if row[1] == '1':101 copy_files(row[0], valid_elbow_folder, 100, 'valid_elbow')102 else:103 copy_files(row[0], valid_elbow_folder, 0, 'valid_elbow')104 elif 'FINGER' in row[0]:105 # copy_files(row[0], valid_finger_folder)106 if row[1] == '1':107 copy_files(row[0], valid_finger_folder, 100, 'valid_finger')108 else:109 copy_files(row[0], valid_finger_folder, 0, 'valid_finger')110 elif 'FOREARM' in row[0]:111 # copy_files(row[0], valid_forearm_folder)112 if row[1] == '1':113 copy_files(row[0], valid_forearm_folder, 100, 'valid_forearm')114 else:115 copy_files(row[0], valid_forearm_folder, 0, 'valid_forearm')116 elif 'HAND' in row[0]:117 # copy_files(row[0], valid_hand_folder)118 if row[1] == '1':119 copy_files(row[0], valid_hand_folder, 100, 'valid_hand')120 else:121 copy_files(row[0], valid_hand_folder, 0, 'valid_hand')122 elif 'HUMERUS' in row[0]:123 # copy_files(row[0], valid_humerus_folder)124 if row[1] == '1':125 copy_files(row[0], valid_humerus_folder, 100, 'valid_humerus')126 else:127 copy_files(row[0], valid_humerus_folder, 0, 'valid_humerus')128 elif 'SHOULDER' in row[0]:129 # copy_files(row[0], valid_shoulder_folder)130 if row[1] == '1':131 copy_files(row[0], valid_shoulder_folder, 100, 'valid_shoulder')132 else:133 copy_files(row[0], valid_shoulder_folder, 0, 'valid_shoulder')134 elif 'WRIST' in row[0]:135 # copy_files(row[0], valid_wrist_folder)136 if row[1] == '1':137 copy_files(row[0], valid_wrist_folder, 100, 'valid_wrist')138 else:139 copy_files(row[0], valid_wrist_folder, 0, 'valid_wrist')140 print('Valid: ', row_count)...

Full Screen

Full Screen

icons.py

Source:icons.py Github

copy

Full Screen

1from os import path2_icon_path_for_customer = {3 "android": "development/android/res/",4 "safari": "development/forge.safariextension/",5 "firefox": "development/firefox/",6 "ios": "development/ios/*.app/",7 "wp": "development/wp/dist/"8}9def customer_phase(build):10 icon_path = _icon_path_for_customer11 def icon(platform, sub_path):12 return path.join(icon_path[platform], sub_path)13 return [14 {'when': {'platform_is': 'android'}, 'do': {'populate_icons': ("android", [36, 48, 72])}},15 {'when': {'platform_is': 'chrome'}, 'do': {'populate_icons': ("chrome", [16, 48, 128])}},16 {'when': {'platform_is': 'firefox'}, 'do': {'populate_icons': ("firefox", [32, 64])}},17 {'when': {'platform_is': 'ios'}, 'do': {'populate_icons': ("ios", [57, 72, 114, 144])}},18 {'when': {'platform_is': 'safari'}, 'do': {'populate_icons': ("safari", [32, 48, 64])}},19 {'when': {'platform_is': 'wp'}, 'do': {'populate_icons': ("wp", [62, 99, 173])}},20 {'when': {'platform_is': 'android', 'icon_available': ('android', '36')}, 'do': {'copy_files': {21 'from': '${modules["icons"]["android"]["36"]}',22 'to': icon("android", 'drawable-ldpi/icon.png')23 }}},24 {'when': {'platform_is': 'android', 'icon_available': ('android', '48')}, 'do': {'copy_files': {25 'from': '${modules["icons"]["android"]["48"]}',26 'to': icon("android", 'drawable-mdpi/icon.png')27 }}},28 {'when': {'platform_is': 'android', 'icon_available': ('android', '72')}, 'do': {'copy_files': {29 'from': '${modules["icons"]["android"]["72"]}',30 'to': icon("android", "drawable-hdpi/icon.png")31 }}},32 33 {'when': {'platform_is': 'safari', 'icon_available': ('safari', '32')}, 'do': {'copy_files': {34 'from': '${modules["icons"]["safari"]["32"]}',35 'to': icon("safari", 'icon-32.png')36 }}},37 {'when': {'platform_is': 'safari', 'icon_available': ('safari', '48')}, 'do': {'copy_files': {38 'from': '${modules["icons"]["safari"]["48"]}',39 'to': icon("safari", 'icon-48.png')40 }}},41 {'when': {'platform_is': 'safari', 'icon_available': ('safari', '64')}, 'do': {'copy_files': {42 'from': '${modules["icons"]["safari"]["64"]}',43 'to': icon("safari", 'icon-64.png')44 }}},45 46 {'when': {'platform_is': 'firefox', 'icon_available': ('firefox', '32')}, 'do': {'copy_files': {47 'from': '${modules["icons"]["firefox"]["32"]}',48 'to': icon("firefox", 'icon.png')49 }}},50 {'when': {'platform_is': 'firefox', 'icon_available': ('firefox', '64')}, 'do': {'copy_files': {51 'from': '${modules["icons"]["firefox"]["64"]}',52 'to': icon("firefox", 'icon64.png')53 }}},54 {'when': {'platform_is': 'ios', 'icon_available': ('ios', '57')}, 'do': {'copy_files': {55 'from': '${modules["icons"]["ios"]["57"]}',56 'to': icon("ios", 'normal.png')57 }}},58 {'when': {'platform_is': 'ios', 'icon_available': ('ios', '72')}, 'do': {'copy_files': {59 'from': '${modules["icons"]["ios"]["72"]}',60 'to': icon("ios", 'ipad.png')61 }}},62 {'when': {'platform_is': 'ios', 'icon_available': ('ios', '114')}, 'do': {'copy_files': {63 'from': '${modules["icons"]["ios"]["114"]}',64 'to': icon("ios", 'retina.png')65 }}},66 {'when': {'platform_is': 'ios', 'icon_available': ('ios', '144')}, 'do': {'copy_files': {67 'from': '${modules["icons"]["ios"]["144"]}',68 'to': icon("ios", 'ipad-retina.png')69 }}},70 {'when': {'platform_is': 'wp', 'icon_available': ('wp', '64')}, 'do': {'copy_files': {71 'from': '${modules["icons"]["wp"]["62"]}',72 'to': icon("wp", 'ApplicationIcon.png')73 }}},74 {'when': {'platform_is': 'wp', 'icon_available': ('wp', '99')}, 'do': {'copy_files': {75 'from': '${modules["icons"]["wp"]["99"]}',76 'to': icon("wp", 'Marketplace.png')77 }}},78 {'when': {'platform_is': 'wp', 'icon_available': ('wp', '173')}, 'do': {'copy_files': {79 'from': '${modules["icons"]["wp"]["173"]}',80 'to': icon("wp", 'Background.png')81 }}},82 {'when': {'platform_is': 'wp', 'have_wp_launch': ()}, 'do': {'copy_files': {83 'from': '${modules["launchimage"]["wp-landscape"]}',84 'to': icon("wp", "SplashScreenImage.jpg")85 }}},86 87 {'when': {'platform_is': 'ios', 'config_property_true': 'modules.icons.ios.prerendered'}, 'do': {88 'set_in_biplist': {89 "filename": 'development/ios/*/Info.plist',90 "key": "UIPrerenderedIcon",91 "value": True92 },93 }},94 {'when': {'platform_is': 'ios', 'config_property_true': 'modules.icons.ios.prerendered'}, 'do': {95 'set_in_biplist': {96 "filename": 'development/ios/*/Info.plist',97 "key": "CFBundleIcons.CFBundlePrimaryIcon.UIPrerenderedIcon",98 "value": True99 },100 }},...

Full Screen

Full Screen

link_wheels_from_caches.py

Source:link_wheels_from_caches.py Github

copy

Full Screen

1#!/usr/bin/env python32"""Harvest wheels from pip & poetry caches and create a repo from them."""3import os4import sys5from pathlib import Path6from shutil import copy7from cache_paths import PIP_WHEELS_PATH, POETRY_ARTIFACTS_PATH8CACHE_WHEELS_PATH = Path("./cache/packages/wheels")9def link_artifact(cached_artifact_path, copy_files):10 """Link an artifact in the cache tree into the wheels directory."""11 dest_path = CACHE_WHEELS_PATH / cached_artifact_path.name12 dest_path.unlink(missing_ok=True)13 if copy_files:14 copy(cached_artifact_path, dest_path)15 else:16 dest_path.symlink_to(cached_artifact_path)17 print(".", end="")18def link_cached_dir(dir_name, copy_files):19 """Recursively link artifacts in a cached artifacts subdir."""20 for root_dirname, _, filenames in os.walk(dir_name):21 root_path = Path(root_dirname)22 for filename in filenames:23 full_path = root_path / filename24 if full_path.is_dir():25 link_cached_dir(full_path, copy_files)26 continue27 link_artifact(full_path, copy_files)28def link_cached_artifacts(copy_files):29 """Link all the cached poetry artifacts into the wheels dir."""30 print("Linking cached artifacts from ", end="")31 CACHE_WHEELS_PATH.mkdir(parents=True, exist_ok=True)32 print("poetry", end="")33 link_cached_dir(POETRY_ARTIFACTS_PATH, copy_files)34 print("pip", end="")35 link_cached_dir(PIP_WHEELS_PATH, copy_files)36 print("done.")37def main(args):38 """Copy the wheels and build the repo."""39 copy_files = "copy" in args40 link_cached_artifacts(copy_files)41if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful