예제 #1
0
        def _call(path, callback, *args):
            err = None
            files = JSArray([])
            try:
                files = JSArray(os.listdir(path))
            except Exception as e:
                err = e
            if (callback):

                def _callback():
                    ctx = getContext()
                    ctx._js_ctx.enter()
                    callback(err, files)
                    ctx._js_ctx.leave()

                sublime.set_timeout(_callback, 0)
예제 #2
0
	def on_ready(self):
		sublime.status_message('PyV8 binary successfully loaded')
		if(not ctx):
			globals()['ctx'] = JSCore(self.log)
			from PyV8 import JSClass, JSObject, JSArray, JSFunction
			ctx.JSClass = lambda obj: JSClass(convert(obj))
			ctx.JSObject = lambda obj: JSObject(convert(obj))
			ctx.JSArray = lambda obj: JSArray(convert(obj))
			ctx.JSFunction = lambda obj: JSFunction(convert(obj))
			ctx.load_js_file(os.path.join(BASE_PATH, "SublimeJS/js/core.js"))
			if('js_loading_queue' in globals()):
				for i in globals()['js_loading_queue']:
					ctx.load_js_file(i)
예제 #3
0
	def childNodes(self):
		node = self._soup
		return JSArray([normalizeNode(node) for node in node.contents])
예제 #4
0
	def getElementsByClassName(self, className):
		nodelist = self._soup.findAll(None, {"class":className})
		return JSArray([normalizeNode(node) for node in nodelist])
예제 #5
0
	def getElementsByTagName(self, tagName):
		if(tagName == '*'):
			tagName = True		
		nodelist = self._soup.findAll(tagName)
		return JSArray([normalizeNode(node) for node in nodelist])
예제 #6
0
	def children(self):
		return JSArray(filter(lambda n: n.nodeType == 1, self.childNodes))
예제 #7
0
 def readdirSync(self, path):
     return JSArray(os.listdir(path))