def runApp(): while True: print( "what you want to do ?\n1.Add Contact\n2.View all Contacts\n3.Edit Contact\n4.Delete Contact\n5.Search Contact\n6.Exit" ) choice = int(input()) if choice == 1: name = input("Enter a name : ") number = input("Enter Contact number : ") while not isValidPhoneNumber(number): print("Enter a valid phone number") number = input("Enter Contact number : ") add(name, number) print("contact added successfully") elif choice == 2: view() elif choice == 3: name = input("Enter a name : ") edit(name) elif choice == 4: name = input("Enter a name : ") deletee(name) elif choice == 5: search() elif choice == 6: break print("\n")
def main(): graphics = graph.init_video() graphics.screen.fill((32, 0, 64)) pygame.mouse.set_visible(0) pygame.display.flip() level = game.load_level() mygame = game.init_game(level) graphics.tilemap = level.tilemap graphics.tilemap_height = level.height graphics.tilemap_width = level.width next = "title" mygame.ingame = 0 while next != "quit": if next == "menu": next = menu.main_menu(mygame, level, graphics) if next == "edit": next = "menu" edit.edit(level, graphics) if next == "play": next = game.game(mygame, level, graphics) if next == "title": mygame.sound_12.play() next = menu.title_screen(graphics) if next == "intro": mygame.sound_12.play() next = menu.intro(graphics) if next == "win": mygame.sound_0.play() next = menu.win(graphics) graph.free_video()
def edit(self,widget): self.treeView.set_model(self.create_model()) model=self.treeView.get_model() edit.edit(self.fname) #print 1 update_list.main(self.fname) self.treeView.set_model(self.create_model()) model=self.treeView.get_model() '''print 1 for i in model: for j in i: print j, print print 2 ''' self.graphs(1) self.graphs(2) stats.update(self.fname) stats.treeView.set_model(stats.create_model(self)) try: viewer.update(self,'') viewer.treeView.set_model(viewer.create_model(self)) except AttributeError: pass
def compose_in_editor(two_way_card): if two_way_card: print_info('Two-way mode is ON.') else: print_info('Two-way mode is OFF.') print_instruction('Hit Enter to continue in editor mode, or enter one of these options:') print_instruction('q: Quit.') print_instruction('t: Toggle two-way card and continue in editor mode.') print_instruction('m: Continue in normal multi-line mode.') print_instruction('s: Continue in single-line mode.') while True: selection = colored_prompt('[q/t/m/s]: ') if selection in ['q', 't', 'm', 's', '']: break if selection == 'q': return None, None, None, None if selection == 't': two_way_card = not two_way_card if selection == 'm': return new_card(two_way_card, single_line_mode=False, editor_mode=False) if selection == 's': return new_card(two_way_card, single_line_mode=True, editor_mode=False) bogus_timestamp = '1991-08-25 20:57:08' empty_card = Card('', '', 0, bogus_timestamp) card = edit(empty_card, two_way_card) return card, two_way_card, False, True
def draw_subgraph(data, subg, DG): id = "" labels = labeler(data) while id != "end": id = input("id: ") if id == "break": break if id == "end": continue if id == "edit": edit(topic) subgraphA = [] cur_node = data[int(id)] subgraphA.extend(bfs(cur_node, data, DG)) subDG = DG.subgraph(subgraphA) # print str(len(subgraphA)) + " NODES" pos = nx.spring_layout(subDG) labelDict = {n: lab for n, lab in labels.items() if n in pos} nx.draw(subDG, pos, with_labels=True, font_size=12, labels=labelDict) plt.draw() plt.show()
def default(self, *args, **kwargs): ''' This is the main handler for any requests recieved on this mount point. ''' if cherrypy.request.method != "GET" and cherrypy.session.get("user",None) is None: raise cherrypy.HTTPError(401, "Not authorized to %s to this source" %(cherrypy.request.method)) if "action" in kwargs: action = kwargs['action'] else: action = "view" self.parsePath(args) if cherrypy.request.method == "POST": action=self._handlePost(args,**kwargs) if action == "edit": import edit cherrypy.request.template = template = edit.edit() elif action == "upload": import upload cherrypy.request.template = template = upload.upload() elif action == "bare": if 'id_prefix' in kwargs: print "id_prefix: "+ kwargs["id_prefix"] return cherrypy.request.rst.render(settings_overrides={'id_prefix': kwargs['id_prefix']}) return cherrypy.request.rst.render() else: action = "view" import master cherrypy.request.template = template = master.master() template.action = action if cherrypy.request.resourceFileExt != ".rst": mimetype = mimetypes.guess_type(cherrypy.request.resourceFilePath) cherrypy.response.headers["Content-Type"] = mimetype[0] return open(cherrypy.request.resourceFilePath).read() elif os.path.isfile(cherrypy.request.resourceFilePath): template.rst = RstDocument(cherrypy.request.resourceFilePath) else: raise cherrypy.HTTPError(404) return self.render()
def menu(card): contents_changed = True print_instruction('e: Edit this card.') print_instruction('d: Delete this card.') while True: selection = colored_prompt('[e/d]: ') if selection in ['e', 'd']: break if selection == 'e': two_way_card = False return edit(card, two_way_card), contents_changed elif selection == 'd': return None, contents_changed
def default(self, *args, **kwargs): ''' This is the main handler for any requests recieved on this mount point. ''' usar = cherrypy.session.get("user", None) if usar is not None: print usar.keys() if cherrypy.request.method != "GET" and usar is None: # if we've setup a post-recieve hook, check out this first. if self._triggerurl == cherrypy.request.path_info and cherrypy.request.app.vcs is not None: # perhaps do some exception handling and put a warning on .app that merge conflict happened? cherrypy.request.app.vcs.pull() return "" else: # otherwise: raise cherrypy.HTTPError(401, "Not authorized to %s to this source" % (cherrypy.request.method)) if "action" in kwargs: action = kwargs['action'] else: action = "view" self.parsePath(args) if cherrypy.request.method == "POST": action = self._handlePost(args, **kwargs) if action == "create" and usar is not None and cherrypy.request.resourceFileExt == ".rst": import create cherrypy.request.template = template = create.create() print "Showing create page %s" % (cherrypy.request.path_info) filename = cherrypy.request.path_info[1:] title = filename.replace("/", ".") heading = "=" * len(title) somerst = ".. _%s:\n\n%s\n%s\n%s\n\nTODOC!\n\n.. contents ::\n :depth: 2\n\n=============\nFirst Section\n=============\n\n" % ( filename, heading, title, heading ) template.rst = RstDocument() template.rst.update(somerst) template.encoded_rst = cgi.escape(template.rst.document) template.title = "Creating: %s" % (template.rst.gettitle()) template.action = action cherrypy.response.status = 404 return self.render() elif action == "edit": import edit cherrypy.request.template = template = edit.edit() elif action == "upload": import upload cherrypy.request.template = template = upload.upload() elif action == "bare": if 'id_prefix' in kwargs: print "id_prefix: " + kwargs["id_prefix"] return cherrypy.request.rst.render(settings_overrides={'id_prefix': kwargs['id_prefix']}) return cherrypy.request.rst.render() else: action = "view" import master cherrypy.request.template = template = master.master() cherrypy.request.githublink = self.githubroot template.action = action if cherrypy.request.resourceFileExt != ".rst": mimetype = mimetypes.guess_type(cherrypy.request.resourceFilePath) cherrypy.response.headers["Content-Type"] = mimetype[0] return open(cherrypy.request.resourceFilePath).read() elif os.path.isfile(cherrypy.request.resourceFilePath): template.rst = RstDocument(cherrypy.request.resourceFilePath) template.encoded_rst = cgi.escape(template.rst.document) template.title = template.rst.gettitle() else: get_parmas = urllib.quote(cherrypy.request.request_line.split()[1]) creating = get_parmas.find("action%3Dcreate") print get_parmas if creating == -1: redir = get_parmas + "?action=create" raise cherrypy.HTTPRedirect(redir) else: raise cherrypy.HTTPError(404) return self.render()
def default(self, *args, **kwargs): ''' This is the main handler for any requests recieved on this mount point. ''' usar = cherrypy.session.get("user", None) if usar is not None: print usar.keys() if cherrypy.request.method != "GET" and usar is None: # if we've setup a post-recieve hook, check out this first. if self._triggerurl == cherrypy.request.path_info and cherrypy.request.app.vcs is not None: # perhaps do some exception handling and put a warning on .app that merge conflict happened? cherrypy.request.app.vcs.pull() return "" else: # otherwise: raise cherrypy.HTTPError( 401, "Not authorized to %s to this source" % (cherrypy.request.method)) if "action" in kwargs: action = kwargs['action'] else: action = "view" self.parsePath(args) if cherrypy.request.method == "POST": action = self._handlePost(args, **kwargs) if action == "create" and usar is not None and cherrypy.request.resourceFileExt == ".rst": import create cherrypy.request.template = template = create.create() print "Showing create page %s" % (cherrypy.request.path_info) filename = cherrypy.request.path_info[1:] title = filename.replace("/", ".") heading = "=" * len(title) somerst = ".. _%s:\n\n%s\n%s\n%s\n\nTODOC!\n\n.. contents ::\n :depth: 2\n\n=============\nFirst Section\n=============\n\n" % ( filename, heading, title, heading) template.rst = RstDocument() template.rst.update(somerst) template.encoded_rst = cgi.escape(template.rst.document) template.title = "Creating: %s" % (template.rst.gettitle()) template.action = action cherrypy.response.status = 404 return self.render() elif action == "edit": import edit cherrypy.request.template = template = edit.edit() elif action == "upload": import upload cherrypy.request.template = template = upload.upload() elif action == "bare": if 'id_prefix' in kwargs: print "id_prefix: " + kwargs["id_prefix"] return cherrypy.request.rst.render( settings_overrides={'id_prefix': kwargs['id_prefix']}) return cherrypy.request.rst.render() else: action = "view" import master cherrypy.request.template = template = master.master() cherrypy.request.githublink = self.githubroot template.action = action if cherrypy.request.resourceFileExt != ".rst": mimetype = mimetypes.guess_type(cherrypy.request.resourceFilePath) cherrypy.response.headers["Content-Type"] = mimetype[0] return open(cherrypy.request.resourceFilePath).read() elif os.path.isfile(cherrypy.request.resourceFilePath): template.rst = RstDocument(cherrypy.request.resourceFilePath) template.encoded_rst = cgi.escape(template.rst.document) template.title = template.rst.gettitle() else: get_parmas = urllib.quote(cherrypy.request.request_line.split()[1]) creating = get_parmas.find("action%3Dcreate") print get_parmas if creating == -1: redir = get_parmas + "?action=create" raise cherrypy.HTTPRedirect(redir) else: raise cherrypy.HTTPError(404) return self.render()
else: returnDict[x] = 1 print(len(dict)) print([n[0].title for n in dict_sorter(returnDict, rev="reverse")[:5]]) if indict == 0: topic = input("topic: ") data = reader(topic) DG = init(data) cur = "" cleanPred(data, DG) while cur != "end": if id == "edit": edit(topic) cur = input("graph: ") if cur == "cur": id = "" while id != "end": id = input("id: ") if id == "end": continue if id == "edit": edit(topic) draw_current(data, id, DG) if cur == "sub": draw_subgraph(data, [], DG) if cur == "all": draw_all(data, DG)
def writer(topic, data=0, init_description=""): from writer import writeToFile, isint #cleaning function making sure each node is properly linked def clean(data, curNode): for n in curNode.future: if n >= len(data): continue pastArray = data[n].past if n not in pastArray: data[n].flashback(curNode.id) for n in curNode.past: if n >= len(data): continue futureArray = data[n].future if n not in futureArray: data[n].flashforward(curNode.id) for n in curNode.related: if n >= len(data): continue relatedArray = data[n].related if n not in relatedArray: data[n].relate(curNode.id) file = "../data/" + topic + ".json" data = reader(topic) DG = init(data) DG = cleanPred(data, DG) max = len(data) content = "" summary = init_description print(topic + ".write: " + summary) while content != "end": content = input("") if content == "end": continue #summary function if content == "ls": print(summary) continue #enter if content == "\n": summary += "\n" continue #premature break if content == "break": break #writing the actual content summary += content + " " #premature break if content == "break": return "" #connecting the content #get title print("Title: ") title = input("") if title == "up": title = summary print("Type: ") type = [] t = "" while t != "end": t = input("") if t == "end": continue type.append(t) print("Past: ") past_temp = "" back = [] while past_temp != "end": past_temp = input("") if past_temp == "end": continue if past_temp[:2] == "ls": ls(past_temp, data) continue if past_temp == "search": se = "" while se != "end": se = input("search: ") if se == "end": continue if isint(se): get(data, DG, id=int(se)) for n in searcher(se, data): print(str(n.id) + ": " + n.title) continue if past_temp == "suc": for n in mostPopularSuc(data, DG, limit=10): print(str(n.id) + ": " + n.title) continue if past_temp == "pre": for n in mostPopularPred(data, DG, limit=10): print(str(n.id) + ": " + n.title) continue if past_temp == "cen": for n in most_degree_centrality(DG, limit=10): print(str(n[0].id) + ": " + n[0].title) continue if past_temp == "project": get_project(data, DG) continue if past_temp == "branch": branch(data, DG) continue if past_temp == "get": get(data, DG) continue if isint(past_temp): result = int(past_temp) back.append(result) else: print([ str(n.id) + ": " + str(n.title) for n in searcher(past_temp, data) ]) print(back) print("Future: ") future_temp = "" future = [] while future_temp != "end": future_temp = input("") if future_temp == "end": continue if future_temp[:2] == "ls": if future_temp[:2] == "ls": ls(future_temp, data) continue if future_temp == "search": se = "" while se != "end": se = input("search: ") if se == "end": continue if isint(se): get(data, DG, id=int(se)) for n in searcher(se, data): print(str(n.id) + ": " + n.title) continue if future_temp == "suc": for n in mostPopularSuc(data, DG, limit=10): print(str(n.id) + ": " + n.title) if future_temp == "pre": for n in mostPopularPred(data, DG, limit=10): print(str(n.id) + ": " + n.title) if future_temp == "cen": for n in most_degree_centrality(DG, limit=10): print(str(n[0].id) + ": " + n[0].title) if future_temp == "get": get(data, DG) if isint(future_temp): result = int(future_temp) future.append(result) else: print([ str(n.id) + ": " + str(n.title) for n in searcher(future_temp, data) ]) print(future) #simplify things, break things up into if you want to add related c = "" related = [] keyword = [] while c != "end": c = input("") if c == "end": continue if c == "break": break #if you want to add related if c == "related": print("Related: ") r_temp = "" while r_temp != "end": r_temp = input("") if r_temp == "end": continue if isint(r_temp): result = int(r_temp) related.append(result) else: print([ str(n.id) + ": " + str(n.title) for n in searcher(r_temp, data) ]) print(related) #if you want to add keywords if c == "keywords": print("Keywords: ") k_temp = "" while k_temp != "end": k_temp = input("") if k_temp == "end": continue keyword.append(k_temp) if c == "edit": data = edit(data) if c == "break": return "" print(title) print(type) print(summary) #CLEANING current_Node = Node(title, type, summary, keyword, back, future, related, max) clean(data, current_Node) data.append(current_Node) max += 1 #WRITING BACK TO TXT FILE writeToFile(file, data)
print() if (sel == 1): for id, v in exif.items(): print(TAGS.get(id), ":", v) if (sel == 2): print("search word") search = str(input()) tag_list.tags(search) print("input id") num = int(input()) for id, v in exif.items(): if (id == num): print(TAGS.get(id), ":", v) if (sel == 3): print("input edit tag") tag = str(input()) if tag == 'GPS': edit.edit_gps(name) else: edit.edit(name, tag) if (sel == 4): piexif.remove(name) print("erase completed") if (sel == 5): break
continue #print the new data? useless method because it writes to file everytime if start == "print": for i in range(preLen + 1, len(data)): print(str(data[i].id) + ": " + data[i].title) print(data) conf = input("confirm?: ") if conf == "y" or conf == "yes": writeToFile(file, data) else: continue if start == "edit": data = edit(data) writeToFile(file, data) DG = reload(data) #WRITING CONTENT if start == "write": writer(topic) data = reader(topic) DG = init(data) DG = cleanPred(data, DG) if start == "search": se = "" while se != "end": if se == "end": continue
def interface(init_topic=""): from mapper import reload topic = "" while topic != "end": #loading topic if init_topic == "": topic = input("topic: ") if topic == "end": continue if topic == "ls": for n in [ n.replace(".json", "") for n in os.listdir("../data/") if ".json" in n ]: print(n) continue if len(searcher(topic, list(os.listdir("../data/")))) > 0: print() for n in [ n.replace(".json", "") for n in searcher(topic, list(os.listdir("../data/"))) if ".json" in n ]: print(n) else: topic = init_topic file = "../data/" + topic + ".json" if topic + ".json" not in set(os.listdir("../data/")): print("NEW") conf = input("confirm: ") #need a confirm option if conf == "y" or conf == "yes": with open(file, "w+") as cur_file: cur_file.write(json.dumps([])) else: continue start = "" data = reader(topic) DG = reload(data) #for the purpose of recording changes to length of dataset preLen = len(data) path = "" walker = 0 SET_OF_COMMANDS = ["end", "print", "edit", "write", "search"] #actions while start != "end": start = input(topic + ": ") if start == "end": continue #print the new data? useless method because it writes to file everytime if start == "print": for i in range(preLen + 1, len(data)): print(str(data[i].id) + ": " + data[i].title) print(data) conf = input("confirm?: ") if conf == "y" or conf == "yes": writeToFile(file, data) else: continue if start == "edit": data = edit(data) writeToFile(file, data) DG = reload(data) #WRITING CONTENT if start == "write": writer(topic) data = reader(topic) DG = reload(data) if start == "search": se = "" while se != "end": se = input("search: ") if se == "end": continue if isint(se): get(data, DG, id=int(se)) for n in searcher(se, data): print(str(n.id) + ": " + n.title) if isint(start): get(data, DG, id=int(start)) if start[:2] == "ls": ls(start, data) continue if start == "graph": draw_all(data, DG) #summarize data #degree centrality, pred nodes, suc nodes (page rank) if start == "summarize": size = int(len(DG.nodes()) / 10) print("Size = " + str(size)) centralnodes = [ n[0] for n in most_degree_centrality(DG, limit=size) ] suc = mostPopularSuc(data, DG, limit=size) pred = mostPopularPred(data, DG, limit=size) totalNodes = [] totalNodes.extend(centralnodes) totalNodes.extend(suc) totalNodes.extend(pred) print("Pred Nodes: ") print() for n in pred: print(str(n.id) + ": " + str(n.title)) print() print("Central Nodes: ") print() for n in centralnodes: print(str(n.id) + ": " + str(n.title)) print() print("Suc Nodes: ") print() for n in suc: print(str(n.id) + ": " + str(n.title)) p = input("plot? ") if p == "y" or p == "yes": subDG = DG.subgraph(totalNodes) labels = labeler(data) pos = nx.spring_layout(subDG) labelDict = { n: lab for n, lab in labels.items() if n in pos } nx.draw(subDG, pos, with_labels=True, font_size=12, labels=labelDict) plt.draw() plt.show() if start == "get": get(data, DG) if start == "axioms": leaves = [n for n, d in DG.out_degree() if d == 0] print(len(leaves)) dprint(leaves) if start == "cycle": isCycle(DG) if start == "project": get_project(data, DG) if start == "branch": branch(data, DG) if start == "pyvis": from net_vis import net_vis net_vis(data) if start == "load": from load import file_finder, term_text_editor, pdf_loader, txt_loader if len(path) > 0: s = input("LOADED PATH: " + path + "\n") if s == "new": path = file_finder() if ".txt" in path: t_data = txt_loader(path) elif ".pdf" in path: t_data = pdf_loader(path) else: print("NO VALID FILE") term_text_editor(path, from_topic=topic) data = reader(topic) DG = reload(data) else: walker = term_text_editor(t_data, init_index=walker, from_topic=topic) data = reader(topic) DG = reload(data) else: path = file_finder() if ".txt" in path: t_data = txt_loader(path) elif ".pdf" in path: t_data = pdf_loader(path) else: print("NO VALID FILE") walker = term_text_editor(t_data, from_topic=topic) data = reader(topic) DG = reload(data)
from edit import edit import xbmcgui import xbmc if __name__ == '__main__': type = xbmc.getInfoLabel("ListItem.Property(type)") id = xbmc.getInfoLabel("ListItem.Property(streamID)") if type == "stream": edit(type, id) else: dialog = xbmcgui.Dialog() ok = dialog.ok('Add', 'There has been an error.\nPlease inform the developer about this.')
def map_data(): return jsonify(edit.edit())
from edit import edit import xbmcgui import xbmc if __name__ == '__main__': type = xbmc.getInfoLabel("ListItem.Property(type)") playlist = xbmc.getInfoLabel("ListItem.Property(playlistName)") if type == "playlist": edit(type, playlist) else: dialog = xbmcgui.Dialog() ok = dialog.ok('Add', 'There has been an error.\nPlease inform the developer about this.')
def iterate(conn, cursor, iterator, count): if count == 0: print_error('No results.') elif count == 1: print_info('[1 CARD.]') else: print_info('[{} CARDS.]'.format(count)) try: for card in iterator: print_instruction('[Ctrl+C to quit.]') updated_card, contents_changed = review_card(card) is_two_way_card = card_repository.is_two_way_card(cursor, card) if is_two_way_card and contents_changed: flipped_card_too = include_flipped_card() else: flipped_card_too = False if updated_card == None: card_repository.delete(conn, cursor, card) if flipped_card_too: card_repository.delete_flipped_card(conn, cursor, card) count -= 1 # Not an error, but I feel this should be red. print_error('DELETED.') table_is_empty = card_repository.check_if_empty(cursor) if table_is_empty: print_info('You have no more cards!') break else: if contents_changed: while True: card_repository.insert(conn, cursor, updated_card) if flipped_card_too: card_repository.insert_flipped_card(conn, cursor, updated_card) else: bump_flipped_card_timestamp(conn, cursor, card) print_instruction('Create another version based on this same card?') print_info('Protip: This is how you split one card into several cards.') while True: answer = colored_prompt('[y/n]: ') if answer in ['y', 'n']: break if answer == 'n': break else: updated_card = edit(card, flipped_card_too) card_repository.delete(conn, cursor, card) if flipped_card_too: card_repository.delete_flipped_card(conn, cursor, card) else: card_repository.insert(conn, cursor, updated_card) card_repository.delete(conn, cursor, card) bump_flipped_card_timestamp(conn, cursor, card) count -= 1 if count > 0: print_info('[{} MORE:]'.format(count)) except KeyboardInterrupt: print()
driver.get(URL) #用户登录 driver.find_element_by_name("username").send_keys("admin") driver.find_element_by_name("password").clear() driver.find_element_by_name("password").send_keys("123456") driver.find_element_by_xpath("//span[contains(.,'Sign in')]").click() try: driver.find_element_by_xpath("//span[text()='会议列表']") print(u"登录成功") except: logging.error("登录失败") #编辑信息 driver.find_element_by_xpath("//span[text()='我的面板']").click() sleep(1) edit(driver) #点击系统设置 while (1): try: driver.find_element_by_xpath("//span[text()='系统设置']").click() break except: pass sleep(1) organization_del(driver) #清空机构 organization(driver) #创建机构 meeting_room_del(driver, 1) #清空会议室 meeting_room(driver, 0) #创建会议室 meeting_type_del(driver, 1) #清空会议类型