Best Python code snippet using stestr_python
CreateJson.py
Source: CreateJson.py
...13 return [p.name for p in d.iterdir() if p.is_dir()]14 else:15 print("Error - the given path does not point to a directory")16'''17parse_enumeration() takes the list of folder names enumarated by18the explore_directory function. The folder names follow a specific19format: #_englishname_chinesename20where # represents the folder number and is required21where englishname represents the english name and is required22where chinesename represents the chinese name and is NOT required23each parameter is seperated by a single '_' character24'''25def parse_enumeration(e_list: [str]) -> {str : [str]}:26 parsed = dict()27 for folder_name in e_list:28 components = folder_name.split('_')29 if components[0].isdigit()==False:30 continue 31 parsed.update({components[0] : components[1:]})32 return parsed33'''34write_json_to_file() takes the output of parse_enumeration() and35writes to a json file with the specified name.36'''37def write_json_to_file(e_dict: dict, filename: str) -> None:38 with open(os.path.dirname(os.path.realpath(__file__))+"/"+filename, 'w') as out:39 json.dump(e_dict, out, ensure_ascii=False)40if __name__ == '__main__':...
process-request.py
Source: process-request.py
1#!/usr/bin/python2import cgi3import cgitb4import json5import parse_enumeration6cgitb.enable()7form = cgi.FieldStorage() 8# Get data from fields9callback = form.getvalue('callback')10email = form.getvalue('email')11if (email is None):12 email = "<ul><li>hello, world!</li></ul>"13print "Content-type: application/json"14print 15response = parse_enumeration.parse_enumerations(email)16d = json.JSONEncoder().encode((response))17if (callback):18 print callback+'(' + d + ');'19else:...
Check out the latest blogs from LambdaTest on this topic:
In recent times, many web applications have been ported to mobile platforms, and mobile applications are also created to support businesses. However, Android and iOS are the major platforms because many people use smartphones compared to desktops for accessing web applications.
The web paradigm has changed considerably over the last few years. Web 2.0, a term coined way back in 1999, was one of the pivotal moments in the history of the Internet. UGC (User Generated Content), ease of use, and interoperability for the end-users were the key pillars of Web 2.0. Consumers who were only consuming content up till now started creating different forms of content (e.g., text, audio, video, etc.).
Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.
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!!