def test_make_list(mocker, make_wb_and_ws): return_value = [('ConfigID', 'ColumnName1', 'ColumnName2', 'ColumnName3'), ('1', '100', '200', '300'), ('1', '1000', '2000', '3000'), ('2', '10000', '20000', '30000')] expect_value = [ { 'ConfigID': '1', 'ColumnName1': '100', 'ColumnName2': '200', 'ColumnName3': '300' }, { 'ConfigID': '1', 'ColumnName1': '1000', 'ColumnName2': '2000', 'ColumnName3': '3000' }, { 'ConfigID': '2', 'ColumnName1': '10000', 'ColumnName2': '20000', 'ColumnName3': '30000' }, ] sheet_name = 'Temp' wb, ws = make_wb_and_ws(sheet_name) mocker.patch.object(ws, 'iter_rows', return_value=return_value) lists = make_list(wb, sheet_name) assert lists == expect_value
def main(): print('hello') # image_list = tools.make_list(r'E:\我的电脑\07_Photo\02_Photo') # tools.remove_duplicate(image_list, r'E:\我的电脑\07_Photo\手机资料20180903\照片')) # image_list = tools.make_list(r'E:\我的电脑\07_Photo\02_Photo') # tools.remove_duplicate(image_list, r'F:\Temp') image_list = tools.make_list(r'F:\Temp') move_images(image_list, r'E:\我的电脑\07_Photo\03_趣图') print('welcome')
def download(self, target_list, source_path): target_list = make_list(target_list) for target_file in target_list: target_file, target_path, target_name, source_name = split_file(target_file) shutil.copy(target_file, '%s/%s' % (source_path, source_name)) #os.system('copy /Y %s %s/%s 1>nul' % (target_file, source_path, source_name))
def upload(self, source_list, target_path): source_list = make_list(source_list) for source_file in source_list: source_file, source_path, source_name, target_name = split_file(source_file) shutil.copy(source_file, '%s/%s' % (target_path, target_name))
def delete(self, target_list): target_list = make_list(target_list) for target_file in target_list: if os.path.exists(target_file): os.remove(target_file)