예제 #1
0
class IMDBScraper:
	def __init__(self, file_name):
		self.open_file = File(file_name)
		self.open_file.skipToData()
		
	def next(self):
		actor = Actor("init", "actor")
		for line in self.open_file.next():
			if (line.containsActorName()):
				yield actor
				actor, film = line.getActorAndFilm()
				actor.addFilm(film)
			else:
				film = line.getFilm()
				if not film is None:
					actor.addFilm(film)
예제 #2
0
파일: vcoq.py 프로젝트: QuanticPotato/vcoq
class Plugin:

	def __init__(self):
		self.windowsManager = WM.WindowsManager(self)
		self.coqManager = CM.CoqManager(self.windowsManager)
		self.instance = None
		self.launched = False

	def launch(self): 
		# Don't relaunched if it is already running !
		if self.launched == True:
			return False
		self.launched = True
		vim.command(":call MapVcoq()")
		self.windowsManager.setupWindows()
		self.coqManager.launchCoqtopProcess()
		self.instance = File(self, (self.windowsManager.windowBuffers['__Edit__'],
			self.windowsManager.windowBuffers['__Compiled__']))
		self.windowsManager.focusWindow("__Edit__")
	
	def shutdown(self):
		self.launched = False
		error("Stopping vcoq ...")
		vim.command('windo bd') # Close every windows

	def next(self):
		if self.instance != None:
			self.instance.next()

	def prev(self):
		if self.instance != None:
			self.instance.prev()

	################
	## Vim events ##
	################

	def onBufferFocus(self, entered, buffer):
		""" This function is called when the user enter or leave a buffer.
		It setups (and removes) the special maps for this buffer.
		It also perform extra actions, depending on the buffer. """
		if self.launched == False:
			return 0
		if buffer == '__Input__':
			cmd = 'imap <buffer> <CR> <Esc>:py vcoq.main.coqManager.sendQueryCommand()<CR>a' if entered else 'mapclear <buffer>'
			vim.command(cmd)
		return 1

	def onVimResized(self):
		if self.launched == False: return 0
		self.windowsManager.updateWindows()
		return 0

	def onEnter(self, buffer):
		if self.launched == False: return 0
		self.windowsManager.onEnter(buffer)
		return 0

	def onWrite(self, filename):
		if self.launched == False: 
			error("Vcoq isn't running", prompt=False)
			return 0
		self.instance.write(filename)
		return 0

	def onOpen(self, filename):
		if self.launched == False: 
			error("Vcoq isn't running", prompt=False)
			return 0
		self.instance.open(filename)
		return 0