示例#1
0
	def test_heap(self):
		word.word.say = lambda _: True
		word.display = lambda _: True
		for pair in [('çekirge', 'grasshopper'), ('okul yılı', 'school year'), ('akort etmek', 'to tune'), ('oynamak', 'to preform'), ('düğmelemek', 'to button'), ('korku', 'fear'), ('memeli', 'mammal'), ('gelir', 'revenue')]:
			text, meaning = pair
			word.raw_input = lambda _: give_answer(.5, text)
			w = word.word(text, meaning)
			heap.heap_node(self.pl, w)
			self.check_values()
		for i in range(20):
			h = self.pl.heap_root
			word.raw_input = lambda _: give_answer(.5, h.word.text)
			h.word.guess_word()
			h.update()
			self.check_values()
示例#2
0
	def __init__(self, forum, content):
		self.forum = forum
		self.content = content
		self.parent = None
		self.child = None
		self.forum.last_content_time = self.content.post_time
		if content.thread_id in self.forum.thread_list:
			bottom = self.forum.thread_list[content.thread_id]
			while bottom.child is not None:
				bottom = bottom.child
			bottom.child = self
			self.parent = bottom
			self.thread_title = self.parent.thread_title
			self.forum_id = self.parent.forum_id
			for pl in self.forum.heap_list:
				pl.thread_heap_map[self.content.thread_id].update()
		else:
			self.forum.thread_list[self.content.thread_id] = self
			self.thread_title, self.forum_id = self.forum.feed.getThreadTitle(self.content.thread_id)
			for pl in self.forum.heap_list:
				heap.heap_node(pl, self)