def GET(self): top() data=web.input() web.ctx.session.idp=data['idp'] web.ctx.session.hintlevel=0 web.ctx.session.hint='' problemdata=db.select('description',data,where='id=$idp') problemdata=problemdata[0] constants=randomgenerator.getRandomConstants(problemdata.constants) arrays=randomgenerator.getRandomArrays(problemdata.arrays) if problemdata.hints is not None: hinttext='hints='+problemdata.hints exec(hinttext) else: hints=None if problemdata.video is not None: videotext='video='+problemdata.video exec(videotext) else : video=None t=problem('<p>'+problemdata.description,arrays,constants,(problemdata.dimension_y,20),problemdata.solutiontext,problemdata.tableexplanation,hints,video) web.ctx.session.instance=t web.ctx.session.problemstatus=2; web.ctx.session.solutionindex=0; commands=re.split('[\n\r]+',problemdata.recurrence) comments=db.query('select * from example_users eu join comment c on c.user_id=eu.id where c.problem_id='+web.ctx.session.idp) mysolution=solutioninstance(solver2.solve(web.ctx.session.instance.lists,web.ctx.session.instance.constants,commands,web.ctx.session.instance.dimensions[0],web.ctx.session.instance.dimensions[1])) render = web.template.render(config.templatedir,base='layout',globals={'context': web.ctx.session}) return render.problemtable(web.ctx.session.instance,mysolution,None,comments)
def test_top_objects_error() -> None: series = [object() for _ in range(4)] if TYPE_CHECKING: reveal_type(series) with pytest.raises(TypeError) as exc: top(series, 3) assert "'<' not supported" in str(exc)
def POST(self): top() i=web.input() data = db.query("SELECT * from achievements a where id="+str(i['achievement_id'])) data=data[0] generator= pdfgenerator() sourceHtml=generator.generateHtml(i['person'],data['title'],data['url']) outputFilename = "/home/marty/web.py/webpy/test.pdf" generator.convertHtmlToPdf(sourceHtml,outputFilename) f=open(outputFilename) return f
def POST(self): top() data=web.input() if 'comment' not in data: data['comment']="x" if 'field' in data: query="REPLACE into survey VALUES({0},\'{1}\',{2},{3},{4},{5},{6},{7},\'{8}\')".format(web.ctx.session.userid,data['field'],data['system'],data['syntax'],data['hints'],data['commandvsmenu'],data['menuconcentration'],data['menurestrictive'],data['comment']) db.query(query) achecker=achievementchecker() message=achecker.awardSurvey(web.ctx.session.userid) return render.survey("Thank you! Survey submitted successfully! You have been awarded the Surveyor Achievement "+message) return render.survey("Something went wrong...Please try again")
def POST(self): top() i=web.input() t=i.view[0] print t variables=dict(myid=t) description=db.select('description',vars=variables,where='id=$myid') problem=db.select('problem',vars=variables,where='id=$myid') problem=problem[0] description=description[0] f=getForm(problem,description) exec("description['constants']="+description['constants']) return render.modify(f,problem,description)
def test_top( series: Tuple[float, ...], length: int, expected: List[float], ) -> None: result = top(series, length) assert expected == result
def GET(self): toprankings = top() mailbody = str(toprankings.GET()) mail.send_mail(sender="*****@*****.**", to="*****@*****.**", subject="Vimgolf rankings: " + str(datetime.utcnow()) + " UTC", body=mailbody.encode('utf-8'))
def hello_world(dut): # `include "packet.sv" # `include "producer.sv" # `include "consumer.sv" # `include "top.sv" # # top mytop; # # initial begin # $timeformat(-9,0," ns",5); # uvm_default_table_printer.knobs.name_width=20; # uvm_default_table_printer.knobs.type_width=50; # uvm_default_table_printer.knobs.size_width=10; # uvm_default_table_printer.knobs.value_width=14; # uvm_config_int::set(null, "top.producer1","num_packets",2); # uvm_config_int::set(null, "top.producer2","num_packets",4); # uvm_config_int::set(null, "*","recording_detail",UVM_LOW); # //uvm_default_printer = uvm_default_tree_printer; # uvm_default_printer.knobs.reference=0; mytop = top("top", parent=None) # uvm_default_table_printer.knobs.type_width=20; yield run_test() if mytop.error: raise Exception("mytop had errors")
def test_top_tuples() -> None: fruit = 'mango pear apple kiwi banana'.split() series: Iterator[Tuple[int, str]] = ((len(s), s) for s in fruit) length = 3 expected = [(6, 'banana'), (5, 'mango'), (5, 'apple')] result = top(series, length) if TYPE_CHECKING: reveal_type(series) reveal_type(expected) reveal_type(result) assert result == expected
def GET(self): toprankings = top() html = str(toprankings.GET()) rss = PyRSS2Gen.RSS2( title="Vimgolf rankings", description="RSS feed for newest Vimgolf rankings", link="http://vimgolf-rank.appspot.com", lastBuildDate=datetime.utcnow(), items=[PyRSS2Gen.RSSItem(title=str(datetime.utcnow()), description=html, pubDate=datetime.utcnow())], ) return rss.to_xml(encoding="utf-8")
def assembly(): # Your code here! a = union() pins = right(5)(pin()) s = union() + down(1 / 2)(slides(pins=5)) r = union() + up(3.875)(forward(0)(racks(pins=5))) a = a + up(15/2)(pins) + s + down(19/2)(bottom(pins=5)) + \ up(7.5/2)(top(pins=5)) + r # a = up(7.5/2)(top(pins=4)) + r return a
def top_invert(): clk = Signal(bool(0)) rst = ResetSignal(1, active=1, isasync=False) write = Signal(bool(0)) read = Signal(bool(0)) rdy = Signal(bool(0)) pc = Signal(intbv(0)[16:]) ins = Signal(intbv(0)[16:]) addr = Signal(intbv(0)[16:]) wdata = Signal(intbv(0)[8:]) rdata = Signal(intbv(0)[8:]) int0 = Signal(bool(0)) int1 = Signal(bool(0)) int2 = Signal(bool(0)) int3 = Signal(bool(0)) top_ins = top(clk, rst, write, read, rdy, pc, ins, addr, wdata, rdata, int0, int1, int2, int3) return top_ins
async def hello_world(dut): # initial begin # $timeformat(-9,0," ns",5); # uvm_default_table_printer.knobs.name_width=20; # uvm_default_table_printer.knobs.type_width=50; # uvm_default_table_printer.knobs.size_width=10; # uvm_default_table_printer.knobs.value_width=14; # uvm_config_int::set(null, "top.producer1","num_packets",2); # uvm_config_int::set(null, "top.producer2","num_packets",4); # uvm_config_int::set(null, "*","recording_detail",UVM_LOW); # //uvm_default_printer = uvm_default_tree_printer; # uvm_default_printer.knobs.reference=0; # Required by ghdl, otherwise sim ends in fatal error cocotb.fork(Clock(dut.clk, 10, "NS").start()) mytop = top("top", parent=None) # uvm_default_table_printer.knobs.type_width=20; await run_test() if mytop.error: raise Exception("mytop had errors")
def POST(self): top() mbuttonhitter=buttonhitter() render = web.template.render(config.templatedir, base='layout', globals={'context': web.ctx.session}) problemdata = db.select('description', web.ctx.session, where='id=$idp') problemdata = problemdata[0] commands = re.split('[\n\r]+', problemdata.recurrence) comments = db.query( 'select * from example_users eu join comment c on c.user_id=eu.id where c.problem_id=' + web.ctx.session.idp) mhinter = hinter() mysolution = solutioninstance( solver2.solve(web.ctx.session.instance.lists, web.ctx.session.instance.constants, commands, web.ctx.session.instance.dimensions[0], web.ctx.session.instance.dimensions[1])) msplitter = splitter(False) builders = msplitter.split(commands) if web.ctx.session.hintlevel > 0: web.ctx.session.hint = mhinter.hint(problemdata.recurrence, web.ctx.session.hintlevel) data = web.input() scroll=None if 'scroll' in data: scroll=data['scroll'] if 'left0' in data: mbuttonhitter.hitMenus() commands = build(data) message = '' theirsolution = None try: theirsolution = solutioninstance( solver2.solve(web.ctx.session.instance.lists, web.ctx.session.instance.constants, commands, web.ctx.session.instance.dimensions[0], web.ctx.session.instance.dimensions[1])) print "THEIR SOLUTION:", theirsolution.table correct, checks = checksolution(web.ctx.session.idp, commands) if correct: achecker = achievementchecker() message = achecker.check(web.ctx.session.userid) mbuttonhitter.hitCorrectMenus() except ParserException as e: correct = False if theirsolution is not None: return render.problemtableform(web.ctx.session.instance, mysolution, theirsolution.table, comments, builders, correct, e.message, theircommands=commands,scroll=scroll) else: return render.problemtableform(web.ctx.session.instance, mysolution, None, comments, builders, correct, e.message, theircommands=commands,scroll=scroll) except (NameError, SyntaxError) as e: print e correct = False if theirsolution is not None: return render.problemtableform(web.ctx.session.instance, mysolution, theirsolution.table, comments, builders, correct, str(e), theircommands=commands,scroll=scroll) else: return render.problemtableform(web.ctx.session.instance, mysolution, None, comments, builders, correct, str(e), theircommands=commands,scroll=scroll) except: correct = False if theirsolution is not None: return render.problemtableform(web.ctx.session.instance, mysolution, theirsolution.table, comments, builders, correct, "Something went wrong", theircommands=commands,scroll=scroll) else: return render.problemtableform(web.ctx.session.instance, mysolution, None, comments, builders, correct, "Something went wrong", theircommands=commands,scroll=scroll) print "received checks length", len(checks) return render.problemtableform(web.ctx.session.instance, mysolution, theirsolution.table, comments, builders, correct=correct, message=message, theircommands=commands, checks=checks,scroll=scroll) if data['action'] == 'new': constants = randomgenerator.getRandomConstants(problemdata.constants) web.ctx.session.instance.constants = constants arrays = randomgenerator.getRandomArrays(problemdata.arrays) web.ctx.session.instance.lists = arrays web.ctx.session.solutionindex = 0 print constants mysolution = solutioninstance( solver2.solve(web.ctx.session.instance.lists, web.ctx.session.instance.constants, commands, web.ctx.session.instance.dimensions[0], web.ctx.session.instance.dimensions[1])) return render.problemtableform(web.ctx.session.instance, mysolution, None, comments, builders,scroll=scroll) elif data['action'] == 'showsolution': mysolution.show = True web.ctx.session.solutionindex = mysolution.length return render.problemtableform(web.ctx.session.instance, mysolution, None, comments,builders,scroll=scroll) elif data['action'] == 'nextvalue': mysolution.show = True web.ctx.session.solutionindex += 1 return render.problemtableform(web.ctx.session.instance, mysolution, None, comments,builders,scroll=scroll) elif data['action'] == 'comment': db.insert('comment', user_id=web.ctx.session.userid, problem_id=web.ctx.session.idp, comment=data['comment']) comments = db.query( 'select * from example_users eu join comment c on c.user_id=eu.id where c.problem_id=' + web.ctx.session.idp) return render.problemtableform(web.ctx.session.instance, mysolution, None, comments,builders,scroll=scroll)
def GET(self): top() problems=db.select('problem') return render.modifyall(problems)
for j in range(populationLimit): fitnessVal = fitnessFunction.fitnessFunction(population[j],city) if fitnessVal < bestVal: bestVal = fitnessVal bestAns = population[j] for k in range(populationLimit): for l in range((k+1), populationLimit): # child = population[k] child = crossover.crossover(population[k],population[l],city) newGeneration.append(child) for member in newGeneration: member = mutation.mutate(member) for m in range(populationLimit): newGeneration.append(population[m]) population = top.top(populationLimit,newGeneration,city) print bestAns print bestVal elapsed = time.clock() print elapsed - start
def GET(self): top() problems=db.select('problem') progress=db.select('user_problems',session,where='id_user=$userid') progress=[x.id_problem for x in progress] return render.collection(problems,progress)
def GET(self): top() data = db.query("SELECT id,type,data,title,url,description,user_id from achievements a left join user_achievements ua on a.id=ua.achievement_id AND ua.user_id="+str(web.ctx.session.userid)) return render.achievements(data)
def GET(self): top() # do $:f.render() in the template return render.survey()
#examples of retrieving graphed/printed info below, uncomment one object block and run this file to view results #i recommend using only one object at a time, but can do both, will have to authenticate multiple times if you do #must call build graph functions before finally calling show_graphs username = input("enter spotify username: ") ''' tracks = track.tracks(username) tracks.print_user_tracks_info() tracks.build_top_artists_graph() tracks.show_graphs() ''' ''' p = play.playlists(username) p.build_tracks_popularity_graph() p.build_tracks_graph() p.build_popularity_graph() p.show_graphs() ''' t = tp.top(username) #t.build_top_artist_graph(25) #t.build_top_tracks_graph(25) t.build_top_genres_graph() t.show_graphs()