def coffee2js(script): global coffeeScriptConverter # We need only one instance of the CSConverter to survive for the whole life of PyPhantomJS if not coffeeScriptConverter: coffeeScriptConverter = CSConverter() return coffeeScriptConverter.convert(script)
def execute(self): if self.m_script.startsWith("#!"): self.m_script.prepend("//") if self.m_scriptFile.endswith(".coffee"): coffee = CSConverter(self) self.m_script = coffee.convert(self.m_script) self.m_page.mainFrame().evaluateJavaScript(self.m_script)
def execute(self): if self.m_script.startswith('#!'): self.m_script = '//' + self.m_script if self.m_scriptFile.lower().endswith('.coffee'): coffee = CSConverter(self) self.m_script = coffee.convert(self.m_script) self.m_page.mainFrame().evaluateJavaScript(self.m_script)
def loadScript(self, script): if script in self.m_loadScript_cache: self.m_page.mainFrame().evaluateJavaScript(self.m_loadScript_cache[script]) return True scriptFile = QString(script) try: script = open(script) script = QString.fromUtf8(script.read()) except IOError: return False if script.startsWith("#!"): script.prepend("//") if scriptFile.endsWith(".coffee"): coffee = CSConverter(self) script = QString.fromUtf8(coffee.convert(script)) self.m_loadScript_cache[scriptFile] = script self.m_page.mainFrame().evaluateJavaScript(script) return True
def loadScript(self, script): if script in self.m_loadScript_cache: self.m_page.mainFrame().evaluateJavaScript(self.m_loadScript_cache[script]) return True scriptFile = script try: script = codecs.open(self.m_scriptDir + script, encoding='utf-8') script = script.read() except IOError: return False if script.startswith('#!'): script = '//' + script if scriptFile.lower().endswith('.coffee'): coffee = CSConverter(self) script = coffee.convert(script) self.m_loadScript_cache[scriptFile] = script self.m_page.mainFrame().evaluateJavaScript(script) return True
def loadScript(self, script): if script in self.m_loadScript_cache: self.m_page.mainFrame().evaluateJavaScript(self.m_loadScript_cache[script]) return True scriptFile = QString(script) try: script = open(script) script = QString.fromUtf8(script.read()) except IOError: return False if script.startsWith('#!'): script.prepend('//') if scriptFile.endsWith('.coffee'): coffee = CSConverter(self) script = QString.fromUtf8(coffee.convert(script)) self.m_loadScript_cache[scriptFile] = script self.m_page.mainFrame().evaluateJavaScript(script) return True
def loadScript(self, script): if script in self.m_loadScript_cache: self.m_page.mainFrame().evaluateJavaScript( self.m_loadScript_cache[script]) return True scriptFile = script try: script = codecs.open(self.m_scriptDir + script, encoding='utf-8') script = script.read() except IOError: return False if script.startswith('#!'): script = '//' + script if scriptFile.lower().endswith('.coffee'): coffee = CSConverter(self) script = coffee.convert(script) self.m_loadScript_cache[scriptFile] = script self.m_page.mainFrame().evaluateJavaScript(script) return True