def operate(self): self.show_item_info() while True: op = raw_input("Question Answer Item$ ") if op == "voteup": self.vote_up_answer() elif op == "votedown": self.vote_down_answer() elif op == "votecancle": self.vote_cancle_answer() elif op == "answer": from Answer import Answer answer = Answer(zhihu + self.get_answer_link()) if answer.operate(): return True elif op == "author": author_link = self.get_author_link() if author_link: user = User(zhihu + self.get_author_link()) if user.operate(): return True else: print termcolor.colored("回答者为匿名用户", "red") elif op == "pwd": self.show_item_info() elif op == "help": self.help() elif op == "break": break elif op == "clear": clear() elif op == "quit": return True else: error()
def operate(self): self.show_item_info() while True: op = raw_input("{}\'s Answer Item$ ".format(self.username)) if op == "voteup": self.vote_up() elif op == "votecancle": self.vote_cancle() elif op == "votedown": self.vote_down() elif op == "answer": answer_link = self.get_answer_link() from Answer import Answer answer = Answer(zhihu + answer_link) if answer.operate(): return True elif op == "question": from Question import Question question = Question(zhihu + self.get_question_link()) if question.operate(): return True elif op == "pwd": self.show_item_info() elif op == "quit": return True elif op == "help": self.help() elif op == "clear": clear() elif op == "break": break else: error()
def operate(self): #self.show_base_info() if not self.parse(): return True print termcolor.colored(self.get_title(), "blue") while True: op = raw_input("Question$ ") if op == "follow": self.follow_question() elif op == "unfollow": self.unfollow_question() elif op == "answers": if self.answer_operate(): return True elif op == "pwd": print termcolor.colored(self.get_title(), "blue") elif op == "info": self.show_base_info() elif op == "detail": self.show_detail() elif op == "browser": self.open_in_browser() elif op == "clear": clear() elif op == "break": break elif op == "help": self.help() elif op == "quit": return True else: error() return False
def operate(self): if not self.parse(): return True print self.get_title() while True: op = raw_input("zhuanlan$ ") if op == "content": self.get_content() elif op == "author": url = self.get_author_info() if not url: print termcolor.colored("当前用户为匿名用户", "red") else: from User import User user = User(url) if user.operate(): return True elif op == "voteup": self.vote(type=1) elif op == "votecancle": self.vote(type=2) elif op == "pwd": print self.get_title() elif op == "browser": self.open_in_browser() elif op == "clear": clear() elif op == "break": break elif op == "help": self.help() elif op == "quit": return True else: error()
def operate(self): if not self.parse(): return True self.show_base_info() while True: op = raw_input("User$ ") if op == "follow": self.follow_member() elif op == "unfollow": self.unfollow_member() elif op == "answers": if self.answer_operate(): return True elif op == "pwd": self.show_base_info() elif op == "browser": self.open_in_browser() elif op == "break": break elif op == "help": self.help() elif op == "clear": clear() elif op == "quit": return True else: error()
def operate(self): self.show_item_info() while True: op = raw_input("{}\'s Answer Item$ ".format(self.username)) if op == "voteup": self.vote_up() elif op =="votecancle": self.vote_cancle() elif op == "votedown": self.vote_down() elif op == "answer": answer_link = self.get_answer_link() from Answer import Answer answer = Answer(zhihu + answer_link) if answer.operate(): return True elif op == "question": from Question import Question question = Question(zhihu + self.get_question_link()) if question.operate(): return True elif op == "pwd": self.show_item_info() elif op == "quit": return True elif op == "help": self.help() elif op == "clear": clear() elif op == "break": break else: error()
def answer_operate(self): print "\n", answers = self.get_answers() answer_num = int(self.soup.find("span", class_="Tabs-meta").text) i = 0 count = 0 answerlist = [] mode = re.compile(r"^\d+$") for answer in answers: if i < limit and count != answer_num: print count answer.show_item_info() answerlist.append(answer) i += 1 count += 1 if i == limit or count == answer_num: while True: op = raw_input("{}\'s All Answers$ ".format( self.get_name())) if op == "": if count == answer_num: print termcolor.colored("没有更多回答", "red") else: clear() i = 0 break elif re.match(mode, op.strip()): opn = int(op) if opn < len(answerlist): if answerlist[opn].operate(): return True else: print termcolor.colored("请输入正确的序号", "red") elif op == "pwd": clear() start = max(0, count - limit) for x in xrange(start, count): print x answerlist[x].show_item_info() elif op == "browser": self.open_in_browser() elif op == "break": return False elif op == "help": self.help2() elif op == "quit": return True elif op == "clear": clear() else: error()
def answer_operate(self): print "\n", answers = self.get_answers() answer_num = int(self.soup.find("span", class_="Tabs-meta").text) i = 0 count = 0 answerlist = [] mode = re.compile(r"^\d+$") for answer in answers: if i < limit and count != answer_num: print count answer.show_item_info() answerlist.append(answer) i += 1 count += 1 if i == limit or count == answer_num: while True: op = raw_input("{}\'s All Answers$ ".format(self.get_name())) if op == "": if count == answer_num: print termcolor.colored("没有更多回答", "red") else: clear() i = 0 break elif re.match(mode, op.strip()): opn = int(op) if opn < len(answerlist): if answerlist[opn].operate(): return True else: print termcolor.colored("请输入正确的序号", "red") elif op == "pwd": clear() start = max(0, count - limit) for x in xrange(start, count): print x answerlist[x].show_item_info() elif op == "browser": self.open_in_browser() elif op == "break": return False elif op == "help": self.help2() elif op == "quit": return True elif op == "clear": clear() else: error()
def answer_operate(self): answers = self.get_answers() answer_num = self.get_answer_num() i = 0 count = 0 answerlist = [] mode = re.compile(r"^\d+$") for answer in answers: if i < limit and count < answer_num: print count answer.show_item_info() answerlist.append(answer) i += 1 count += 1 if i == limit or count == answer_num: while True: op = raw_input("All Answers of Question$ ") if op == "": if count == answer_num: print termcolor.colored("没有更多回答", "red") else: i = 0 clear() break elif re.match(mode, op.strip()): opn = int(op) if opn < len(answerlist): if answerlist[opn].operate(): return True elif op == "pwd": clear() start = max(0, count - limit) for x in xrange(start, count): print x answerlist[x].show_item_info() elif op == "browser": self.open_in_browser() elif op == "break": return False elif op == "help": self.help2() elif op == "quit": return True elif op == "clear": clear() else: error()
def operate(self): if not self.parse(): return True self.get_full_answer() while True: op = raw_input("Answer$ ") if op == "voteup": self.vote_up() elif op == "votedown": self.vote_down() elif op == "votecancle": self.vote_cancle() elif op == "collect": self.add_to_collections() elif op == "author": url = self.get_author_link() if not url: print termcolor.colored("作者为匿名用户", "green") else: from User import User user = User(zhihu + url) if user.operate(): return True elif op == "question": from Question import Question question = Question(zhihu + self.get_question()) if question.operate(): return True elif op == "browser": self.open_in_browser() elif op == "pwd": self.get_full_answer() elif op == "clear": clear() elif op == "break": break elif op == "quit": return True elif op == "help": self.help() else: error()
def operate(self): d = self.get_item_info() ftype = self.get_feed_type() print "\n".join(i for i in d[1] if i) + "\n" while True: global flag op = raw_input("Time Line Item$ ") if op == "answer": if ftype.startswith("ANSWER"): #print d[2][1] from Answer import Answer answer = Answer(d[2][1]) #print answer.get_full_answer() if answer.operate(): flag = False return True else: error() elif op == "question": if ftype.startswith("ANSWER") or ftype.startswith("QUESTION"): #print d[2][0] from Question import Question question = Question(d[2][0]) if question.operate(): flag = False return True else: error() elif op == "author": if d[2][2]: #print d[2][2] from User import User user = User(d[2][2], self._xsrf) if user.operate(): flag = False return True else: error() elif op == "zhuanlan": if ftype.find("ARTICLE") != -1: url = self.get_zhuanlan_link() from Zhuanlan import Zhuanlan zhuanlan = Zhuanlan(url) if zhuanlan.operate(): flag = False return True else: error() elif op == "pwd": print "\n".join(i for i in d[1] if i) + "\n" elif op == "help": self.help() elif op == "break": break elif op == "clear": clear() elif op == "quit": flag = False return True else: error()
def operate(self): d = self.get_item_info() ftype = self.get_feed_type() print "\n".join(i for i in d[1] if i) + "\n" while True: global flag op = raw_input("Time Line Item$ ") if op == "answer": if ftype.startswith("ANSWER"): #print d[2][1] from Answer import Answer answer = Answer(d[2][1]) #print answer.get_full_answer() if answer.operate(): flag = False return True else: error() elif op == "question": if ftype.startswith("ANSWER") or ftype.startswith("QUESTION"): #print d[2][0] from Question import Question question = Question(d[2][0]) if question.operate(): flag = False return True else: error() elif op == "author": if d[2][2]: #print d[2][2] from User import User user = User(d[2][2]) if user.operate(): flag = False return True else: error() elif op == "zhuanlan": if ftype.find("ARTICLE") != -1: url = self.get_zhuanlan_link() from Zhuanlan import Zhuanlan zhuanlan = Zhuanlan(url) if zhuanlan.operate(): flag = False return True else: error() elif op == "pwd": print "\n".join(i for i in d[1] if i) + "\n" elif op == "help": self.help() elif op == "break": break elif op == "clear": clear() elif op == "quit": flag = False return True else: error()