Best Python code snippet using autotest_python
routes.py
Source:routes.py
...33def static_from_root():34 return send_from_directory(app.static_folder, request.path[1:])35@app.route("/index")36def get_index():37 index = request.args.get("index", get_default_index())38 return jsonify(index)39@app.route("/id")40def get_id():41 index = request.args.get("index", get_default_index())42 id = index_to_id(index)43 return jsonify(id)44@app.route("/name")45def get_name():46 index = request.args.get("index", get_default_index())47 name = index_to_name(index)48 return jsonify(name)49@app.route("/app")50def get_app():51 index = request.args.get("index", get_default_index())52 app = index_to_app(index)53 return jsonify(app)54@app.route("/matches")55def get_matches():56 index = request.args.get("index", get_default_index())57 num_matches = request.args.get("n", get_default_num_matches())58 matches = index_to_matches(index, num_matches)59 return jsonify(matches)60@app.route("/similar_apps")61def get_similar_apps():62 index = request.args.get("index", get_default_index())63 num_matches = request.args.get("n", get_default_num_matches())64 mirror_x = request.args.get("mirror", False)65 flip_y = request.args.get("flip", False)66 similar_apps = index_to_similar_apps(67 index, num_matches, mirror_x=bool(mirror_x), flip_y=bool(flip_y)68 )69 return jsonify(similar_apps)70@app.route("/index_from_id")71def get_index_from_id():72 id = request.args.get("id", get_default_id())73 index = id_to_index(id)74 return jsonify(index)75@app.route("/name_from_id")76def get_name_from_id():...
indexed.py
Source:indexed.py
...19class TemplateIndexedNode(TemplateAttribNode):20 def __init__(self, index=1):21 TemplateAttribNode.__init__(self)22 self._index = index23 def get_default_index(self):24 return 125 @property26 def index(self):27 return self._index28 @index.setter29 def index(self, index):30 self._index = index31 def get_index_as_str(self):32 string = ""33 if self.index != self.get_default_index():34 string += " index=%d"%self.index35 return string36 def get_index_as_xml(self):37 xml = ""38 if self.index != self.get_default_index():39 xml += ' index="%d"'%self.index40 return xml41 def set_attrib(self, attrib_name, attrib_value):42 if attrib_name != 'index':43 raise ParserException("Invalid attribute name [%s] for this node" % (attrib_name))44 if isinstance(attrib_value, int):45 self._index = attrib_value46 else:47 try:48 self._index = int(attrib_value)49 except:50 raise ParserException("None numeric format [%s] for this node [%s]", attrib_value, attrib_name)51 #if self._index == 0:52 # raise ParserException("Index values are 1 based, cannot be 0")...
urls.py
Source:urls.py
...12# Serve default deploy folder as site root13if settings.DEBUG:14 urlpatterns += [15 url(16 r'^(?:%s)?$' % get_default_index(deploy_type='dev'),17 serve,18 {19 'document_root': get_deploy_root(deploy_type='dev'), 'path': get_default_index(deploy_type='dev')20 }21 ),22 url(23 r'^(?P<path>.*)$',24 serve,25 {26 'document_root': get_deploy_root(deploy_type='dev')27 }28 ),...
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!!