How to use _new_name method in hypothesis

Best Python code snippet using hypothesis

editor_2_1.py

Source: editor_2_1.py Github

copy

Full Screen

1import os2from os.path import join, getsize3import pathlib4from pathlib import Path5import time6import shutil7directory = '/​mnt/​hdd1/​photos/​фото_актуальное_это_заполнять'8directory2 = '/​mnt/​hdd1/​photos/​photo_mix2'9path_list = Path(directory2, "_list.txt")10path_errors_list = Path(directory2, "_errors.txt")11photos_list = open(path_list, 'w')12errors_list = open(path_errors_list, 'w')13count = 014count_trash = 015for root, dirs, files in os.walk(directory):16 for file_ in files:17 file = file_.upper()18 count += 119 #if count == 300:20 # break21 _path = Path(root, file_) # not upper22 fn, file_extension_ = os.path.splitext(file)23 file_extension = file_extension_.upper()24 if file_extension == '.THM' or file_extension == '.DB' or file_extension == '.JSON' \25 or file_extension == '.INFO' or file_extension == '.HTML':26 count -= 127 count_trash += count_trash28 continue29 _time = time.gmtime(os.path.getmtime(_path))30 _new_name = time.strftime("%Y-%m-%d %H-%M-%S", _time) + file_extension31 _new_path = Path(directory2, _new_name)32 check_file = os.path.isfile(_new_path)33 if check_file == False:34 #write line to the list.txt and copy file35 photos_list.writelines("s:" + root + "/​" + file + " new:" + _new_name + '\n')36 shutil.copy2(_path, _new_path)37 else:38 _new_name = time.strftime("%Y-%m-%d %H-%M-%S", _time) + "_" + file39 _new_path = Path(directory2, _new_name)40 photos_list.writelines("s:" + root + "/​" + file + " new:" + _new_name + '\n')41 shutil.copy2(_path, _new_path)42 errors_list.writelines("err s:" + root + "/​" + file + " new:" + _new_name + '\n')43 #print('****************' + str(count) + " " + root + "/​" + file + " " + _new_name)44 print(str(count) + " " + root + "/​" + file + " " + _new_name)45 else:46 continue47 break48photos_list.close()49errors_list.close()50print("The end")51print('transmit = ' + str(count))52print('trash = ' + str(count_trash))53count_all = count + count_trash54print('all = ' + str(count_all))55import os56from os.path import join, getsize57import pathlib58from pathlib import Path59import time60import shutil61directory = '/​mnt/​hdd1/​photos/​mix02_no_sort'62directory2 = '/​mnt/​hdd1/​photos/​photo_mix1'63path_list = Path(directory2, "_list.txt")64path_errors_list = Path(directory2, "_errors.txt")65photos_list = open(path_list, 'w')66errors_list = open(path_errors_list, 'w')67count = 068count_trash = 069for root, dirs, files in os.walk(directory):70 for file_ in files:71 file = file_.upper()72 count += 173 #if count == 300:74 # break75 _path = Path(root, file_) # not upper76 fn, file_extension_ = os.path.splitext(file)77 file_extension = file_extension_.upper()78 if file_extension == '.THM' or file_extension == '.DB' or file_extension == '.JSON' \79 or file_extension == '.INFO' or file_extension == '.HTML':80 count -= 181 count_trash += count_trash82 continue83 _time = time.gmtime(os.path.getmtime(_path))84 _new_name = time.strftime("%Y-%m-%d %H-%M-%S", _time) + file_extension85 _new_path = Path(directory2, _new_name)86 check_file = os.path.isfile(_new_path)87 if check_file == False:88 #write line to the list.txt and copy file89 photos_list.writelines("s:" + root + "/​" + file + " new:" + _new_name + '\n')90 shutil.copy2(_path, _new_path)91 else:92 _new_name = time.strftime("%Y-%m-%d %H-%M-%S", _time) + "_" + file93 _new_path = Path(directory2, _new_name)94 photos_list.writelines("s:" + root + "/​" + file + " new:" + _new_name + '\n')95 shutil.copy2(_path, _new_path)96 errors_list.writelines("err s:" + root + "/​" + file + " new:" + _new_name + '\n')97 #print('****************' + str(count) + " " + root + "/​" + file + " " + _new_name)98 print(str(count) + " " + root + "/​" + file + " " + _new_name)99 else:100 continue101 break102photos_list.close()103errors_list.close()104print("The end")105print('transmit = ' + str(count))106print('trash = ' + str(count_trash))107count_all = count + count_trash...

Full Screen

Full Screen

material_class_file.py

Source: material_class_file.py Github

copy

Full Screen

1# coding=utf-82import json3from tkinter import messagebox4import re5class MaterialProperties:6 """ define and retrieve material properties """7 def __init__(self, name=None):8 self.material_name = name9 self.material_file = "./​data/​settings_files/​materials.json"10 self.material_list = []11 self.material_json = {}12 self.density = 0.13 self.specific_heat = 0.14 self.conductivity = 0.15 self.melting_point = 0.16 self.emissivity = 0.17 self.reflectivity = 0.18 self.get_material_list()19 def get_material_list(self):20 with open(self.material_file, 'r') as _jsfile:21 _data = json.load(_jsfile)22 self.material_list = []23 for _key in _data:24 self.material_list.append(_key)25 self.material_list.sort()26 def read_from_json(self, material_name):27 with open(self.material_file, 'r') as _jsfile:28 _data = json.load(_jsfile)29 self.material_name = material_name30 self.density = _data[material_name]["Density"]31 self.specific_heat = _data[material_name]["SpecificHeat"]32 self.conductivity = _data[material_name]["Conductivity"]33 self.melting_point = _data[material_name]["MeltingTemperature"]34 self.emissivity = _data[material_name]["Emissivity"]35 self.reflectivity = _data[material_name]["Reflectivity"]36 def save_material(self):37 # material name error handling38 if self.material_name is None:39 messagebox.showerror('Error', 'Please enter material name')40 else:41 if self.material_name in self.material_list:42 _new_name = self.material_name_test()43 _error_message = ('Material "%s" already exists in database.\n'44 'Would you like to save as "%s"?'45 % (self.material_name, _new_name))46 if messagebox.askyesno('Error', _error_message, icon='warning'):47 self.material_name = _new_name48 self.format_material_as_json()49 self.write_to_json()50 else:51 self.format_material_as_json()52 self.write_to_json()53 def write_to_json(self):54 with open(self.material_file, 'r') as _output_file:55 _existing_data = json.load(_output_file)56 _existing_data.update(self.material_json)57 with open(self.material_file, 'w') as _output_file1:58 json.dump(_existing_data, _output_file1, indent=4)59 def edit_existing_in_json(self):60 _box_title = 'Edit Material?'61 _box_message = ('Are you sure you want to permanently edit "%s"?'62 % self.material_name)63 if messagebox.askyesno(_box_title, _box_message, icon='warning'):64 self.format_material_as_json()65 self.write_to_json()66 def format_material_as_json(self):67 # format properties for JSON dump68 self.material_json = {self.material_name: {69 "Density": self.density,70 "SpecificHeat": self.specific_heat,71 "Conductivity": self.conductivity,72 "MeltingTemperature": self.melting_point,73 "Emissivity": self.emissivity,74 "Reflectivity": self.reflectivity}}75 def material_name_test(self):76 _new_name = self.material_name77 while _new_name in self.material_list:78 _bracketed_words = (re.findall("\((.*?)\)", _new_name))79 _material_version = 080 if len(_bracketed_words) > 0:81 _last_entry = _bracketed_words[-1]82 if _last_entry.isdigit():83 _material_version = int(_last_entry)84 if _material_version > 0:85 _new_name = _new_name[:-len(_last_entry)-3]86 _new_name = "%s (%s)" % (_new_name, _material_version+1)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Joomla Testing Guide: How To Test Joomla Websites

Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.

Now Log Bugs Using LambdaTest and DevRev

In today’s world, an organization’s most valuable resource is its customers. However, acquiring new customers in an increasingly competitive marketplace can be challenging while maintaining a strong bond with existing clients. Implementing a customer relationship management (CRM) system will allow your organization to keep track of important customer information. This will enable you to market your services and products to these customers better.

Why Agile Teams Have to Understand How to Analyze and Make adjustments

How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.

27 Best Website Testing Tools In 2022

Testing is a critical step in any web application development process. However, it can be an overwhelming task if you don’t have the right tools and expertise. A large percentage of websites still launch with errors that frustrate users and negatively affect the overall success of the site. When a website faces failure after launch, it costs time and money to fix.

11 Best Mobile Automation Testing Tools In 2022

Mobile application development is on the rise like never before, and it proportionally invites the need to perform thorough testing with the right mobile testing strategies. The strategies majorly involve the usage of various mobile automation testing tools. Mobile testing tools help businesses automate their application testing and cut down the extra cost, time, and chances of human error.

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 hypothesis 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