示例#1
0
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)
示例#2
0
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)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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
示例#7
0
    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
示例#8
0
    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
示例#9
0
    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