def main(): logs = '' args = get_args() maze, functions = parser.parse_file(args.file) args.file.close() cars = run.create_cars(maze, Car) if args.debug: out.init() try: while cars: if args.debug: out.output(maze, cars, logs, args.no_colors) maze, cars = run.move_cars(maze, cars) maze, cars, new_logs = run.car_actions(maze, cars, functions, debug=args.debug) if args.debug: if new_logs: logs = out.log_lines(logs + new_logs, args.log_length) time.sleep(1 / args.fps) else: print(new_logs, end='') finally: if args.debug: out.end()
def regDeputado(numId): url = 'http://dadosabertos.almg.gov.br/ws/deputados/'+str(numId)+'?formato=json' registroDeputado = [] registroDeputado = getData(url)["deputado"] #print "\n\tRedes Sociais\n" # output("saida.out", "\n\tRedes Sociais\n") # dicio = {} for redeSoc in registroDeputado["redesSociais"]: print "\t\t", redeSoc["redeSocial"]["nome"], "-", redeSoc["url"] # dicio.update({redeSoc["redeSocial"]["nome"]:redeSoc["url"]}) # saida = "\t\t"+redeSoc["redeSocial"]["nome"]+" - "+redeSoc["url"]+"\n" # output("saida.out", saida.encode('utf-8')) saida = "\t\t{\n\t\t\"redeSocial\": {\n\t\t\t\"nome\": \""+redeSoc["redeSocial"]["nome"]+"\",\n\t\t\t\"url\": \""+redeSoc["url"]+"\",\n\t\t},\n\t}" output("teste.out", saida.encode('utf-8'))
def infoDeputado(status): cont = 0 if status == 1: listaDeputado = [] listaDeputado = getData('http://dadosabertos.almg.gov.br/ws/deputados/situacao/1?formato=json')["list"] lista = [] dicio = {"lista":lista} for deputado in listaDeputado: print deputado["nome"], "-", deputado["partido"] # saida = deputado["nome"]+" - "+deputado["partido"] # output("saida.out", saida.encode('utf-8')) # lista.append(regDeputado(deputado["id"]) saida = "{\n\t\"nome\": \""+deputado["nome"]+"\",\n\t\"partido\": \""+deputado["partido"]+"\",\n\t\"redesSociais\": [" output("teste.out", saida.encode('utf-8')) regDeputado(deputado["id"]) saida = "\t],\n},\n" output("teste.out", saida.encode('utf-8')) # verbaDeputado(deputado["id"]) print dicio["lista"]
"-=") == -1 and x.find("==") == -1 and x.find( ">=") == -1 and x.find("<=") == -1 and x.find("!=") == -1: make = initialise.main(x) file1.write(make) # For adding something to variables elif x.find("+=") != -1: makea = increment.main(x) file1.write(makea) #For loop making elif x.find("for") != -1: makeb = fori.main(x) a = f"{makeb[0]} {makeb[1]}{makeb[2]} {makeb[3]} {makeb[4]} {makeb[5]}\n" file1.write(a) #Writing #Printing elif x.find("print") != -1: makec = out.output(x) file1.write(makec) #Printing with vars elif "," in x and "print" in x: maked = harder.main(x) file1.write(maked) elif x.find("-=") != -1: makee = increment.decrement(x) file1.write(makee) elif x.find("while") != -1: makef = fori.whileloop(x) file1.write(makef) elif x.find("if") != -1 and x.find("elif") == -1: makeg = increment.ifstatement(x) + "\nTHEN\n" file1.write(makeg) elif x.find("elif") != -1:
def gendeps(): import optparse parser = optparse.OptionParser() opts, args = parser.parse_args() if not args: args = ['.'] for arg in args: fn = realpath(arg) if not exists(fn): parser.error("Filename '%s' does not exist." % fn) inroots = find_roots(args, def_ignores) sys.path = inroots + sys.path inroots = frozenset(inroots) allfiles = defaultdict(set) allerrors = [] processed_files = set() fiter = iterate_files(args, def_ignores, False) while 1: newfiles = set() for fn in fiter: if fn in processed_files: continue processed_files.add(fn) if is_python(fn): files, errors = find_dependencies(fn, 0, True, None) allerrors.extend(errors) else: files = [] if basename(fn) == '__init__.py': fn = dirname(fn) from_ = relfile(fn, def_ignores) if from_ is None: continue infrom = from_[0] in inroots allfiles[from_].add((None, None)) for dfn in files: xfn = dfn if basename(xfn) == '__init__.py': xfn = dirname(xfn) to_ = relfile(xfn, def_ignores) into = to_[0] in inroots allfiles[from_].add(to_) newfiles.add(dfn) if not (None and newfiles): break else: fiter = iter(sorted(newfiles)) output(allfiles)
for key, value in sorted_val.items(): for i in range(0, len(value)): output_list.append([key, value[i][0]]) print(output_list) file_name = input( "Please enter the name of relevance file, you can also input the address of file:" ) relevant = open(file_name, "r") # This snippet reads the "relevent.txt file" r_line = relevant.readline() r_data = dict() while r_line: x = [] x = r_line.split( ) #We take input line for line and split the values of query and document. if int(x[0]) not in r_data: k = [int(x[1])] r_data.update({int(x[0]): k}) else: r_data[int(x[0])].append(int(x[1])) r_line = relevant.readline() recall_denom = [ ] # This is to caluculate the number of relevant documents for each query. for key, value in r_data.items(): recall_denom.append(len(value)) o.output(r_data, sorted_val, recall_denom, 10) #Following give the answer to all the questions asked o.output(r_data, sorted_val, recall_denom, 50) o.output(r_data, sorted_val, recall_denom, 100) o.output(r_data, sorted_val, recall_denom, 500)