Best Python code snippet using autotest_python
ui_functions.py
Source: ui_functions.py
...11 self.entry_private_key = private_key12 self.txt_encrypt = encrypt_text13 self.txt_decrypt = decrypt_text1415 def render_entry(self, reference, value):16 reference.delete(0, tk.END)17 reference.insert(0, value)1819 def render_text(self, reference, value):20 reference.delete("1.0", tk.END)21 reference.insert("1.0", value)2223 def open_text_file(self):24 try:25 with io.open(self.get_file(), mode="r", encoding="utf-8") as file:26 content = file.read()27 return content28 except:29 return "Error!"3031 def open_key_file(self):32 try:33 with io.open(self.get_file(), mode="r", encoding="utf-8") as file:34 public, private = file.readlines()35 return public, private36 except:37 return "Error!", "Error!"3839 def get_file(self):40 return tkinter.filedialog.askopenfilename(initialdir="/", title="Choose a file", filetypes=(("Text files", "*.txt"),("All files", "*.*")))4142 def get_path(self):43 return tkinter.filedialog.askdirectory(initialdir="/", title="Choose a directory")4445 def generate_keys(self):46 public, private = rsa.generate_keys()47 self.render_entry(self.entry_public_key, public)48 self.render_entry(self.entry_private_key, private)4950 def get_keys_from_file(self):51 52 public, private = self.open_key_file()53 public.strip()54 private.strip()55 self.render_entry(self.entry_public_key, public)56 self.render_entry(self.entry_private_key, private)57 58 def save_keys_to_file(self):59 public = self.entry_public_key.get()60 private = self.entry_private_key.get()6162 try:63 if(public and private):64 keys = [self.entry_public_key.get()+"\n", self.entry_private_key.get()]65 path = self.get_path()66 67 with io.open(f"{path}/keys.txt", mode="w", encoding="utf-8") as file:68 file.writelines(keys)69 with io.open(f"{path}/public.txt", mode="w", encoding="utf-8") as file:70 file.writelines(self.entry_public_key.get()+"\n")71 else:72 self.render_entry(self.entry_public_key, "Error! Both fields must be filled.")73 except:74 self.render_entry(self.entry_public_key, "Error while saving the file!")7576 def open_plain_text(self):77 content = self.open_text_file()78 self.render_text(self.txt_encrypt, content)7980 def save_file(self):81 try:82 content = self.txt_decrypt.get("1.0", tk.END)83 if(len(content)>1):84 path = self.get_path()85 with io.open(f"{path}/encrypt-it.txt", mode="w", encoding="utf-8") as file:86 file.write(content)87 else:88 self.render_text(self.txt_decrypt, "Error! Field must be filled")
...
journey.py
Source: journey.py
...35 type=int,36 default=500,37 help="Number of entries to download at a time",38)39def render_entry(entry):40 link = entry.entry_url41 frontend_route = "https://bugout.dev/app/personal/"42 api_route_http = "http://spire.bugout.dev/journals/"43 api_route_https = "https://spire.bugout.dev/journals/"44 if link.startswith(api_route_http):45 link = f"{frontend_route}{link[len(api_route_http):]}"46 link = "".join(link.split("/entries"))47 elif link.startswith(api_route_https):48 link = f"{frontend_route}{link[len(api_route_https):]}"49 link = "".join(link.split("/entries"))50 print("- - -")51 print(entry.title)52 print(" Link: {}".format(link))53 print(" Created at: {}".format(entry.created_at))54 print(" Tags:")55 for tag in sorted(entry.tags):56 print(" - {}".format(tag))57 print("- - -")58args = parser.parse_args()59token = args.token60if token is None:61 token = os.environ.get("BUGOUT_ACCESS_TOKEN")62if token is None:63 raise ValueError(64 "Please specify --token or set your BUGOUT_ACCESS_TOKEN environment variable"65 )66journal = args.journal67if journal is None:68 journal = os.environ.get("BUGOUT_JOURNAL_ID")69if journal is None:70 raise ValueError(71 "Please specify --journal or set your BUGOUT_JOURNAL_ID environment variable"72 )73query = " ".join(args.query)74bugout_client = Bugout()75limit = args.batch_size76current_offset = 077results = bugout_client.search(78 token, journal, query, limit=limit, offset=current_offset79)80entries = results.results81total_results = results.total_results82print("Total results:", total_results)83print("")84while len(entries) < total_results:85 print(current_offset)86 current_offset += limit87 results = bugout_client.search(88 token, journal, query, limit=limit, offset=current_offset89 )90 entries.extend(results.results)91timestamped_entries = []92for entry in entries:93 entry_created_at_seconds = parse_date(entry.created_at)94 timestamped_entries.append((entry_created_at_seconds, entry))95timestamped_entries.sort(key=lambda i: i[0])96if timestamped_entries:97 last_timestamp, last_entry = timestamped_entries[0]98 render_entry(last_entry)99 for timestamp, entry in timestamped_entries[1:]:100 print("")101 print(" gap: {}".format(timestamp - last_timestamp))102 print("")103 render_entry(entry)104 last_timestamp = timestamp...
views.py
Source: views.py
...72def random_entry(request):73 entry = random.choice(util.list_entries())74 return HttpResponseRedirect(reverse("encyclopedia:render_entry", kwargs={'q': entry}))75# Encyclopedia entry page76def render_entry(request, q):77 for entry in util.list_entries():78 if entry.lower() == q.lower():79 return render(request, "encyclopedia/entry.html", {80 'entry': markdown2.markdown(util.get_entry(entry)),81 'search': forms.Search(),82 'title': entry83 })84 return render(request, "encyclopedia/notfound.html", {85 'search': forms.Search(),86 'title': q...
Check out the latest blogs from LambdaTest on this topic:
Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.
So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.
Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.
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!!