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)
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)
def childNodes(self): node = self._soup return JSArray([normalizeNode(node) for node in node.contents])
def getElementsByClassName(self, className): nodelist = self._soup.findAll(None, {"class":className}) return JSArray([normalizeNode(node) for node in nodelist])
def getElementsByTagName(self, tagName): if(tagName == '*'): tagName = True nodelist = self._soup.findAll(tagName) return JSArray([normalizeNode(node) for node in nodelist])
def children(self): return JSArray(filter(lambda n: n.nodeType == 1, self.childNodes))
def readdirSync(self, path): return JSArray(os.listdir(path))