Best Python code snippet using autotest_python
create_bench_db.py
Source:create_bench_db.py
...71 global chan_id72 chan_id = chan_id + 1;73 print "INSERT INTO channel (id,name,owner) VALUE ("+`chan_id`+",'"+name+"','"+owner+"');"74 return chan_id75def insert_property(channel, name, owner, value):76 global next_prop, prop_id, props77 if (not name in props):78 next_prop = next_prop + 179 props[name] = next_prop80 prop_id = next_prop81 print "INSERT INTO property (id,name,owner,is_tag) VALUE ("+`prop_id`+",'"+name+"','"+owner+"',FALSE);"82 else:83 prop_id = props[name]84 print "INSERT INTO value (channel_id,property_id,value) VALUE ("+`channel`+","+`prop_id`+",'"+value+"');"85def insert_tag(channel, name, owner):86 global next_prop, prop_id, props87 if (not name in props):88 next_prop = next_prop + 189 props[name] = next_prop90 prop_id = next_prop91 print "INSERT INTO property (id,name,owner,is_tag) VALUE ("+`prop_id`+",'"+name+"','"+owner+"',TRUE);"92 else:93 prop_id = props[name]94 print "INSERT INTO value (channel_id,property_id) VALUE ("+`channel`+","+`prop_id`+");"95# for dummy channel information96def insert_bunch(count, prefix, midfix, postfix, location, cell, element, device, unit, sigtype):97 global chan_in_cell, buckets, val_bucket, full_buckets98 if (count > 9):99 cw = 2100 else:101 cw = 1102 for n in range(1,count+1):103 if (count == 1):104 cid = insert_channel(prefix+`cell`.zfill(3)+"-"+midfix+postfix, cowner)105 else:106 cid = insert_channel(prefix+`cell`.zfill(3)+"-"+midfix+`n`.zfill(cw)+postfix, cowner)107 chan_in_cell += 1108# Insert "real" properties109 insert_property(cid,"location",powner,location)110 insert_property(cid,"cell",powner,`cell`.zfill(3))111 insert_property(cid,"element",powner,element)112 insert_property(cid,"device",powner,device)113 if (count != 1):114 insert_property(cid,"family",powner,`n`.zfill(cw))115 insert_property(cid,"unit",powner,unit)116 insert_property(cid,"type",powner,sigtype)117 pos_c = round((10.0/(count+1)) * n, 3)118 insert_property(cid,"z pos r",powner,'%.3f' % pos_c)119 insert_property(cid,"z pos a",powner,'%.3f' % (pos_c+(cell-1)*10.0))120 if (postfix.endswith("}T:1-RB")):121 insert_property(cid,"mount",powner,"outside")122 elif (postfix.endswith("}T:2-RB")):123 insert_property(cid,"mount",powner,"inside")124 elif (postfix.endswith("}T:3-RB")):125 insert_property(cid,"mount",powner,"top")126 elif (postfix.endswith("}T:4-RB")):127 insert_property(cid,"mount",powner,"bottom")128 else:129 insert_property(cid,"mount",powner,"center")130# group0 ... group5: Random distributions of 500/200/100/50/20/10/5/2/1 values and tags131 for g in range(0, 6):132 inx = random.randint(0, len(tokens[g])-1)133 val = tokens[g].pop(inx)134 insert_property(cid,"group"+`g`,powner,val)135 insert_tag(cid,"group"+`g`+"-"+val,towner)136# group6 ... group9: Ordered distributions of 500/200/100/50/20/10/5/2/1 values and tags137 if (chan_in_cell%2 == 1):138 insert_property(cid,"group6",powner,"500")139 insert_tag(cid,"group6-500",towner)140 elif (chan_in_cell <= 2*200):141 insert_property(cid,"group6",powner,"200")142 insert_tag(cid,"group6-200",towner)143 elif (chan_in_cell <= 2*(200+100)):144 insert_property(cid,"group6",powner,"100")145 insert_tag(cid,"group6-100",towner)146 elif (chan_in_cell <= 2*(200+100+50)):147 insert_property(cid,"group6",powner,"50")148 insert_tag(cid,"group6-50",towner)149 elif (chan_in_cell <= 2*(200+100+50+20)):150 insert_property(cid,"group6",powner,"20")151 insert_tag(cid,"group6-20",towner)152 elif (chan_in_cell <= 2*(200+100+50+20+10)):153 insert_property(cid,"group6",powner,"10")154 insert_tag(cid,"group6-10",towner)155 elif (chan_in_cell <= 2*(200+100+50+20+10+5)):156 insert_property(cid,"group6",powner,"5")157 insert_tag(cid,"group6-5",towner)158 elif (chan_in_cell <= 2*(200+100+50+20+10+5+2)):159 insert_property(cid,"group6",powner,"2")160 insert_tag(cid,"group6-2",towner)161 elif (chan_in_cell <= 2*(200+100+50+20+10+5+2+1)):162 insert_property(cid,"group6",powner,"1")163 insert_tag(cid,"group6-1",towner)164 else:165 insert_property(cid,"group6",powner,"0")166 insert_tag(cid,"group6-0",towner)167 if (chan_in_cell%2 == 0):168 insert_property(cid,"group7",powner,"500")169 insert_tag(cid,"group7-500",towner)170 elif (chan_in_cell <= 2*200):171 insert_property(cid,"group7",powner,"200")172 insert_tag(cid,"group7-200",towner)173 elif (chan_in_cell <= 2*(200+100)):174 insert_property(cid,"group7",powner,"100")175 insert_tag(cid,"group7-100",towner)176 elif (chan_in_cell <= 2*(200+100+50)):177 insert_property(cid,"group7",powner,"50")178 insert_tag(cid,"group7-50",towner)179 elif (chan_in_cell <= 2*(200+100+50+20)):180 insert_property(cid,"group7",powner,"20")181 insert_tag(cid,"group7-20",towner)182 elif (chan_in_cell <= 2*(200+100+50+20+10)):183 insert_property(cid,"group7",powner,"10")184 insert_tag(cid,"group7-10",towner)185 elif (chan_in_cell <= 2*(200+100+50+20+10+5)):186 insert_property(cid,"group7",powner,"5")187 insert_tag(cid,"group7-5",towner)188 elif (chan_in_cell <= 2*(200+100+50+20+10+5+2)):189 insert_property(cid,"group7",powner,"2")190 insert_tag(cid,"group7-2",towner)191 elif (chan_in_cell <= 2*(200+100+50+20+10+5+2+1)):192 insert_property(cid,"group7",powner,"1")193 insert_tag(cid,"group7-1",towner)194 else:195 insert_property(cid,"group7",powner,"0")196 insert_tag(cid,"group7-0",towner)197 if (chan_in_cell <= 500):198 insert_property(cid,"group8",powner,"500")199 insert_tag(cid,"group8-500",towner)200 elif (chan_in_cell <= 500+200):201 insert_property(cid,"group8",powner,"200")202 insert_tag(cid,"group8-200",towner)203 elif (chan_in_cell <= 500+(200+100)):204 insert_property(cid,"group8",powner,"100")205 insert_tag(cid,"group8-100",towner)206 elif (chan_in_cell <= 500+(200+100+50)):207 insert_property(cid,"group8",powner,"50")208 insert_tag(cid,"group8-50",towner)209 elif (chan_in_cell <= 500+(200+100+50+20)):210 insert_property(cid,"group8",powner,"20")211 insert_tag(cid,"group8-20",towner)212 elif (chan_in_cell <= 500+(200+100+50+20+10)):213 insert_property(cid,"group8",powner,"10")214 insert_tag(cid,"group8-10",towner)215 elif (chan_in_cell <= 500+(200+100+50+20+10+5)):216 insert_property(cid,"group8",powner,"5")217 insert_tag(cid,"group8-5",towner)218 elif (chan_in_cell <= 500+(200+100+50+20+10+5+2)):219 insert_property(cid,"group8",powner,"2")220 insert_tag(cid,"group8-2",towner)221 elif (chan_in_cell <= 500+(200+100+50+20+10+5+2+1)):222 insert_property(cid,"group8",powner,"1")223 insert_tag(cid,"group8-1",towner)224 else:225 insert_property(cid,"group8",powner,"0")226 insert_tag(cid,"group8-0",towner)227 if (chan_in_cell > 500):228 insert_property(cid,"group9",powner,"500")229 insert_tag(cid,"group9-500",towner)230 elif (chan_in_cell > 500-200):231 insert_property(cid,"group9",powner,"200")232 insert_tag(cid,"group9-200",towner)233 elif (chan_in_cell > 500-200-100):234 insert_property(cid,"group9",powner,"100")235 insert_tag(cid,"group9-100",towner)236 elif (chan_in_cell > 500-200-100-50):237 insert_property(cid,"group9",powner,"50")238 insert_tag(cid,"group9-50",towner)239 elif (chan_in_cell > 500-200-100-50-20):240 insert_property(cid,"group9",powner,"20")241 insert_tag(cid,"group9-20",towner)242 elif (chan_in_cell > 500-200-100-50-20-10):243 insert_property(cid,"group9",powner,"10")244 insert_tag(cid,"group9-10",towner)245 elif (chan_in_cell > 500-200-100-50-20-10-5):246 insert_property(cid,"group9",powner,"5")247 insert_tag(cid,"group9-5",towner)248 elif (chan_in_cell > 500-200-100-50-20-10-5-2):249 insert_property(cid,"group9",powner,"2")250 insert_tag(cid,"group9-2",towner)251 elif (chan_in_cell > 500-200-100-50-20-10-5-2-1):252 insert_property(cid,"group9",powner,"1")253 insert_tag(cid,"group9-1",towner)254 else:255 insert_property(cid,"group9",powner,"0")256 insert_tag(cid,"group9-0",towner)257 for p in range(20,max_prop):258 insert_property(cid,"prop"+`p`.zfill(2),powner,`chan_in_cell`+"-"+`p`.zfill(2))259 for p in range(11,max_tag):260 insert_tag(cid,"tag"+`p`.zfill(2),towner)261 if (cell%9 == 0):262 insert_tag(cid,"tagnine",towner)263 elif (cell%8 == 0):264 insert_tag(cid,"tageight",towner)265 elif (cell%7 == 0):266 insert_tag(cid,"tagseven",towner)267 elif (cell%6 == 0):268 insert_tag(cid,"tagsix",towner)269 elif (cell%5 == 0):270 insert_tag(cid,"tagfive",towner)271 elif (cell%4 == 0):272 insert_tag(cid,"tagfour",towner)...
stories_to_neo4j.py
Source:stories_to_neo4j.py
...106 print('æ
äºçº¿å
¥neo4jï¼',story_id,story_name)107 # æ°å»ºæ
äºçº¿èç¹108 story_node = self.build_node(start_node=topic_node,node_ID=story_id,node_type='STORY',node_name='æ
äºçº¿')109 # æå
¥æ
äºçº¿å±æ§110 self.insert_property(properties=[story_id, 'å称', story_name])111 for intend in data['æå¾']:112 intend_id = intend['æå¾ID'].strip().replace('\n','')113 PID = intend['PID']114 if PID:115 PID = PID.strip().replace('\n','')116 intend_name = intend['æå¾'].strip().replace('\n','')117 intend_resp = intend['åå¤'].strip().replace('\n','')118 # æ°å»ºæå¾119 self.build_node(start_node=story_node,node_ID=intend_id,node_type='INTEND',node_name='æå¾')120 # æå
¥æ
äºçº¿å±æ§121 self.insert_property(properties=[intend_id, 'PID', PID])122 self.insert_property(properties=[intend_id, 'é®æ³', intend_name])123 self.insert_property(properties=[intend_id, 'åå¤', intend_resp])124 self.build_Hierarchical_Relation()125if __name__ == '__main__':126 data = [127 {'æ
äºçº¿ID': '1ab1853a-89fc-11ea-8c27-f4d108568a73',128 'æ
äºçº¿å称': 'é®å',129 'æå¾': [{'æå¾ID': 'f14275f0-7d5f-11ea-9bb0-f4d108568a73_f1433728-7d5f-11ea-8f7d-f4d108568a73',130 'PID': 'none',131 'æå¾': 'æè¦åæ´»æ/åæ´»æ/ææ³åæ´»æ/ææ³åç¹æ´»æ/æè¦åç¹æ´»æå款/åç¹æ´»æ',132 'åå¤': '请é®æ¨å¨æè¡æè´¦æ·åï¼',133 'ä¸æ ': [7, 1]}]134 }135 ]136 scene_id = 'fzdh'137 topic_id = 'whzj'...
di.py
Source:di.py
...7 pt = self.view.sel()[0].begin()8 if not self.view.match_selector(pt, "source.cfml meta.class"):9 return10 if property_name:11 self.insert_property(edit, property_name)12 return13 cfml_view = CfmlView(self.view, pt)14 if not cfml_view.project_name:15 return16 cfc_info, metadata, function_name, regions = documentation.find_cfc(cfml_view)17 if cfc_info:18 self.insert_property(edit, cfc_info["name"])19 else:20 cfc_list = cfcs.get_cfc_list(cfml_view.project_name)21 def callback(i):22 if i > -1:23 self.view.run_command(24 "cfml_di_property", {"property_name": cfc_list[i]}25 )26 self.view.window().show_quick_panel(27 cfc_list, callback, flags=sublime.MONOSPACE_FONT28 )29 def insert_property(self, edit, property_name):30 di_property = self.get_setting("di_property")31 is_script = (32 len(self.view.find_by_selector("source.cfml.script meta.class.body.cfml"))33 > 034 )35 property_string = (36 di_property.get("script_template", "")37 if is_script38 else di_property.get("tag_template", "")39 )40 if "{name}" not in property_string:41 return42 properties = self.view.find_by_selector("meta.tag.property.cfml")43 property_names = [...
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!!